src/mess/video/samcoupe.c
| r3703 | r3704 | |
| 13 | 13 | #include "includes/samcoupe.h" |
| 14 | 14 | |
| 15 | 15 | |
| 16 | | static void drawMode4_line(bitmap_t *bitmap,int y) |
| 16 | static void draw_mode4_line(const device_config *screen, bitmap_t *bitmap, int y) |
| 17 | 17 | { |
| 18 | coupe_asic *asic = screen->machine->driver_data; |
| 18 | 19 | int x; |
| 19 | | unsigned char tmp=0; |
| 20 | 20 | |
| 21 | | for (x=0;x<256;) |
| 21 | for (x = 0; x < 256;) |
| 22 | 22 | { |
| 23 | | tmp=*(videoram + (x/2) + (y*128)); |
| 23 | UINT8 tmp = *(videoram + (x/2) + (y*128)); |
| 24 | |
| 24 | 25 | #ifdef MONO |
| 25 | 26 | if (tmp>>4) |
| 26 | 27 | { |
| r3703 | r3704 | |
| 45 | 46 | } |
| 46 | 47 | x++; |
| 47 | 48 | #else |
| 48 | | *BITMAP_ADDR16(bitmap, y, x*2+0) = samcoupe_regs.clut[tmp>>4]; |
| 49 | | *BITMAP_ADDR16(bitmap, y, x*2+1) = samcoupe_regs.clut[tmp>>4]; |
| 49 | *BITMAP_ADDR16(bitmap, y, x*2+0) = asic->clut[tmp >> 4]; |
| 50 | *BITMAP_ADDR16(bitmap, y, x*2+1) = asic->clut[tmp >> 4]; |
| 50 | 51 | x++; |
| 51 | | *BITMAP_ADDR16(bitmap, y, x*2+0) = samcoupe_regs.clut[tmp&0x0F]; |
| 52 | | *BITMAP_ADDR16(bitmap, y, x*2+1) = samcoupe_regs.clut[tmp&0x0F]; |
| 52 | *BITMAP_ADDR16(bitmap, y, x*2+0) = asic->clut[tmp & 0x0f]; |
| 53 | *BITMAP_ADDR16(bitmap, y, x*2+1) = asic->clut[tmp & 0x0f]; |
| 53 | 54 | x++; |
| 54 | 55 | #endif |
| 55 | 56 | } |
| 56 | 57 | } |
| 57 | 58 | |
| 58 | | static void drawMode3_line(bitmap_t *bitmap,int y) |
| 59 | static void draw_mode3_line(const device_config *screen, bitmap_t *bitmap, int y) |
| 59 | 60 | { |
| 61 | coupe_asic *asic = screen->machine->driver_data; |
| 60 | 62 | int x; |
| 61 | | unsigned char tmp=0; |
| 62 | 63 | |
| 63 | | for (x=0;x<512;) |
| 64 | for (x = 0; x < 512;) |
| 64 | 65 | { |
| 65 | | tmp=*(videoram + (x/4) + (y*128)); |
| 66 | UINT8 tmp = *(videoram + (x/4) + (y*128)); |
| 67 | |
| 66 | 68 | #ifdef MONO |
| 67 | | if (tmp>>6) |
| 68 | | plot_pixel(bitmap,x,y,127); |
| 69 | if (tmp >> 6) |
| 70 | plot_pixel(bitmap, x, y, 127); |
| 69 | 71 | else |
| 70 | | plot_pixel(bitmap,x,y,0); |
| 72 | plot_pixel(bitmap, x, y, 0); |
| 71 | 73 | x++; |
| 72 | | if ((tmp>>4)&0x03) |
| 73 | | plot_pixel(bitmap,x,y,127); |
| 74 | if ((tmp >> 4) & 0x03) |
| 75 | plot_pixel(bitmap, x, y, 127); |
| 74 | 76 | else |
| 75 | | plot_pixel(bitmap,x,y,0); |
| 77 | plot_pixel(bitmap, x, y, 0); |
| 76 | 78 | x++; |
| 77 | | if ((tmp>>2)&0x03) |
| 78 | | plot_pixel(bitmap,x,y,127); |
| 79 | if ((tmp >> 2) & 0x03) |
| 80 | plot_pixel(bitmap, x, y, 127); |
| 79 | 81 | else |
| 80 | | plot_pixel(bitmap,x,y,0); |
| 82 | plot_pixel(bitmap, x, y, 0); |
| 81 | 83 | x++; |
| 82 | | if (tmp&0x03) |
| 83 | | plot_pixel(bitmap,x,y,127); |
| 84 | if (tmp & 0x03) |
| 85 | plot_pixel(bitmap, x, y, 127); |
| 84 | 86 | else |
| 85 | | plot_pixel(bitmap,x,y,0); |
| 87 | plot_pixel(bitmap, x, y, 0); |
| 86 | 88 | x++; |
| 87 | 89 | #else |
| 88 | | *BITMAP_ADDR16(bitmap, y, x) = samcoupe_regs.clut[tmp>>6]; |
| 90 | *BITMAP_ADDR16(bitmap, y, x) = asic->clut[tmp >> 6]; |
| 89 | 91 | x++; |
| 90 | | *BITMAP_ADDR16(bitmap, y, x) = samcoupe_regs.clut[(tmp>>4)&0x03]; |
| 92 | *BITMAP_ADDR16(bitmap, y, x) = asic->clut[(tmp >> 4) & 0x03]; |
| 91 | 93 | x++; |
| 92 | | *BITMAP_ADDR16(bitmap, y, x) = samcoupe_regs.clut[(tmp>>2)&0x03]; |
| 94 | *BITMAP_ADDR16(bitmap, y, x) = asic->clut[(tmp >> 2) & 0x03]; |
| 93 | 95 | x++; |
| 94 | | *BITMAP_ADDR16(bitmap, y, x) = samcoupe_regs.clut[tmp&0x03]; |
| 96 | *BITMAP_ADDR16(bitmap, y, x) = asic->clut[tmp & 0x03]; |
| 95 | 97 | x++; |
| 96 | 98 | #endif |
| 97 | 99 | } |
| 98 | 100 | } |
| 99 | 101 | |
| 100 | | static void drawMode2_line(bitmap_t *bitmap,int y) |
| 102 | static void draw_mode2_line(const device_config *screen, bitmap_t *bitmap, int y) |
| 101 | 103 | { |
| 102 | | int x,b,scrx; |
| 103 | | unsigned char tmp=0; |
| 104 | | unsigned short ink,pap; |
| 105 | | unsigned char *attr; |
| 104 | coupe_asic *asic = screen->machine->driver_data; |
| 105 | int b, scrx = 0; |
| 106 | UINT16 ink = 127, pap = 0; |
| 107 | UINT8 *attr = videoram + 32*192 + y*32; |
| 108 | int x; |
| 106 | 109 | |
| 107 | | attr=videoram + 32*192 + y*32; |
| 108 | | |
| 109 | | scrx=0; |
| 110 | | for (x=0;x<256/8;x++) |
| 110 | for (x = 0; x < 256/8; x++) |
| 111 | 111 | { |
| 112 | | tmp=*(videoram + x + (y*32)); |
| 113 | | #ifdef MONO |
| 114 | | ink = 127; |
| 115 | | pap = 0; |
| 116 | | #else |
| 117 | | ink = samcoupe_regs.clut[(*attr) & 0x07]; |
| 118 | | pap = samcoupe_regs.clut[((*attr)>>3) & 0x07]; |
| 112 | UINT8 tmp = *(videoram + x + (y*32)); |
| 113 | |
| 114 | #ifndef MONO |
| 115 | ink = asic->clut[(*attr) & 0x07]; |
| 116 | pap = asic->clut[((*attr) >> 3) & 0x07]; |
| 119 | 117 | #endif |
| 118 | |
| 120 | 119 | attr++; |
| 121 | 120 | |
| 122 | | for (b=0x80;b!=0;b>>=1) |
| 121 | for (b = 0x80; b!= 0; b >>= 1) |
| 123 | 122 | { |
| 124 | | *BITMAP_ADDR16(bitmap, y, scrx++) = (tmp&b) ? ink : pap; |
| 125 | | *BITMAP_ADDR16(bitmap, y, scrx++) = (tmp&b) ? ink : pap; |
| 123 | *BITMAP_ADDR16(bitmap, y, scrx++) = (tmp & b) ? ink : pap; |
| 124 | *BITMAP_ADDR16(bitmap, y, scrx++) = (tmp & b) ? ink : pap; |
| 126 | 125 | } |
| 127 | 126 | } |
| 128 | 127 | } |
| 129 | 128 | |
| 130 | | static void drawMode1_line(bitmap_t *bitmap,int y) |
| 129 | static void draw_mode1_line(const device_config *screen, bitmap_t *bitmap, int y) |
| 131 | 130 | { |
| 132 | | int x,b,scrx,scry; |
| 133 | | unsigned char tmp=0; |
| 134 | | unsigned short ink,pap; |
| 135 | | unsigned char *attr; |
| 131 | coupe_asic *asic = screen->machine->driver_data; |
| 132 | int x, b; |
| 133 | UINT16 ink = 127, pap = 0; |
| 134 | UINT8 *attr = videoram + 32*192 + (y/8)*32; |
| 136 | 135 | |
| 137 | | attr=videoram + 32*192 + (y/8)*32; |
| 136 | int scrx = 0; |
| 137 | int scry = ((y & 7) * 8) + ((y & 0x38) >> 3) + (y & 0xc0); |
| 138 | 138 | |
| 139 | | scrx=0; |
| 140 | | scry=((y&7) * 8) + ((y&0x38)>>3) + (y&0xC0); |
| 141 | | for (x=0;x<256/8;x++) |
| 139 | for (x = 0; x < 256/8; x++) |
| 142 | 140 | { |
| 143 | | tmp=*(videoram + x + (y*32)); |
| 144 | | #ifdef MONO |
| 145 | | ink = 127; |
| 146 | | pap = 0; |
| 147 | | #else |
| 148 | | ink = samcoupe_regs.clut[(*attr) & 0x07]; |
| 149 | | pap = samcoupe_regs.clut[((*attr)>>3) & 0x07]; |
| 141 | UINT8 tmp = *(videoram + x + (y*32)); |
| 142 | |
| 143 | #ifndef MONO |
| 144 | ink = asic->clut[(*attr) & 0x07]; |
| 145 | pap = asic->clut[((*attr)>>3) & 0x07]; |
| 150 | 146 | #endif |
| 147 | |
| 151 | 148 | attr++; |
| 152 | | for (b=0x80;b!=0;b>>=1) |
| 149 | |
| 150 | for (b = 0x80; b != 0; b>>= 1) |
| 153 | 151 | { |
| 154 | | *BITMAP_ADDR16(bitmap, scry, scrx++) = (tmp&b) ? ink : pap; |
| 155 | | *BITMAP_ADDR16(bitmap, scry, scrx++) = (tmp&b) ? ink : pap; |
| 152 | *BITMAP_ADDR16(bitmap, scry, scrx++) = (tmp & b) ? ink : pap; |
| 153 | *BITMAP_ADDR16(bitmap, scry, scrx++) = (tmp & b) ? ink : pap; |
| 156 | 154 | } |
| 157 | 155 | } |
| 158 | 156 | } |
| r3703 | r3704 | |
| 160 | 158 | VIDEO_UPDATE( samcoupe ) |
| 161 | 159 | { |
| 162 | 160 | int scanline = video_screen_get_vpos(screen); |
| 161 | coupe_asic *asic = screen->machine->driver_data; |
| 163 | 162 | |
| 164 | 163 | /* line interrupt? */ |
| 165 | | if (samcoupe_regs.line_int == scanline) samcoupe_irq(screen->machine, 0x01); |
| 164 | if (asic->line_int == scanline) |
| 165 | samcoupe_irq(screen->machine->cpu[0], 0x01); |
| 166 | 166 | |
| 167 | 167 | /* display disabled? (only in mode 3 or 4) */ |
| 168 | | if ((samcoupe_regs.vmpr & 0x40) && (samcoupe_regs.border & 0x80)) |
| 168 | if ((asic->vmpr & 0x40) && (asic->border & 0x80)) |
| 169 | 169 | { |
| 170 | /* display is disabled, draw a black screen */ |
| 170 | 171 | fillbitmap(bitmap, 0, cliprect); |
| 171 | 172 | } |
| 172 | 173 | else |
| 173 | 174 | { |
| 174 | | switch ((samcoupe_regs.vmpr & 0x60) >> 5) |
| 175 | /* display enabled, draw line in the right screen mode */ |
| 176 | switch ((asic->vmpr & 0x60) >> 5) |
| 175 | 177 | { |
| 176 | | case 0: /* mode 1 */ |
| 177 | | drawMode1_line(bitmap, scanline); |
| 178 | | break; |
| 179 | | case 1: /* mode 2 */ |
| 180 | | drawMode2_line(bitmap, scanline); |
| 181 | | break; |
| 182 | | case 2: /* mode 3 */ |
| 183 | | drawMode3_line(bitmap, scanline); |
| 184 | | break; |
| 185 | | case 3: /* mode 4 */ |
| 186 | | drawMode4_line(bitmap, scanline); |
| 187 | | break; |
| 178 | case 0: draw_mode1_line(screen, bitmap, scanline); break; |
| 179 | case 1: draw_mode2_line(screen, bitmap, scanline); break; |
| 180 | case 2: draw_mode3_line(screen, bitmap, scanline); break; |
| 181 | case 3: draw_mode4_line(screen, bitmap, scanline); break; |
| 188 | 182 | } |
| 189 | 183 | } |
| 190 | 184 | |
src/mess/machine/samcoupe.c
| r3703 | r3704 | |
| 19 | 19 | #define HMPR_MCNTRL 0x80 /* If set external RAM is enabled */ |
| 20 | 20 | |
| 21 | 21 | |
| 22 | | struct samcoupe_asic samcoupe_regs; |
| 23 | | |
| 24 | | |
| 25 | | static void samcoupe_update_bank(running_machine *machine, int bank, UINT8 *memory, int is_readonly) |
| 22 | static void samcoupe_update_bank(const address_space *space, int bank, UINT8 *memory, int is_readonly) |
| 26 | 23 | { |
| 27 | | const address_space *space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM); |
| 28 | 24 | read8_space_func rh = SMH_NOP; |
| 29 | 25 | write8_space_func wh = SMH_NOP; |
| 30 | 26 | |
| 31 | 27 | if (memory) |
| 32 | 28 | { |
| 33 | | memory_set_bankptr(machine,bank, memory); |
| 29 | memory_set_bankptr(space->machine, bank, memory); |
| 34 | 30 | rh = (read8_space_func) (STATIC_BANK1 + (FPTR)bank - 1); |
| 35 | 31 | wh = is_readonly ? SMH_UNMAP : (write8_space_func) (STATIC_BANK1 + (FPTR)bank - 1); |
| 36 | 32 | } |
| r3703 | r3704 | |
| 40 | 36 | } |
| 41 | 37 | |
| 42 | 38 | |
| 43 | | static void samcoupe_install_ext_mem(running_machine *machine) |
| 39 | static void samcoupe_install_ext_mem(const address_space *space) |
| 44 | 40 | { |
| 41 | coupe_asic *asic = space->machine->driver_data; |
| 45 | 42 | UINT8 *mem; |
| 46 | 43 | |
| 47 | 44 | /* bank 3 */ |
| 48 | | if (samcoupe_regs.lext >> 6 < mess_ram_size >> 20) |
| 49 | | mem = &mess_ram[(mess_ram_size & 0xfffff) + (samcoupe_regs.lext >> 6) * 0x100000 + (samcoupe_regs.lext & 0x3f) * 0x4000]; |
| 45 | if (asic->lext >> 6 < mess_ram_size >> 20) |
| 46 | mem = &mess_ram[(mess_ram_size & 0xfffff) + (asic->lext >> 6) * 0x100000 + (asic->lext & 0x3f) * 0x4000]; |
| 50 | 47 | else |
| 51 | 48 | mem = NULL; |
| 52 | 49 | |
| 53 | | samcoupe_update_bank(machine, 3, mem, FALSE); |
| 50 | samcoupe_update_bank(space, 3, mem, FALSE); |
| 54 | 51 | |
| 55 | 52 | /* bank 4 */ |
| 56 | | if (samcoupe_regs.hext >> 6 < mess_ram_size >> 20) |
| 57 | | mem = &mess_ram[(mess_ram_size & 0xfffff) + (samcoupe_regs.hext >> 6) * 0x100000 + (samcoupe_regs.hext & 0x3f) * 0x4000]; |
| 53 | if (asic->hext >> 6 < mess_ram_size >> 20) |
| 54 | mem = &mess_ram[(mess_ram_size & 0xfffff) + (asic->hext >> 6) * 0x100000 + (asic->hext & 0x3f) * 0x4000]; |
| 58 | 55 | else |
| 59 | 56 | mem = NULL; |
| 60 | 57 | |
| 61 | | samcoupe_update_bank(machine, 4, mem, FALSE); |
| 58 | samcoupe_update_bank(space, 4, mem, FALSE); |
| 62 | 59 | } |
| 63 | 60 | |
| 64 | 61 | |
| 65 | | void samcoupe_update_memory(running_machine *machine) |
| 62 | void samcoupe_update_memory(const address_space *space) |
| 66 | 63 | { |
| 64 | coupe_asic *asic = space->machine->driver_data; |
| 67 | 65 | const int PAGE_MASK = ((mess_ram_size & 0xfffff) / 0x4000) - 1; |
| 68 | | UINT8 *rom = memory_region(machine, "main"); |
| 66 | UINT8 *rom = memory_region(space->machine, "main"); |
| 69 | 67 | UINT8 *memory; |
| 70 | 68 | int is_readonly; |
| 71 | 69 | |
| 72 | 70 | /* BANK1 */ |
| 73 | | if (samcoupe_regs.lmpr & LMPR_RAM0) /* Is ram paged in at bank 1 */ |
| 71 | if (asic->lmpr & LMPR_RAM0) /* Is ram paged in at bank 1 */ |
| 74 | 72 | { |
| 75 | | if ((samcoupe_regs.lmpr & 0x1F) <= PAGE_MASK) |
| 76 | | memory = &mess_ram[(samcoupe_regs.lmpr & PAGE_MASK) * 0x4000]; |
| 73 | if ((asic->lmpr & 0x1F) <= PAGE_MASK) |
| 74 | memory = &mess_ram[(asic->lmpr & PAGE_MASK) * 0x4000]; |
| 77 | 75 | else |
| 78 | 76 | memory = NULL; /* Attempt to page in non existant ram region */ |
| 79 | 77 | is_readonly = FALSE; |
| r3703 | r3704 | |
| 83 | 81 | memory = rom; /* Rom0 paged in */ |
| 84 | 82 | is_readonly = TRUE; |
| 85 | 83 | } |
| 86 | | samcoupe_update_bank(machine, 1, memory, is_readonly); |
| 84 | samcoupe_update_bank(space, 1, memory, is_readonly); |
| 87 | 85 | |
| 88 | 86 | |
| 89 | 87 | /* BANK2 */ |
| 90 | | if (((samcoupe_regs.lmpr + 1) & 0x1f) <= PAGE_MASK) |
| 91 | | memory = &mess_ram[((samcoupe_regs.lmpr + 1) & PAGE_MASK) * 0x4000]; |
| 88 | if (((asic->lmpr + 1) & 0x1f) <= PAGE_MASK) |
| 89 | memory = &mess_ram[((asic->lmpr + 1) & PAGE_MASK) * 0x4000]; |
| 92 | 90 | else |
| 93 | 91 | memory = NULL; /* Attempt to page in non existant ram region */ |
| 94 | | samcoupe_update_bank(machine, 2, memory, FALSE); |
| 92 | samcoupe_update_bank(space, 2, memory, FALSE); |
| 95 | 93 | |
| 96 | 94 | /* only update bank 3 and 4 when external memory is not enabled */ |
| 97 | | if (samcoupe_regs.hmpr & HMPR_MCNTRL) |
| 95 | if (asic->hmpr & HMPR_MCNTRL) |
| 98 | 96 | { |
| 99 | | samcoupe_install_ext_mem(machine); |
| 97 | samcoupe_install_ext_mem(space); |
| 100 | 98 | } |
| 101 | 99 | else |
| 102 | 100 | { |
| 103 | 101 | /* BANK3 */ |
| 104 | | if ((samcoupe_regs.hmpr & 0x1F) <= PAGE_MASK ) |
| 105 | | memory = &mess_ram[(samcoupe_regs.hmpr & PAGE_MASK)*0x4000]; |
| 102 | if ((asic->hmpr & 0x1F) <= PAGE_MASK ) |
| 103 | memory = &mess_ram[(asic->hmpr & PAGE_MASK)*0x4000]; |
| 106 | 104 | else |
| 107 | 105 | memory = NULL; /* Attempt to page in non existant ram region */ |
| 108 | | samcoupe_update_bank(machine, 3, memory, FALSE); |
| 106 | samcoupe_update_bank(space, 3, memory, FALSE); |
| 109 | 107 | |
| 110 | 108 | |
| 111 | 109 | /* BANK4 */ |
| 112 | | if (samcoupe_regs.lmpr & LMPR_ROM1) /* Is Rom1 paged in at bank 4 */ |
| 110 | if (asic->lmpr & LMPR_ROM1) /* Is Rom1 paged in at bank 4 */ |
| 113 | 111 | { |
| 114 | 112 | memory = rom + 0x4000; |
| 115 | 113 | is_readonly = TRUE; |
| 116 | 114 | } |
| 117 | 115 | else |
| 118 | 116 | { |
| 119 | | if (((samcoupe_regs.hmpr + 1) & 0x1f) <= PAGE_MASK) |
| 120 | | memory = &mess_ram[((samcoupe_regs.hmpr + 1) & PAGE_MASK) * 0x4000]; |
| 117 | if (((asic->hmpr + 1) & 0x1f) <= PAGE_MASK) |
| 118 | memory = &mess_ram[((asic->hmpr + 1) & PAGE_MASK) * 0x4000]; |
| 121 | 119 | else |
| 122 | 120 | memory = NULL; /* Attempt to page in non existant ram region */ |
| 123 | 121 | is_readonly = FALSE; |
| 124 | 122 | } |
| 125 | | samcoupe_update_bank(machine, 4, memory, FALSE); |
| 123 | samcoupe_update_bank(space, 4, memory, FALSE); |
| 126 | 124 | } |
| 127 | 125 | |
| 128 | 126 | /* video memory location */ |
| 129 | | if (samcoupe_regs.vmpr & 0x40) /* if bit set in 2 bank screen mode */ |
| 130 | | videoram = &mess_ram[((samcoupe_regs.vmpr & 0x1e) & PAGE_MASK) * 0x4000]; |
| 127 | if (asic->vmpr & 0x40) /* if bit set in 2 bank screen mode */ |
| 128 | videoram = &mess_ram[((asic->vmpr & 0x1e) & PAGE_MASK) * 0x4000]; |
| 131 | 129 | else |
| 132 | | videoram = &mess_ram[((samcoupe_regs.vmpr & 0x1f) & PAGE_MASK) * 0x4000]; |
| 130 | videoram = &mess_ram[((asic->vmpr & 0x1f) & PAGE_MASK) * 0x4000]; |
| 133 | 131 | } |
| 134 | 132 | |
| 135 | 133 | |
| 136 | 134 | WRITE8_HANDLER( samcoupe_ext_mem_w ) |
| 137 | 135 | { |
| 136 | const address_space *space_program = cpu_get_address_space(space->machine->cpu[0], ADDRESS_SPACE_PROGRAM); |
| 137 | coupe_asic *asic = space->machine->driver_data; |
| 138 | |
| 138 | 139 | if (offset & 1) |
| 139 | | samcoupe_regs.hext = data; |
| 140 | asic->hext = data; |
| 140 | 141 | else |
| 141 | | samcoupe_regs.lext = data; |
| 142 | asic->lext = data; |
| 142 | 143 | |
| 143 | 144 | /* external RAM enabled? */ |
| 144 | | if (samcoupe_regs.hmpr & HMPR_MCNTRL) |
| 145 | if (asic->hmpr & HMPR_MCNTRL) |
| 145 | 146 | { |
| 146 | | samcoupe_install_ext_mem(space->machine); |
| 147 | samcoupe_install_ext_mem(space_program); |
| 147 | 148 | } |
| 148 | 149 | } |
| 149 | 150 | |
| r3703 | r3704 | |
| 164 | 165 | |
| 165 | 166 | MACHINE_RESET( samcoupe ) |
| 166 | 167 | { |
| 168 | const address_space *space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM); |
| 167 | 169 | const address_space *spaceio = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_IO); |
| 168 | | memset(&samcoupe_regs, 0, sizeof(samcoupe_regs)); |
| 169 | | |
| 170 | | samcoupe_regs.lmpr = 0x0f; /* ROM0 paged in, ROM1 paged out RAM Banks */ |
| 171 | | samcoupe_regs.hmpr = 0x01; |
| 172 | | samcoupe_regs.vmpr = 0x81; |
| 173 | | samcoupe_regs.line_int = 0xff; /* line interrupts disabled */ |
| 174 | | samcoupe_regs.status = 0x1f; /* no interrupts active */ |
| 170 | coupe_asic *asic = machine->driver_data; |
| 175 | 171 | |
| 172 | asic->lmpr = 0x0f; /* ROM0 paged in, ROM1 paged out RAM Banks */ |
| 173 | asic->hmpr = 0x01; |
| 174 | asic->vmpr = 0x81; |
| 175 | asic->line_int = 0xff; /* line interrupts disabled */ |
| 176 | asic->status = 0x1f; /* no interrupts active */ |
| 177 | |
| 176 | 178 | if (input_port_read(machine, "config") & 0x01) |
| 177 | 179 | { |
| 178 | 180 | /* install RTC */ |
| r3703 | r3704 | |
| 184 | 186 | memory_install_readwrite8_handler(spaceio, 0xef, 0xef, 0xffff, 0xff00, SMH_UNMAP, SMH_UNMAP); |
| 185 | 187 | } |
| 186 | 188 | |
| 187 | | samcoupe_update_memory(machine); |
| 189 | samcoupe_update_memory(space); |
| 188 | 190 | } |
| 189 | 191 | |
| 190 | 192 | |
src/mess/drivers/samcoupe.c
| r3703 | r3704 | |
| 25 | 25 | the future to support others |
| 26 | 26 | |
| 27 | 27 | Note on the bioses: |
| 28 | | SAM Coupé ROM Images |
| 28 | SAM Coupe ROM Images |
| 29 | 29 | -------------------- |
| 30 | 30 | |
| 31 | | This archive contains many versions of the SAM Coupé 32K ROM image, released |
| 31 | This archive contains many versions of the SAM Coupe 32K ROM image, released |
| 32 | 32 | with kind permission from the ROM author, Dr Andy Wright. |
| 33 | 33 | |
| 34 | 34 | Thanks to Simon N Goodwin for supplying the files, which include two dumped |
| 35 | 35 | from pre-production hardware (and which only work with the early hardware!). |
| 36 | | |
| 36 | |
| 37 | 37 | Beware - the early ROMs are very buggy, and tend to go mad once BASIC starts |
| 38 | 38 | paging. ROM 10 (version 1.0) requires the CALL after F9 or BOOT because the |
| 39 | 39 | ROM loads the bootstrap but fails to execute it. The address depends on the |
| r3703 | r3704 | |
| 121 | 121 | if (offset & 0x100) |
| 122 | 122 | { |
| 123 | 123 | /* return either the current line or 192 for the vblank area */ |
| 124 | | int line = video_screen_get_vpos(space->machine->primary_screen); |
| 124 | int line = video_screen_get_vpos(space->machine->primary_screen); |
| 125 | 125 | data = video_screen_get_vblank(space->machine->primary_screen) ? 192 : line; |
| 126 | 126 | } |
| 127 | 127 | else |
| r3703 | r3704 | |
| 135 | 135 | |
| 136 | 136 | |
| 137 | 137 | static WRITE8_HANDLER( samcoupe_clut_w ) |
| 138 | | { |
| 139 | | samcoupe_regs.clut[(offset >> 8) & 0x0f] = data & 0x7f; |
| 138 | { |
| 139 | coupe_asic *asic = space->machine->driver_data; |
| 140 | asic->clut[(offset >> 8) & 0x0f] = data & 0x7f; |
| 140 | 141 | } |
| 141 | 142 | |
| 142 | 143 | |
| 143 | 144 | static READ8_HANDLER( samcoupe_status_r ) |
| 144 | 145 | { |
| 146 | coupe_asic *asic = space->machine->driver_data; |
| 145 | 147 | UINT8 data = 0xe0; |
| 146 | 148 | UINT8 row = ~(offset >> 8); |
| 147 | 149 | |
| r3703 | r3704 | |
| 154 | 156 | if (row & 0x02) data &= input_port_read(space->machine, "keyboard_row_fd") & 0xe0; |
| 155 | 157 | if (row & 0x01) data &= input_port_read(space->machine, "keyboard_row_fe") & 0xe0; |
| 156 | 158 | |
| 157 | | return data | samcoupe_regs.status; |
| 159 | return data | asic->status; |
| 158 | 160 | } |
| 159 | 161 | |
| 160 | 162 | |
| 161 | 163 | static WRITE8_HANDLER( samcoupe_line_int_w ) |
| 162 | 164 | { |
| 163 | | samcoupe_regs.line_int = data; |
| 165 | coupe_asic *asic = space->machine->driver_data; |
| 166 | asic->line_int = data; |
| 164 | 167 | } |
| 165 | 168 | |
| 166 | 169 | |
| 167 | 170 | static READ8_HANDLER( samcoupe_lmpr_r ) |
| 168 | 171 | { |
| 169 | | return samcoupe_regs.lmpr; |
| 172 | coupe_asic *asic = space->machine->driver_data; |
| 173 | return asic->lmpr; |
| 170 | 174 | } |
| 171 | 175 | |
| 172 | 176 | |
| 173 | 177 | static WRITE8_HANDLER( samcoupe_lmpr_w ) |
| 174 | 178 | { |
| 175 | | samcoupe_regs.lmpr = data; |
| 176 | | samcoupe_update_memory(space->machine); |
| 179 | const address_space *space_program = cpu_get_address_space(space->machine->cpu[0], ADDRESS_SPACE_PROGRAM); |
| 180 | coupe_asic *asic = space->machine->driver_data; |
| 181 | asic->lmpr = data; |
| 182 | samcoupe_update_memory(space_program); |
| 177 | 183 | } |
| 178 | 184 | |
| 179 | 185 | |
| 180 | 186 | static READ8_HANDLER( samcoupe_hmpr_r ) |
| 181 | 187 | { |
| 182 | | return samcoupe_regs.hmpr; |
| 188 | coupe_asic *asic = space->machine->driver_data; |
| 189 | return asic->hmpr; |
| 183 | 190 | } |
| 184 | 191 | |
| 185 | 192 | |
| 186 | 193 | static WRITE8_HANDLER( samcoupe_hmpr_w ) |
| 187 | 194 | { |
| 188 | | samcoupe_regs.hmpr = data; |
| 189 | | samcoupe_update_memory(space->machine); |
| 195 | const address_space *space_program = cpu_get_address_space(space->machine->cpu[0], ADDRESS_SPACE_PROGRAM); |
| 196 | coupe_asic *asic = space->machine->driver_data; |
| 197 | asic->hmpr = data; |
| 198 | samcoupe_update_memory(space_program); |
| 190 | 199 | } |
| 191 | 200 | |
| 192 | 201 | |
| 193 | 202 | static READ8_HANDLER( samcoupe_vmpr_r ) |
| 194 | 203 | { |
| 195 | | return samcoupe_regs.vmpr; |
| 204 | coupe_asic *asic = space->machine->driver_data; |
| 205 | return asic->vmpr; |
| 196 | 206 | } |
| 197 | 207 | |
| 198 | 208 | |
| 199 | 209 | static WRITE8_HANDLER( samcoupe_vmpr_w ) |
| 200 | 210 | { |
| 201 | | samcoupe_regs.vmpr = data; |
| 202 | | samcoupe_update_memory(space->machine); |
| 211 | const address_space *space_program = cpu_get_address_space(space->machine->cpu[0], ADDRESS_SPACE_PROGRAM); |
| 212 | coupe_asic *asic = space->machine->driver_data; |
| 213 | asic->vmpr = data; |
| 214 | samcoupe_update_memory(space_program); |
| 203 | 215 | } |
| 204 | 216 | |
| 205 | 217 | |
| r3703 | r3704 | |
| 243 | 255 | |
| 244 | 256 | static WRITE8_HANDLER( samcoupe_border_w ) |
| 245 | 257 | { |
| 246 | | samcoupe_regs.border = data; |
| 258 | coupe_asic *asic = space->machine->driver_data; |
| 259 | asic->border = data; |
| 247 | 260 | |
| 248 | 261 | /* DAC output state */ |
| 249 | 262 | speaker_level_w(0,(data >> 4) & 0x01); |
| r3703 | r3704 | |
| 260 | 273 | else |
| 261 | 274 | { |
| 262 | 275 | /* TODO: This actually needs to return various attributes |
| 263 | | * of the currently displayed screen data */ |
| 276 | * of the currently displayed screen data */ |
| 264 | 277 | return 0x00; |
| 265 | 278 | } |
| 266 | 279 | } |
| r3703 | r3704 | |
| 313 | 326 | |
| 314 | 327 | static TIMER_CALLBACK( irq_off ) |
| 315 | 328 | { |
| 329 | coupe_asic *asic = machine->driver_data; |
| 330 | |
| 316 | 331 | /* clear interrupt */ |
| 317 | 332 | cpu_set_input_line(machine->cpu[0], 0, CLEAR_LINE); |
| 318 | | |
| 333 | |
| 319 | 334 | /* adjust STATUS register */ |
| 320 | | samcoupe_regs.status |= param; |
| 335 | asic->status |= param; |
| 321 | 336 | } |
| 322 | 337 | |
| 323 | 338 | |
| 324 | | void samcoupe_irq(running_machine *machine, UINT8 src) |
| 339 | void samcoupe_irq(const device_config *device, UINT8 src) |
| 325 | 340 | { |
| 341 | coupe_asic *asic = device->machine->driver_data; |
| 342 | |
| 326 | 343 | /* set irq and a timer to set it off again */ |
| 327 | | cpu_set_input_line(machine->cpu[0], 0, HOLD_LINE); |
| 344 | cpu_set_input_line(device, 0, HOLD_LINE); |
| 328 | 345 | timer_set(ATTOTIME_IN_USEC(20), NULL, src, irq_off); |
| 329 | | |
| 346 | |
| 330 | 347 | /* adjust STATUS register */ |
| 331 | | samcoupe_regs.status &= ~src; |
| 348 | asic->status &= ~src; |
| 332 | 349 | } |
| 333 | 350 | |
| 334 | 351 | |
| 335 | 352 | static INTERRUPT_GEN( samcoupe_frame_interrupt ) |
| 336 | 353 | { |
| 337 | 354 | /* signal frame interrupt */ |
| 338 | | samcoupe_irq(device->machine, 0x08); |
| 355 | samcoupe_irq(device, 0x08); |
| 339 | 356 | } |
| 340 | 357 | |
| 341 | 358 | |
| r3703 | r3704 | |
| 514 | 531 | MDRV_VIDEO_ATTRIBUTES(VIDEO_UPDATE_SCANLINE) |
| 515 | 532 | |
| 516 | 533 | /* devices */ |
| 534 | MDRV_DRIVER_DATA(coupe_asic) |
| 517 | 535 | MDRV_DEVICE_ADD("sambus_clock", MSM6242) |
| 518 | 536 | |
| 519 | 537 | /* sound hardware */ |
| r3703 | r3704 | |
| 532 | 550 | * |
| 533 | 551 | *************************************/ |
| 534 | 552 | |
| 535 | | /* |
| 536 | | The bios is actually 32K. This is the combined version of the two old 16K MESS roms. |
| 537 | | It does match the 3.0 one the most, but the first half differs in one byte |
| 538 | | and in the second half, the case of the "plc" in the company string differs. |
| 553 | /* |
| 554 | The bios is actually 32K. This is the combined version of the two old 16K MESS roms. |
| 555 | It does match the 3.0 one the most, but the first half differs in one byte |
| 556 | and in the second half, the case of the "plc" in the company string differs. |
| 539 | 557 | */ |
| 540 | 558 | ROM_START( samcoupe ) |
| 541 | 559 | ROM_REGION( 0x8000, "main", 0 ) |