src/mess/machine/samcoupe.c
| r9148 | r9149 | |
| 44 | 44 | |
| 45 | 45 | static void samcoupe_install_ext_mem(address_space *space) |
| 46 | 46 | { |
| 47 | | samcoupe_state *asic = space->machine->driver_data<samcoupe_state>(); |
| 47 | samcoupe_state *state = space->machine->driver_data<samcoupe_state>(); |
| 48 | 48 | UINT8 *mem; |
| 49 | 49 | |
| 50 | 50 | /* bank 3 */ |
| 51 | | if (asic->lext >> 6 < messram_get_size(space->machine->device("messram")) >> 20) |
| 52 | | mem = &messram_get_ptr(space->machine->device("messram"))[(messram_get_size(space->machine->device("messram")) & 0xfffff) + (asic->lext >> 6) * 0x100000 + (asic->lext & 0x3f) * 0x4000]; |
| 51 | if (state->lext >> 6 < messram_get_size(space->machine->device("messram")) >> 20) |
| 52 | mem = &messram_get_ptr(space->machine->device("messram"))[(messram_get_size(space->machine->device("messram")) & 0xfffff) + (state->lext >> 6) * 0x100000 + (state->lext & 0x3f) * 0x4000]; |
| 53 | 53 | else |
| 54 | 54 | mem = NULL; |
| 55 | 55 | |
| 56 | 56 | samcoupe_update_bank(space, 3, mem, FALSE); |
| 57 | 57 | |
| 58 | 58 | /* bank 4 */ |
| 59 | | if (asic->hext >> 6 < messram_get_size(space->machine->device("messram")) >> 20) |
| 60 | | mem = &messram_get_ptr(space->machine->device("messram"))[(messram_get_size(space->machine->device("messram")) & 0xfffff) + (asic->hext >> 6) * 0x100000 + (asic->hext & 0x3f) * 0x4000]; |
| 59 | if (state->hext >> 6 < messram_get_size(space->machine->device("messram")) >> 20) |
| 60 | mem = &messram_get_ptr(space->machine->device("messram"))[(messram_get_size(space->machine->device("messram")) & 0xfffff) + (state->hext >> 6) * 0x100000 + (state->hext & 0x3f) * 0x4000]; |
| 61 | 61 | else |
| 62 | 62 | mem = NULL; |
| 63 | 63 | |
| r9148 | r9149 | |
| 68 | 68 | void samcoupe_update_memory(address_space *space) |
| 69 | 69 | { |
| 70 | 70 | samcoupe_state *state = space->machine->driver_data<samcoupe_state>(); |
| 71 | | samcoupe_state *asic = space->machine->driver_data<samcoupe_state>(); |
| 72 | 71 | const int PAGE_MASK = ((messram_get_size(space->machine->device("messram")) & 0xfffff) / 0x4000) - 1; |
| 73 | 72 | UINT8 *rom = memory_region(space->machine, "maincpu"); |
| 74 | 73 | UINT8 *memory; |
| 75 | 74 | int is_readonly; |
| 76 | 75 | |
| 77 | 76 | /* BANK1 */ |
| 78 | | if (asic->lmpr & LMPR_RAM0) /* Is ram paged in at bank 1 */ |
| 77 | if (state->lmpr & LMPR_RAM0) /* Is ram paged in at bank 1 */ |
| 79 | 78 | { |
| 80 | | if ((asic->lmpr & 0x1F) <= PAGE_MASK) |
| 81 | | memory = &messram_get_ptr(space->machine->device("messram"))[(asic->lmpr & PAGE_MASK) * 0x4000]; |
| 79 | if ((state->lmpr & 0x1F) <= PAGE_MASK) |
| 80 | memory = &messram_get_ptr(space->machine->device("messram"))[(state->lmpr & PAGE_MASK) * 0x4000]; |
| 82 | 81 | else |
| 83 | 82 | memory = NULL; /* Attempt to page in non existant ram region */ |
| 84 | 83 | is_readonly = FALSE; |
| r9148 | r9149 | |
| 92 | 91 | |
| 93 | 92 | |
| 94 | 93 | /* BANK2 */ |
| 95 | | if (((asic->lmpr + 1) & 0x1f) <= PAGE_MASK) |
| 96 | | memory = &messram_get_ptr(space->machine->device("messram"))[((asic->lmpr + 1) & PAGE_MASK) * 0x4000]; |
| 94 | if (((state->lmpr + 1) & 0x1f) <= PAGE_MASK) |
| 95 | memory = &messram_get_ptr(space->machine->device("messram"))[((state->lmpr + 1) & PAGE_MASK) * 0x4000]; |
| 97 | 96 | else |
| 98 | 97 | memory = NULL; /* Attempt to page in non existant ram region */ |
| 99 | 98 | samcoupe_update_bank(space, 2, memory, FALSE); |
| 100 | 99 | |
| 101 | 100 | /* only update bank 3 and 4 when external memory is not enabled */ |
| 102 | | if (asic->hmpr & HMPR_MCNTRL) |
| 101 | if (state->hmpr & HMPR_MCNTRL) |
| 103 | 102 | { |
| 104 | 103 | samcoupe_install_ext_mem(space); |
| 105 | 104 | } |
| 106 | 105 | else |
| 107 | 106 | { |
| 108 | 107 | /* BANK3 */ |
| 109 | | if ((asic->hmpr & 0x1F) <= PAGE_MASK ) |
| 110 | | memory = &messram_get_ptr(space->machine->device("messram"))[(asic->hmpr & PAGE_MASK)*0x4000]; |
| 108 | if ((state->hmpr & 0x1F) <= PAGE_MASK ) |
| 109 | memory = &messram_get_ptr(space->machine->device("messram"))[(state->hmpr & PAGE_MASK)*0x4000]; |
| 111 | 110 | else |
| 112 | 111 | memory = NULL; /* Attempt to page in non existant ram region */ |
| 113 | 112 | samcoupe_update_bank(space, 3, memory, FALSE); |
| 114 | 113 | |
| 115 | 114 | |
| 116 | 115 | /* BANK4 */ |
| 117 | | if (asic->lmpr & LMPR_ROM1) /* Is Rom1 paged in at bank 4 */ |
| 116 | if (state->lmpr & LMPR_ROM1) /* Is Rom1 paged in at bank 4 */ |
| 118 | 117 | { |
| 119 | 118 | memory = rom + 0x4000; |
| 120 | 119 | is_readonly = TRUE; |
| 121 | 120 | } |
| 122 | 121 | else |
| 123 | 122 | { |
| 124 | | if (((asic->hmpr + 1) & 0x1f) <= PAGE_MASK) |
| 125 | | memory = &messram_get_ptr(space->machine->device("messram"))[((asic->hmpr + 1) & PAGE_MASK) * 0x4000]; |
| 123 | if (((state->hmpr + 1) & 0x1f) <= PAGE_MASK) |
| 124 | memory = &messram_get_ptr(space->machine->device("messram"))[((state->hmpr + 1) & PAGE_MASK) * 0x4000]; |
| 126 | 125 | else |
| 127 | 126 | memory = NULL; /* Attempt to page in non existant ram region */ |
| 128 | 127 | is_readonly = FALSE; |
| r9148 | r9149 | |
| 131 | 130 | } |
| 132 | 131 | |
| 133 | 132 | /* video memory location */ |
| 134 | | if (asic->vmpr & 0x40) /* if bit set in 2 bank screen mode */ |
| 135 | | state->videoram = &messram_get_ptr(space->machine->device("messram"))[((asic->vmpr & 0x1e) & PAGE_MASK) * 0x4000]; |
| 133 | if (state->vmpr & 0x40) /* if bit set in 2 bank screen mode */ |
| 134 | state->videoram = &messram_get_ptr(space->machine->device("messram"))[((state->vmpr & 0x1e) & PAGE_MASK) * 0x4000]; |
| 136 | 135 | else |
| 137 | | state->videoram = &messram_get_ptr(space->machine->device("messram"))[((asic->vmpr & 0x1f) & PAGE_MASK) * 0x4000]; |
| 136 | state->videoram = &messram_get_ptr(space->machine->device("messram"))[((state->vmpr & 0x1f) & PAGE_MASK) * 0x4000]; |
| 138 | 137 | } |
| 139 | 138 | |
| 140 | 139 | |
| 141 | 140 | WRITE8_HANDLER( samcoupe_ext_mem_w ) |
| 142 | 141 | { |
| 142 | samcoupe_state *state = space->machine->driver_data<samcoupe_state>(); |
| 143 | 143 | address_space *space_program = cputag_get_address_space(space->machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 144 | | samcoupe_state *asic = space->machine->driver_data<samcoupe_state>(); |
| 145 | 144 | |
| 146 | 145 | if (offset & 1) |
| 147 | | asic->hext = data; |
| 146 | state->hext = data; |
| 148 | 147 | else |
| 149 | | asic->lext = data; |
| 148 | state->lext = data; |
| 150 | 149 | |
| 151 | 150 | /* external RAM enabled? */ |
| 152 | | if (asic->hmpr & HMPR_MCNTRL) |
| 151 | if (state->hmpr & HMPR_MCNTRL) |
| 153 | 152 | { |
| 154 | 153 | samcoupe_install_ext_mem(space_program); |
| 155 | 154 | } |
| r9148 | r9149 | |
| 178 | 177 | |
| 179 | 178 | static TIMER_CALLBACK( samcoupe_mouse_reset ) |
| 180 | 179 | { |
| 181 | | samcoupe_state *asic = machine->driver_data<samcoupe_state>(); |
| 182 | | asic->mouse_index = 0; |
| 180 | samcoupe_state *state = machine->driver_data<samcoupe_state>(); |
| 181 | state->mouse_index = 0; |
| 183 | 182 | } |
| 184 | 183 | |
| 185 | 184 | UINT8 samcoupe_mouse_r(running_machine *machine) |
| 186 | 185 | { |
| 187 | | samcoupe_state *asic = machine->driver_data<samcoupe_state>(); |
| 186 | samcoupe_state *state = machine->driver_data<samcoupe_state>(); |
| 188 | 187 | UINT8 result; |
| 189 | 188 | |
| 190 | 189 | /* on a read, reset the timer */ |
| 191 | | timer_adjust_oneshot(asic->mouse_reset, ATTOTIME_IN_USEC(50), 0); |
| 190 | timer_adjust_oneshot(state->mouse_reset, ATTOTIME_IN_USEC(50), 0); |
| 192 | 191 | |
| 193 | 192 | /* update when we are about to read the first real values */ |
| 194 | | if (asic->mouse_index == 2) |
| 193 | if (state->mouse_index == 2) |
| 195 | 194 | { |
| 196 | 195 | /* update values */ |
| 197 | 196 | int mouse_x = input_port_read(machine, "mouse_x"); |
| 198 | 197 | int mouse_y = input_port_read(machine, "mouse_y"); |
| 199 | 198 | |
| 200 | | int mouse_dx = asic->mouse_x - mouse_x; |
| 201 | | int mouse_dy = asic->mouse_y - mouse_y; |
| 199 | int mouse_dx = state->mouse_x - mouse_x; |
| 200 | int mouse_dy = state->mouse_y - mouse_y; |
| 202 | 201 | |
| 203 | | asic->mouse_x = mouse_x; |
| 204 | | asic->mouse_y = mouse_y; |
| 202 | state->mouse_x = mouse_x; |
| 203 | state->mouse_y = mouse_y; |
| 205 | 204 | |
| 206 | 205 | /* button state */ |
| 207 | | asic->mouse_data[2] = input_port_read(machine, "mouse_buttons"); |
| 206 | state->mouse_data[2] = input_port_read(machine, "mouse_buttons"); |
| 208 | 207 | |
| 209 | 208 | /* y-axis */ |
| 210 | | asic->mouse_data[3] = (mouse_dy & 0xf00) >> 8; |
| 211 | | asic->mouse_data[4] = (mouse_dy & 0x0f0) >> 4; |
| 212 | | asic->mouse_data[5] = (mouse_dy & 0x00f) >> 0; |
| 209 | state->mouse_data[3] = (mouse_dy & 0xf00) >> 8; |
| 210 | state->mouse_data[4] = (mouse_dy & 0x0f0) >> 4; |
| 211 | state->mouse_data[5] = (mouse_dy & 0x00f) >> 0; |
| 213 | 212 | |
| 214 | 213 | /* x-axis */ |
| 215 | | asic->mouse_data[6] = (mouse_dx & 0xf00) >> 8; |
| 216 | | asic->mouse_data[7] = (mouse_dx & 0x0f0) >> 4; |
| 217 | | asic->mouse_data[8] = (mouse_dx & 0x00f) >> 0; |
| 214 | state->mouse_data[6] = (mouse_dx & 0xf00) >> 8; |
| 215 | state->mouse_data[7] = (mouse_dx & 0x0f0) >> 4; |
| 216 | state->mouse_data[8] = (mouse_dx & 0x00f) >> 0; |
| 218 | 217 | } |
| 219 | 218 | |
| 220 | 219 | /* get current value */ |
| 221 | | result = asic->mouse_data[asic->mouse_index++]; |
| 220 | result = state->mouse_data[state->mouse_index++]; |
| 222 | 221 | |
| 223 | 222 | /* reset if we are at the end */ |
| 224 | | if (asic->mouse_index == sizeof(asic->mouse_data)) |
| 225 | | asic->mouse_index = 1; |
| 223 | if (state->mouse_index == sizeof(state->mouse_data)) |
| 224 | state->mouse_index = 1; |
| 226 | 225 | |
| 227 | 226 | return result; |
| 228 | 227 | } |
| 229 | 228 | |
| 230 | 229 | MACHINE_START( samcoupe ) |
| 231 | 230 | { |
| 232 | | samcoupe_state *asic = machine->driver_data<samcoupe_state>(); |
| 233 | | asic->mouse_reset = timer_alloc(machine, samcoupe_mouse_reset, 0); |
| 231 | samcoupe_state *state = machine->driver_data<samcoupe_state>(); |
| 232 | state->mouse_reset = timer_alloc(machine, samcoupe_mouse_reset, 0); |
| 234 | 233 | |
| 235 | 234 | /* schedule our video updates */ |
| 236 | | asic->video_update_timer = timer_alloc(machine, sam_video_update_callback, NULL); |
| 237 | | timer_adjust_oneshot(asic->video_update_timer, machine->primary_screen->time_until_pos(0, 0), 0); |
| 235 | state->video_update_timer = timer_alloc(machine, sam_video_update_callback, NULL); |
| 236 | timer_adjust_oneshot(state->video_update_timer, machine->primary_screen->time_until_pos(0, 0), 0); |
| 238 | 237 | } |
| 239 | 238 | |
| 240 | 239 | /*************************************************************************** |
| r9148 | r9149 | |
| 245 | 244 | { |
| 246 | 245 | address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 247 | 246 | address_space *spaceio = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_IO); |
| 248 | | samcoupe_state *asic = machine->driver_data<samcoupe_state>(); |
| 247 | samcoupe_state *state = machine->driver_data<samcoupe_state>(); |
| 249 | 248 | |
| 250 | | /* initialize asic */ |
| 251 | | asic->lmpr = 0x0f; /* ROM0 paged in, ROM1 paged out RAM Banks */ |
| 252 | | asic->hmpr = 0x01; |
| 253 | | asic->vmpr = 0x81; |
| 254 | | asic->line_int = 0xff; /* line interrupts disabled */ |
| 255 | | asic->status = 0x1f; /* no interrupts active */ |
| 249 | /* initialize state */ |
| 250 | state->lmpr = 0x0f; /* ROM0 paged in, ROM1 paged out RAM Banks */ |
| 251 | state->hmpr = 0x01; |
| 252 | state->vmpr = 0x81; |
| 253 | state->line_int = 0xff; /* line interrupts disabled */ |
| 254 | state->status = 0x1f; /* no interrupts active */ |
| 256 | 255 | |
| 257 | 256 | /* initialize mouse */ |
| 258 | | asic->mouse_index = 0; |
| 259 | | asic->mouse_data[0] = 0xff; |
| 260 | | asic->mouse_data[1] = 0xff; |
| 257 | state->mouse_index = 0; |
| 258 | state->mouse_data[0] = 0xff; |
| 259 | state->mouse_data[1] = 0xff; |
| 261 | 260 | |
| 262 | 261 | if (input_port_read(machine, "config") & 0x01) |
| 263 | 262 | { |
src/mess/video/samcoupe.c
| r9148 | r9149 | |
| 30 | 30 | { |
| 31 | 31 | samcoupe_state *state = machine->driver_data<samcoupe_state>(); |
| 32 | 32 | UINT8 *videoram = state->videoram; |
| 33 | | samcoupe_state *asic = machine->driver_data<samcoupe_state>(); |
| 34 | 33 | |
| 35 | 34 | /* get start address */ |
| 36 | 35 | UINT8 *vram = videoram + ((y - SAM_BORDER_TOP) * 128) + ((hpos - SAM_BORDER_LEFT) / 4); |
| r9148 | r9149 | |
| 38 | 37 | for (int i = 0; i < (SAM_BLOCK*2)/4; i++) |
| 39 | 38 | { |
| 40 | 39 | /* draw 2 pixels (doublewidth) */ |
| 41 | | *BITMAP_ADDR16(machine->generic.tmpbitmap, y, hpos + i * 4 + 0) = asic->clut[(*vram >> 4) & 0x0f]; |
| 42 | | *BITMAP_ADDR16(machine->generic.tmpbitmap, y, hpos + i * 4 + 1) = asic->clut[(*vram >> 4) & 0x0f]; |
| 43 | | *BITMAP_ADDR16(machine->generic.tmpbitmap, y, hpos + i * 4 + 2) = asic->clut[(*vram >> 0) & 0x0f]; |
| 44 | | *BITMAP_ADDR16(machine->generic.tmpbitmap, y, hpos + i * 4 + 3) = asic->clut[(*vram >> 0) & 0x0f]; |
| 40 | *BITMAP_ADDR16(machine->generic.tmpbitmap, y, hpos + i * 4 + 0) = state->clut[(*vram >> 4) & 0x0f]; |
| 41 | *BITMAP_ADDR16(machine->generic.tmpbitmap, y, hpos + i * 4 + 1) = state->clut[(*vram >> 4) & 0x0f]; |
| 42 | *BITMAP_ADDR16(machine->generic.tmpbitmap, y, hpos + i * 4 + 2) = state->clut[(*vram >> 0) & 0x0f]; |
| 43 | *BITMAP_ADDR16(machine->generic.tmpbitmap, y, hpos + i * 4 + 3) = state->clut[(*vram >> 0) & 0x0f]; |
| 45 | 44 | |
| 46 | 45 | /* move to next address */ |
| 47 | 46 | vram++; |
| 48 | 47 | |
| 49 | 48 | /* attribute register contains the third displayed byte */ |
| 50 | 49 | if (i == 2) |
| 51 | | asic->attribute = *vram; |
| 50 | state->attribute = *vram; |
| 52 | 51 | } |
| 53 | 52 | } |
| 54 | 53 | |
| r9148 | r9149 | |
| 56 | 55 | { |
| 57 | 56 | samcoupe_state *state = machine->driver_data<samcoupe_state>(); |
| 58 | 57 | UINT8 *videoram = state->videoram; |
| 59 | | samcoupe_state *asic = machine->driver_data<samcoupe_state>(); |
| 60 | 58 | |
| 61 | 59 | /* get start address */ |
| 62 | 60 | UINT8 *vram = videoram + ((y - SAM_BORDER_TOP) * 128) + ((hpos - SAM_BORDER_LEFT) / 4); |
| r9148 | r9149 | |
| 64 | 62 | for (int i = 0; i < (SAM_BLOCK*2)/4; i++) |
| 65 | 63 | { |
| 66 | 64 | /* draw 4 pixels */ |
| 67 | | *BITMAP_ADDR16(machine->generic.tmpbitmap, y, hpos + i * 4 + 0) = asic->clut[(*vram >> 6) & 0x03]; |
| 68 | | *BITMAP_ADDR16(machine->generic.tmpbitmap, y, hpos + i * 4 + 1) = asic->clut[(*vram >> 4) & 0x03]; |
| 69 | | *BITMAP_ADDR16(machine->generic.tmpbitmap, y, hpos + i * 4 + 2) = asic->clut[(*vram >> 2) & 0x03]; |
| 70 | | *BITMAP_ADDR16(machine->generic.tmpbitmap, y, hpos + i * 4 + 3) = asic->clut[(*vram >> 0) & 0x03]; |
| 65 | *BITMAP_ADDR16(machine->generic.tmpbitmap, y, hpos + i * 4 + 0) = state->clut[(*vram >> 6) & 0x03]; |
| 66 | *BITMAP_ADDR16(machine->generic.tmpbitmap, y, hpos + i * 4 + 1) = state->clut[(*vram >> 4) & 0x03]; |
| 67 | *BITMAP_ADDR16(machine->generic.tmpbitmap, y, hpos + i * 4 + 2) = state->clut[(*vram >> 2) & 0x03]; |
| 68 | *BITMAP_ADDR16(machine->generic.tmpbitmap, y, hpos + i * 4 + 3) = state->clut[(*vram >> 0) & 0x03]; |
| 71 | 69 | |
| 72 | 70 | /* move to next address */ |
| 73 | 71 | vram++; |
| 74 | 72 | |
| 75 | 73 | /* attribute register contains the third displayed byte */ |
| 76 | 74 | if (i == 2) |
| 77 | | asic->attribute = *vram; |
| 75 | state->attribute = *vram; |
| 78 | 76 | } |
| 79 | 77 | } |
| 80 | 78 | |
| 81 | | static void draw_mode12_block(samcoupe_state *asic, bitmap_t *bitmap, int vpos, int hpos, UINT8 mask) |
| 79 | static void draw_mode12_block(samcoupe_state *state, bitmap_t *bitmap, int vpos, int hpos, UINT8 mask) |
| 82 | 80 | { |
| 83 | 81 | /* extract colors from attribute */ |
| 84 | | UINT8 ink = asic->clut[ATTR_FG(asic->attribute)]; |
| 85 | | UINT8 pap = asic->clut[ATTR_BG(asic->attribute)]; |
| 82 | UINT8 ink = state->clut[ATTR_FG(state->attribute)]; |
| 83 | UINT8 pap = state->clut[ATTR_BG(state->attribute)]; |
| 86 | 84 | |
| 87 | 85 | /* draw block of 8 pixels (doubled to 16) */ |
| 88 | 86 | for (int i = 0; i < SAM_BLOCK; i++) |
| r9148 | r9149 | |
| 96 | 94 | { |
| 97 | 95 | samcoupe_state *state = machine->driver_data<samcoupe_state>(); |
| 98 | 96 | UINT8 *videoram = state->videoram; |
| 99 | | samcoupe_state *asic = machine->driver_data<samcoupe_state>(); |
| 100 | 97 | |
| 101 | 98 | int cell = (y - SAM_BORDER_TOP) * 32 + (hpos - SAM_BORDER_LEFT) / SAM_BLOCK / 2; |
| 102 | 99 | |
| 103 | 100 | UINT8 mask = videoram[cell]; |
| 104 | | asic->attribute = videoram[cell + 0x2000]; |
| 101 | state->attribute = videoram[cell + 0x2000]; |
| 105 | 102 | |
| 106 | | draw_mode12_block(asic, machine->generic.tmpbitmap, y, hpos, mask); |
| 103 | draw_mode12_block(state, machine->generic.tmpbitmap, y, hpos, mask); |
| 107 | 104 | } |
| 108 | 105 | |
| 109 | 106 | static void draw_mode1_line(running_machine *machine, int y, int hpos) |
| 110 | 107 | { |
| 111 | 108 | samcoupe_state *state = machine->driver_data<samcoupe_state>(); |
| 112 | 109 | UINT8 *videoram = state->videoram; |
| 113 | | samcoupe_state *asic = machine->driver_data<samcoupe_state>(); |
| 114 | 110 | |
| 115 | 111 | UINT8 mask = videoram[((((y - SAM_BORDER_TOP) & 0xc0) << 5) | (((y - SAM_BORDER_TOP) & 0x07) << 8) | (((y - SAM_BORDER_TOP) & 0x38) << 2)) + (hpos - SAM_BORDER_LEFT) / SAM_BLOCK / 2]; |
| 116 | | asic->attribute = videoram[32*192 + (((y - SAM_BORDER_TOP) & 0xf8) << 2) + (hpos - SAM_BORDER_LEFT) / SAM_BLOCK / 2]; |
| 112 | state->attribute = videoram[32*192 + (((y - SAM_BORDER_TOP) & 0xf8) << 2) + (hpos - SAM_BORDER_LEFT) / SAM_BLOCK / 2]; |
| 117 | 113 | |
| 118 | | draw_mode12_block(asic, machine->generic.tmpbitmap, y, hpos, mask); |
| 114 | draw_mode12_block(state, machine->generic.tmpbitmap, y, hpos, mask); |
| 119 | 115 | } |
| 120 | 116 | |
| 121 | 117 | TIMER_CALLBACK( sam_video_update_callback ) |
| 122 | 118 | { |
| 123 | | samcoupe_state *asic = machine->driver_data<samcoupe_state>(); |
| 124 | | |
| 119 | samcoupe_state *state = machine->driver_data<samcoupe_state>(); |
| 125 | 120 | int vpos = machine->primary_screen->vpos(); |
| 126 | 121 | int hpos = machine->primary_screen->hpos(); |
| 127 | 122 | |
| r9148 | r9149 | |
| 136 | 131 | } |
| 137 | 132 | |
| 138 | 133 | /* display disabled? (only in mode 3 or 4) */ |
| 139 | | if (BIT(asic->vmpr, 6) && BIT(asic->border, 7)) |
| 134 | if (BIT(state->vmpr, 6) && BIT(state->border, 7)) |
| 140 | 135 | { |
| 141 | 136 | plot_box(machine->generic.tmpbitmap, hpos, vpos, SAM_BLOCK*2, 1, 0); |
| 142 | 137 | } |
| r9148 | r9149 | |
| 145 | 140 | /* border area? */ |
| 146 | 141 | if (vpos < SAM_BORDER_TOP || vpos >= SAM_BORDER_TOP + SAM_SCREEN_HEIGHT || hpos < SAM_BORDER_LEFT || hpos >= SAM_BORDER_LEFT + SAM_SCREEN_WIDTH) |
| 147 | 142 | { |
| 148 | | asic->attribute = 0xff; |
| 149 | | plot_box(machine->generic.tmpbitmap, hpos, vpos, SAM_BLOCK*2, 1, asic->clut[BORDER_COLOR(asic->border)]); |
| 143 | state->attribute = 0xff; |
| 144 | plot_box(machine->generic.tmpbitmap, hpos, vpos, SAM_BLOCK*2, 1, state->clut[BORDER_COLOR(state->border)]); |
| 150 | 145 | } |
| 151 | 146 | else |
| 152 | 147 | { |
| 153 | 148 | /* main screen area */ |
| 154 | | switch ((asic->vmpr & 0x60) >> 5) |
| 149 | switch ((state->vmpr & 0x60) >> 5) |
| 155 | 150 | { |
| 156 | 151 | case 0: draw_mode1_line(machine, vpos, hpos); break; |
| 157 | 152 | case 1: draw_mode2_line(machine, vpos, hpos); break; |
| r9148 | r9149 | |
| 162 | 157 | } |
| 163 | 158 | |
| 164 | 159 | /* do we need to trigger the scanline interrupt (interrupt happens at the start of the right border before the specified line)? */ |
| 165 | | if (asic->line_int < SAM_SCREEN_HEIGHT && hpos == SAM_BORDER_LEFT + SAM_SCREEN_WIDTH && vpos == (asic->line_int + SAM_BORDER_TOP - 1)) |
| 160 | if (state->line_int < SAM_SCREEN_HEIGHT && hpos == SAM_BORDER_LEFT + SAM_SCREEN_WIDTH && vpos == (state->line_int + SAM_BORDER_TOP - 1)) |
| 166 | 161 | samcoupe_irq(machine->firstcpu, SAM_LINE_INT); |
| 167 | 162 | |
| 168 | 163 | /* schedule next update */ |
| 169 | | timer_adjust_oneshot(asic->video_update_timer, machine->primary_screen->time_until_pos(next_vpos, next_hpos), 0); |
| 164 | timer_adjust_oneshot(state->video_update_timer, machine->primary_screen->time_until_pos(next_vpos, next_hpos), 0); |
| 170 | 165 | } |
src/mess/drivers/samcoupe.c
| r9148 | r9149 | |
| 123 | 123 | |
| 124 | 124 | static WRITE8_HANDLER( samcoupe_clut_w ) |
| 125 | 125 | { |
| 126 | | samcoupe_state *asic = space->machine->driver_data<samcoupe_state>(); |
| 127 | | asic->clut[(offset >> 8) & 0x0f] = data & 0x7f; |
| 126 | samcoupe_state *state = space->machine->driver_data<samcoupe_state>(); |
| 127 | state->clut[(offset >> 8) & 0x0f] = data & 0x7f; |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | static READ8_HANDLER( samcoupe_status_r ) |
| 131 | 131 | { |
| 132 | | samcoupe_state *asic = space->machine->driver_data<samcoupe_state>(); |
| 132 | samcoupe_state *state = space->machine->driver_data<samcoupe_state>(); |
| 133 | 133 | UINT8 data = 0xe0; |
| 134 | 134 | |
| 135 | 135 | /* bit 5-7, keyboard input */ |
| r9148 | r9149 | |
| 143 | 143 | if (!BIT(offset, 15)) data &= input_port_read(space->machine, "keyboard_row_7f") & 0xe0; |
| 144 | 144 | |
| 145 | 145 | /* bit 0-4, interrupt source */ |
| 146 | | data |= asic->status; |
| 146 | data |= state->status; |
| 147 | 147 | |
| 148 | 148 | return data; |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | static WRITE8_HANDLER( samcoupe_line_int_w ) |
| 152 | 152 | { |
| 153 | | samcoupe_state *asic = space->machine->driver_data<samcoupe_state>(); |
| 154 | | asic->line_int = data; |
| 153 | samcoupe_state *state = space->machine->driver_data<samcoupe_state>(); |
| 154 | state->line_int = data; |
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | static READ8_HANDLER( samcoupe_lmpr_r ) |
| 158 | 158 | { |
| 159 | | samcoupe_state *asic = space->machine->driver_data<samcoupe_state>(); |
| 160 | | return asic->lmpr; |
| 159 | samcoupe_state *state = space->machine->driver_data<samcoupe_state>(); |
| 160 | return state->lmpr; |
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | static WRITE8_HANDLER( samcoupe_lmpr_w ) |
| 164 | 164 | { |
| 165 | 165 | address_space *space_program = cputag_get_address_space(space->machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 166 | | samcoupe_state *asic = space->machine->driver_data<samcoupe_state>(); |
| 166 | samcoupe_state *state = space->machine->driver_data<samcoupe_state>(); |
| 167 | 167 | |
| 168 | | asic->lmpr = data; |
| 168 | state->lmpr = data; |
| 169 | 169 | samcoupe_update_memory(space_program); |
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | static READ8_HANDLER( samcoupe_hmpr_r ) |
| 173 | 173 | { |
| 174 | | samcoupe_state *asic = space->machine->driver_data<samcoupe_state>(); |
| 175 | | return asic->hmpr; |
| 174 | samcoupe_state *state = space->machine->driver_data<samcoupe_state>(); |
| 175 | return state->hmpr; |
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | static WRITE8_HANDLER( samcoupe_hmpr_w ) |
| 179 | 179 | { |
| 180 | 180 | address_space *space_program = cputag_get_address_space(space->machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 181 | | samcoupe_state *asic = space->machine->driver_data<samcoupe_state>(); |
| 181 | samcoupe_state *state = space->machine->driver_data<samcoupe_state>(); |
| 182 | 182 | |
| 183 | | asic->hmpr = data; |
| 183 | state->hmpr = data; |
| 184 | 184 | samcoupe_update_memory(space_program); |
| 185 | 185 | } |
| 186 | 186 | |
| 187 | 187 | static READ8_HANDLER( samcoupe_vmpr_r ) |
| 188 | 188 | { |
| 189 | | samcoupe_state *asic = space->machine->driver_data<samcoupe_state>(); |
| 190 | | return asic->vmpr; |
| 189 | samcoupe_state *state = space->machine->driver_data<samcoupe_state>(); |
| 190 | return state->vmpr; |
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | static WRITE8_HANDLER( samcoupe_vmpr_w ) |
| 194 | 194 | { |
| 195 | 195 | address_space *space_program = cputag_get_address_space(space->machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 196 | | samcoupe_state *asic = space->machine->driver_data<samcoupe_state>(); |
| 196 | samcoupe_state *state = space->machine->driver_data<samcoupe_state>(); |
| 197 | 197 | |
| 198 | | asic->vmpr = data; |
| 198 | state->vmpr = data; |
| 199 | 199 | samcoupe_update_memory(space_program); |
| 200 | 200 | } |
| 201 | 201 | |
| r9148 | r9149 | |
| 250 | 250 | { |
| 251 | 251 | running_device *cassette = space->machine->device("cassette"); |
| 252 | 252 | running_device *speaker = space->machine->device("speaker"); |
| 253 | | samcoupe_state *asic = space->machine->driver_data<samcoupe_state>(); |
| 253 | samcoupe_state *state = space->machine->driver_data<samcoupe_state>(); |
| 254 | 254 | |
| 255 | | asic->border = data; |
| 255 | state->border = data; |
| 256 | 256 | |
| 257 | 257 | /* bit 3, cassette output */ |
| 258 | 258 | cassette_output(cassette, BIT(data, 3) ? -1.0 : +1.0); |
| r9148 | r9149 | |
| 263 | 263 | |
| 264 | 264 | static READ8_HANDLER( samcoupe_attributes_r ) |
| 265 | 265 | { |
| 266 | | samcoupe_state *asic = space->machine->driver_data<samcoupe_state>(); |
| 267 | | return asic->attribute; |
| 266 | samcoupe_state *state = space->machine->driver_data<samcoupe_state>(); |
| 267 | return state->attribute; |
| 268 | 268 | } |
| 269 | 269 | |
| 270 | 270 | static READ8_DEVICE_HANDLER( samcoupe_lpt1_busy_r ) |
| r9148 | r9149 | |
| 325 | 325 | |
| 326 | 326 | static TIMER_CALLBACK( irq_off ) |
| 327 | 327 | { |
| 328 | | samcoupe_state *asic = machine->driver_data<samcoupe_state>(); |
| 329 | | |
| 328 | samcoupe_state *state = machine->driver_data<samcoupe_state>(); |
| 330 | 329 | /* adjust STATUS register */ |
| 331 | | asic->status |= param; |
| 330 | state->status |= param; |
| 332 | 331 | |
| 333 | 332 | /* clear interrupt */ |
| 334 | | if ((asic->status & 0x1f) == 0x1f) |
| 333 | if ((state->status & 0x1f) == 0x1f) |
| 335 | 334 | cputag_set_input_line(machine, "maincpu", 0, CLEAR_LINE); |
| 336 | 335 | |
| 337 | 336 | } |
| 338 | 337 | |
| 339 | 338 | void samcoupe_irq(running_device *device, UINT8 src) |
| 340 | 339 | { |
| 341 | | samcoupe_state *asic = device->machine->driver_data<samcoupe_state>(); |
| 340 | samcoupe_state *state = device->machine->driver_data<samcoupe_state>(); |
| 342 | 341 | |
| 343 | 342 | /* assert irq and a timer to set it off again */ |
| 344 | 343 | cpu_set_input_line(device, 0, ASSERT_LINE); |
| 345 | 344 | timer_set(device->machine, ATTOTIME_IN_USEC(20), NULL, src, irq_off); |
| 346 | 345 | |
| 347 | 346 | /* adjust STATUS register */ |
| 348 | | asic->status &= ~src; |
| 347 | state->status &= ~src; |
| 349 | 348 | } |
| 350 | 349 | |
| 351 | 350 | static INTERRUPT_GEN( samcoupe_frame_interrupt ) |