src/mess/machine/adam.c
| r9648 | r9649 | |
| 12 | 12 | #include "devices/flopdrv.h" |
| 13 | 13 | #include "devices/cartslot.h" |
| 14 | 14 | |
| 15 | | int adam_lower_memory; /* Lower 32k memory Z80 address configuration */ |
| 16 | | int adam_upper_memory; /* Upper 32k memory Z80 address configuration */ |
| 17 | | int adam_joy_stat[2]; |
| 18 | | int adam_net_data; /* Data on AdamNet Bus */ |
| 19 | | int adam_pcb; |
| 20 | 15 | |
| 21 | | static int joy_mode = 0; |
| 22 | 16 | |
| 23 | 17 | /* TODO: Are these digits correct? */ |
| 24 | | static int KeyboardBuffer[20]; /* Buffer to store keys pressed */ |
| 25 | 18 | static const int KbBufferCapacity = 15; /* Capacity of the Keyboard Buffer */ |
| 26 | 19 | static const int KbRepeatDelay = 20; |
| 27 | 20 | |
| 28 | | static UINT8 KbRepeatTable[256]; |
| 29 | 21 | |
| 30 | 22 | #ifdef UNUSED_FUNCTION |
| 31 | 23 | int adam_cart_verify(const UINT8 *cartdata, size_t size) |
| r9648 | r9649 | |
| 42 | 34 | } |
| 43 | 35 | #endif |
| 44 | 36 | |
| 45 | | void adam_clear_keyboard_buffer(void) |
| 37 | void adam_clear_keyboard_buffer(running_machine *machine) |
| 46 | 38 | { |
| 39 | adam_state *state = machine->driver_data<adam_state>(); |
| 47 | 40 | int i; |
| 48 | 41 | |
| 49 | | KeyboardBuffer[0] = 0; /* Keys on current buffer */ |
| 42 | state->KeyboardBuffer[0] = 0; /* Keys on current buffer */ |
| 50 | 43 | for(i=1;i<KbBufferCapacity;i++) |
| 51 | 44 | { |
| 52 | | KeyboardBuffer[i] = 0; /* Key pressed */ |
| 45 | state->KeyboardBuffer[i] = 0; /* Key pressed */ |
| 53 | 46 | } |
| 54 | 47 | for(i=0;i<255;i++) |
| 55 | 48 | { |
| 56 | | KbRepeatTable[i]=0; /* Clear Key Repeat Table */ |
| 49 | state->KbRepeatTable[i]=0; /* Clear Key Repeat Table */ |
| 57 | 50 | } |
| 58 | 51 | |
| 59 | 52 | } |
| 60 | 53 | |
| 61 | | static unsigned char getKeyFromBuffer(void) |
| 54 | static unsigned char getKeyFromBuffer(adam_state *state) |
| 62 | 55 | { |
| 63 | 56 | int i; |
| 64 | 57 | UINT8 kbcode; |
| 65 | 58 | |
| 66 | | kbcode=KeyboardBuffer[1]; |
| 67 | | for(i=1;i<KeyboardBuffer[0];i++) |
| 59 | kbcode=state->KeyboardBuffer[1]; |
| 60 | for(i=1;i<state->KeyboardBuffer[0];i++) |
| 68 | 61 | { |
| 69 | | KeyboardBuffer[i]=KeyboardBuffer[i+1]; |
| 62 | state->KeyboardBuffer[i]=state->KeyboardBuffer[i+1]; |
| 70 | 63 | } |
| 71 | | KeyboardBuffer[KeyboardBuffer[0]]=0; |
| 72 | | if (KeyboardBuffer[0]>0) KeyboardBuffer[0]--; |
| 64 | state->KeyboardBuffer[state->KeyboardBuffer[0]]=0; |
| 65 | if (state->KeyboardBuffer[0]>0) state->KeyboardBuffer[0]--; |
| 73 | 66 | return kbcode; |
| 74 | 67 | } |
| 75 | 68 | |
| 76 | | static void addToKeyboardBuffer(unsigned char kbcode) |
| 69 | static void addToKeyboardBuffer(adam_state *state, unsigned char kbcode) |
| 77 | 70 | { |
| 78 | | if (KbRepeatTable[kbcode]==0) |
| 71 | if (state->KbRepeatTable[kbcode]==0) |
| 79 | 72 | { |
| 80 | | if ((KeyboardBuffer[0] < KbBufferCapacity)) |
| 73 | if ((state->KeyboardBuffer[0] < KbBufferCapacity)) |
| 81 | 74 | { |
| 82 | | KeyboardBuffer[0]++; |
| 83 | | KeyboardBuffer[KeyboardBuffer[0]] = kbcode; |
| 84 | | KbRepeatTable[kbcode]=255-KbRepeatDelay; |
| 75 | state->KeyboardBuffer[0]++; |
| 76 | state->KeyboardBuffer[state->KeyboardBuffer[0]] = kbcode; |
| 77 | state->KbRepeatTable[kbcode]=255-KbRepeatDelay; |
| 85 | 78 | } |
| 86 | 79 | } |
| 87 | 80 | } |
| 88 | 81 | |
| 89 | 82 | void adam_explore_keyboard(running_machine *machine) |
| 90 | 83 | { |
| 84 | adam_state *state = machine->driver_data<adam_state>(); |
| 91 | 85 | int controlKey, shiftKey; |
| 92 | 86 | int i, keyboard[10]; |
| 93 | 87 | |
| 94 | 88 | //logerror("Exploring Keyboard.............\n"); |
| 95 | | for(i=0;i<=255;i++) {if (KbRepeatTable[i]>0) KbRepeatTable[i]++;} /* Update repeat table */ |
| 89 | for(i=0;i<=255;i++) {if (state->KbRepeatTable[i]>0) state->KbRepeatTable[i]++;} /* Update repeat table */ |
| 96 | 90 | |
| 97 | 91 | keyboard[0] = input_port_read(machine, "keyboard_1"); |
| 98 | 92 | keyboard[1] = input_port_read(machine, "keyboard_2"); |
| r9648 | r9649 | |
| 110 | 104 | controlKey = !(keyboard[9]&0x01); /* Control */ |
| 111 | 105 | shiftKey = (!(keyboard[8]&0x40) || !(keyboard[8]&0x80) || !(keyboard[9]&0x04)); /* Left shiftKey or Right shiftKey or Lock */ |
| 112 | 106 | |
| 113 | | if (controlKey && !shiftKey && !(keyboard[4] & 0x04)) addToKeyboardBuffer(0x00); /* controlKey + 2 */ |
| 114 | | else {KbRepeatTable[0x00]=0;} |
| 115 | | if (controlKey && !shiftKey && !(keyboard[0] & 0x02)) addToKeyboardBuffer(0x01); /* controlKey + A */ |
| 116 | | else {KbRepeatTable[0x01]=0;} |
| 117 | | if (controlKey && !shiftKey && !(keyboard[0] & 0x04)) addToKeyboardBuffer(0x02); /* controlKey + B */ |
| 118 | | else {KbRepeatTable[0x02]=0;} |
| 119 | | if (controlKey && !shiftKey && !(keyboard[0] & 0x08)) addToKeyboardBuffer(0x03); /* controlKey + C */ |
| 120 | | else {KbRepeatTable[0x03]=0;} |
| 121 | | if (controlKey && !shiftKey && !(keyboard[0] & 0x10)) addToKeyboardBuffer(0x04); /* controlKey + D */ |
| 122 | | else {KbRepeatTable[0x04]=0;} |
| 123 | | if (controlKey && !shiftKey && !(keyboard[0] & 0x20)) addToKeyboardBuffer(0x05); /* controlKey + E */ |
| 124 | | else {KbRepeatTable[0x05]=0;} |
| 125 | | if (controlKey && !shiftKey && !(keyboard[0] & 0x40)) addToKeyboardBuffer(0x06); /* controlKey + F */ |
| 126 | | else {KbRepeatTable[0x06]=0;} |
| 127 | | if (controlKey && !shiftKey && !(keyboard[0] & 0x80)) addToKeyboardBuffer(0x07); /* controlKey + G */ |
| 128 | | else {KbRepeatTable[0x07]=0;} |
| 107 | if (controlKey && !shiftKey && !(keyboard[4] & 0x04)) addToKeyboardBuffer(state, 0x00); /* controlKey + 2 */ |
| 108 | else {state->KbRepeatTable[0x00]=0;} |
| 109 | if (controlKey && !shiftKey && !(keyboard[0] & 0x02)) addToKeyboardBuffer(state, 0x01); /* controlKey + A */ |
| 110 | else {state->KbRepeatTable[0x01]=0;} |
| 111 | if (controlKey && !shiftKey && !(keyboard[0] & 0x04)) addToKeyboardBuffer(state, 0x02); /* controlKey + B */ |
| 112 | else {state->KbRepeatTable[0x02]=0;} |
| 113 | if (controlKey && !shiftKey && !(keyboard[0] & 0x08)) addToKeyboardBuffer(state, 0x03); /* controlKey + C */ |
| 114 | else {state->KbRepeatTable[0x03]=0;} |
| 115 | if (controlKey && !shiftKey && !(keyboard[0] & 0x10)) addToKeyboardBuffer(state, 0x04); /* controlKey + D */ |
| 116 | else {state->KbRepeatTable[0x04]=0;} |
| 117 | if (controlKey && !shiftKey && !(keyboard[0] & 0x20)) addToKeyboardBuffer(state, 0x05); /* controlKey + E */ |
| 118 | else {state->KbRepeatTable[0x05]=0;} |
| 119 | if (controlKey && !shiftKey && !(keyboard[0] & 0x40)) addToKeyboardBuffer(state, 0x06); /* controlKey + F */ |
| 120 | else {state->KbRepeatTable[0x06]=0;} |
| 121 | if (controlKey && !shiftKey && !(keyboard[0] & 0x80)) addToKeyboardBuffer(state, 0x07); /* controlKey + G */ |
| 122 | else {state->KbRepeatTable[0x07]=0;} |
| 129 | 123 | |
| 130 | | if ((controlKey && !shiftKey && !(keyboard[1] & 0x01)) || !(keyboard[9] & 0x02)) addToKeyboardBuffer(0x08); /* controlKey + H or BACKSPACE */ |
| 131 | | else {KbRepeatTable[0x08]=0;} |
| 132 | | if ((controlKey && !shiftKey && !(keyboard[1] & 0x02)) || !(keyboard[8] & 0x20)) addToKeyboardBuffer(0x09); /* controlKey + I or TAB */ |
| 133 | | else {KbRepeatTable[0x09]=0;} |
| 134 | | if (controlKey && !shiftKey && !(keyboard[1] & 0x04)) addToKeyboardBuffer(0x0A); /* controlKey + J */ |
| 135 | | else {KbRepeatTable[0x0A]=0;} |
| 136 | | if (controlKey && !shiftKey && !(keyboard[1] & 0x08)) addToKeyboardBuffer(0x0B); /* controlKey + K */ |
| 137 | | else {KbRepeatTable[0x0B]=0;} |
| 138 | | if (controlKey && !shiftKey && !(keyboard[1] & 0x10)) addToKeyboardBuffer(0x0C); /* controlKey + L */ |
| 139 | | else {KbRepeatTable[0x0C]=0;} |
| 140 | | if ((controlKey && !shiftKey && !(keyboard[1] & 0x20)) || !(keyboard[6] & 0x80)) addToKeyboardBuffer(0x0D); /* controlKey + M or RETURN */ |
| 141 | | else {KbRepeatTable[0x0D]=0;} |
| 142 | | if (controlKey && !shiftKey && !(keyboard[1] & 0x40)) addToKeyboardBuffer(0x0E); /* controlKey + N */ |
| 143 | | else {KbRepeatTable[0x0E]=0;} |
| 144 | | if (controlKey && !shiftKey && !(keyboard[1] & 0x80)) addToKeyboardBuffer(0x0F); /* controlKey + O */ |
| 145 | | else {KbRepeatTable[0x0F]=0;} |
| 124 | if ((controlKey && !shiftKey && !(keyboard[1] & 0x01)) || !(keyboard[9] & 0x02)) addToKeyboardBuffer(state, 0x08); /* controlKey + H or BACKSPACE */ |
| 125 | else {state->KbRepeatTable[0x08]=0;} |
| 126 | if ((controlKey && !shiftKey && !(keyboard[1] & 0x02)) || !(keyboard[8] & 0x20)) addToKeyboardBuffer(state, 0x09); /* controlKey + I or TAB */ |
| 127 | else {state->KbRepeatTable[0x09]=0;} |
| 128 | if (controlKey && !shiftKey && !(keyboard[1] & 0x04)) addToKeyboardBuffer(state, 0x0A); /* controlKey + J */ |
| 129 | else {state->KbRepeatTable[0x0A]=0;} |
| 130 | if (controlKey && !shiftKey && !(keyboard[1] & 0x08)) addToKeyboardBuffer(state, 0x0B); /* controlKey + K */ |
| 131 | else {state->KbRepeatTable[0x0B]=0;} |
| 132 | if (controlKey && !shiftKey && !(keyboard[1] & 0x10)) addToKeyboardBuffer(state, 0x0C); /* controlKey + L */ |
| 133 | else {state->KbRepeatTable[0x0C]=0;} |
| 134 | if ((controlKey && !shiftKey && !(keyboard[1] & 0x20)) || !(keyboard[6] & 0x80)) addToKeyboardBuffer(state, 0x0D); /* controlKey + M or RETURN */ |
| 135 | else {state->KbRepeatTable[0x0D]=0;} |
| 136 | if (controlKey && !shiftKey && !(keyboard[1] & 0x40)) addToKeyboardBuffer(state, 0x0E); /* controlKey + N */ |
| 137 | else {state->KbRepeatTable[0x0E]=0;} |
| 138 | if (controlKey && !shiftKey && !(keyboard[1] & 0x80)) addToKeyboardBuffer(state, 0x0F); /* controlKey + O */ |
| 139 | else {state->KbRepeatTable[0x0F]=0;} |
| 146 | 140 | |
| 147 | | if (controlKey && !shiftKey && !(keyboard[2] & 0x01)) addToKeyboardBuffer(0x10); /* controlKey + P */ |
| 148 | | else {KbRepeatTable[0x10]=0;} |
| 149 | | if (controlKey && !shiftKey && !(keyboard[2] & 0x02)) addToKeyboardBuffer(0x11); /* controlKey + Q */ |
| 150 | | else {KbRepeatTable[0x11]=0;} |
| 151 | | if (controlKey && !shiftKey && !(keyboard[2] & 0x04)) addToKeyboardBuffer(0x12); /* controlKey + R */ |
| 152 | | else {KbRepeatTable[0x12]=0;} |
| 153 | | if (controlKey && !shiftKey && !(keyboard[2] & 0x08)) addToKeyboardBuffer(0x13); /* controlKey + S */ |
| 154 | | else {KbRepeatTable[0x13]=0;} |
| 155 | | if (controlKey && !shiftKey && !(keyboard[2] & 0x10)) addToKeyboardBuffer(0x14); /* controlKey + T */ |
| 156 | | else {KbRepeatTable[0x14]=0;} |
| 157 | | if (controlKey && !shiftKey && !(keyboard[2] & 0x20)) addToKeyboardBuffer(0x15); /* controlKey + U */ |
| 158 | | else {KbRepeatTable[0x15]=0;} |
| 159 | | if (controlKey && !shiftKey && !(keyboard[2] & 0x40)) addToKeyboardBuffer(0x16); /* controlKey + V */ |
| 160 | | else {KbRepeatTable[0x16]=0;} |
| 161 | | if (controlKey && !shiftKey && !(keyboard[2] & 0x80)) addToKeyboardBuffer(0x17); /* controlKey + W */ |
| 162 | | else {KbRepeatTable[0x17]=0;} |
| 141 | if (controlKey && !shiftKey && !(keyboard[2] & 0x01)) addToKeyboardBuffer(state, 0x10); /* controlKey + P */ |
| 142 | else {state->KbRepeatTable[0x10]=0;} |
| 143 | if (controlKey && !shiftKey && !(keyboard[2] & 0x02)) addToKeyboardBuffer(state, 0x11); /* controlKey + Q */ |
| 144 | else {state->KbRepeatTable[0x11]=0;} |
| 145 | if (controlKey && !shiftKey && !(keyboard[2] & 0x04)) addToKeyboardBuffer(state, 0x12); /* controlKey + R */ |
| 146 | else {state->KbRepeatTable[0x12]=0;} |
| 147 | if (controlKey && !shiftKey && !(keyboard[2] & 0x08)) addToKeyboardBuffer(state, 0x13); /* controlKey + S */ |
| 148 | else {state->KbRepeatTable[0x13]=0;} |
| 149 | if (controlKey && !shiftKey && !(keyboard[2] & 0x10)) addToKeyboardBuffer(state, 0x14); /* controlKey + T */ |
| 150 | else {state->KbRepeatTable[0x14]=0;} |
| 151 | if (controlKey && !shiftKey && !(keyboard[2] & 0x20)) addToKeyboardBuffer(state, 0x15); /* controlKey + U */ |
| 152 | else {state->KbRepeatTable[0x15]=0;} |
| 153 | if (controlKey && !shiftKey && !(keyboard[2] & 0x40)) addToKeyboardBuffer(state, 0x16); /* controlKey + V */ |
| 154 | else {state->KbRepeatTable[0x16]=0;} |
| 155 | if (controlKey && !shiftKey && !(keyboard[2] & 0x80)) addToKeyboardBuffer(state, 0x17); /* controlKey + W */ |
| 156 | else {state->KbRepeatTable[0x17]=0;} |
| 163 | 157 | |
| 164 | | if (controlKey && !shiftKey && !(keyboard[3] & 0x01)) addToKeyboardBuffer(0x18); /* controlKey + X */ |
| 165 | | else {KbRepeatTable[0x18]=0;} |
| 166 | | if (controlKey && !shiftKey && !(keyboard[3] & 0x02)) addToKeyboardBuffer(0x19); /* controlKey + Y */ |
| 167 | | else {KbRepeatTable[0x19]=0;} |
| 168 | | if (controlKey && !shiftKey && !(keyboard[3] & 0x04)) addToKeyboardBuffer(0x1A); /* controlKey + Z */ |
| 169 | | else {KbRepeatTable[0x1A]=0;} |
| 170 | | if ((controlKey && !shiftKey && !(keyboard[5] & 0x80)) || !(keyboard[0] & 0x01)) addToKeyboardBuffer(0x1B); /* controlKey + [ or ESCAPE/WP */ |
| 171 | | else {KbRepeatTable[0x1B]=0;} |
| 172 | | if (controlKey && !shiftKey && !(keyboard[3] & 0x10)) addToKeyboardBuffer(0x1C); /* controlKey + \ */ |
| 173 | | else {KbRepeatTable[0x1C]=0;} |
| 174 | | if (controlKey && !shiftKey && !(keyboard[3] & 0x08)) addToKeyboardBuffer(0x1D); /* controlKey + ] */ |
| 175 | | else {KbRepeatTable[0x1D]=0;} |
| 176 | | if (controlKey && !shiftKey && !(keyboard[3] & 0x20)) addToKeyboardBuffer(0x1E); /* controlKey + ^ */ |
| 177 | | else {KbRepeatTable[0x1E]=0;} |
| 178 | | if (controlKey && !shiftKey && !(keyboard[4] & 0x40)) addToKeyboardBuffer(0x1F); /* controlKey + 6 */ |
| 179 | | else {KbRepeatTable[0x1F]=0;} |
| 158 | if (controlKey && !shiftKey && !(keyboard[3] & 0x01)) addToKeyboardBuffer(state, 0x18); /* controlKey + X */ |
| 159 | else {state->KbRepeatTable[0x18]=0;} |
| 160 | if (controlKey && !shiftKey && !(keyboard[3] & 0x02)) addToKeyboardBuffer(state, 0x19); /* controlKey + Y */ |
| 161 | else {state->KbRepeatTable[0x19]=0;} |
| 162 | if (controlKey && !shiftKey && !(keyboard[3] & 0x04)) addToKeyboardBuffer(state, 0x1A); /* controlKey + Z */ |
| 163 | else {state->KbRepeatTable[0x1A]=0;} |
| 164 | if ((controlKey && !shiftKey && !(keyboard[5] & 0x80)) || !(keyboard[0] & 0x01)) addToKeyboardBuffer(state, 0x1B); /* controlKey + [ or ESCAPE/WP */ |
| 165 | else {state->KbRepeatTable[0x1B]=0;} |
| 166 | if (controlKey && !shiftKey && !(keyboard[3] & 0x10)) addToKeyboardBuffer(state, 0x1C); /* controlKey + \ */ |
| 167 | else {state->KbRepeatTable[0x1C]=0;} |
| 168 | if (controlKey && !shiftKey && !(keyboard[3] & 0x08)) addToKeyboardBuffer(state, 0x1D); /* controlKey + ] */ |
| 169 | else {state->KbRepeatTable[0x1D]=0;} |
| 170 | if (controlKey && !shiftKey && !(keyboard[3] & 0x20)) addToKeyboardBuffer(state, 0x1E); /* controlKey + ^ */ |
| 171 | else {state->KbRepeatTable[0x1E]=0;} |
| 172 | if (controlKey && !shiftKey && !(keyboard[4] & 0x40)) addToKeyboardBuffer(state, 0x1F); /* controlKey + 6 */ |
| 173 | else {state->KbRepeatTable[0x1F]=0;} |
| 180 | 174 | |
| 181 | | if (!controlKey && !shiftKey && !(keyboard[6] & 0x40)) addToKeyboardBuffer(0x20); /* SPACEBAR */ |
| 182 | | else {KbRepeatTable[0x20]=0;} |
| 183 | | if (shiftKey && !controlKey && !(keyboard[4] & 0x02)) addToKeyboardBuffer(0x21); /* shiftKey + 1 */ |
| 184 | | else {KbRepeatTable[0x21]=0;} |
| 185 | | if (shiftKey && !controlKey && !(keyboard[5] & 0x04)) addToKeyboardBuffer(0x22); /* shiftKey + ' */ |
| 186 | | else {KbRepeatTable[0x22]=0;} |
| 187 | | if (shiftKey && !controlKey && !(keyboard[4] & 0x08)) addToKeyboardBuffer(0x23); /* shiftKey + 3 */ |
| 188 | | else {KbRepeatTable[0x23]=0;} |
| 189 | | if (shiftKey && !controlKey && !(keyboard[4] & 0x10)) addToKeyboardBuffer(0x24); /* shiftKey + 4 */ |
| 190 | | else {KbRepeatTable[0x24]=0;} |
| 191 | | if (shiftKey && !controlKey && !(keyboard[4] & 0x20)) addToKeyboardBuffer(0x25); /* shiftKey + 5 */ |
| 192 | | else {KbRepeatTable[0x25]=0;} |
| 193 | | if (shiftKey && !controlKey && !(keyboard[4] & 0x80)) addToKeyboardBuffer(0x26); /* shiftKey + 7 */ |
| 194 | | else {KbRepeatTable[0x26]=0;} |
| 195 | | if (!shiftKey && !controlKey && !(keyboard[5] & 0x04)) addToKeyboardBuffer(0x27); /* ' */ |
| 196 | | else {KbRepeatTable[0x27]=0;} |
| 175 | if (!controlKey && !shiftKey && !(keyboard[6] & 0x40)) addToKeyboardBuffer(state, 0x20); /* SPACEBAR */ |
| 176 | else {state->KbRepeatTable[0x20]=0;} |
| 177 | if (shiftKey && !controlKey && !(keyboard[4] & 0x02)) addToKeyboardBuffer(state, 0x21); /* shiftKey + 1 */ |
| 178 | else {state->KbRepeatTable[0x21]=0;} |
| 179 | if (shiftKey && !controlKey && !(keyboard[5] & 0x04)) addToKeyboardBuffer(state, 0x22); /* shiftKey + ' */ |
| 180 | else {state->KbRepeatTable[0x22]=0;} |
| 181 | if (shiftKey && !controlKey && !(keyboard[4] & 0x08)) addToKeyboardBuffer(state, 0x23); /* shiftKey + 3 */ |
| 182 | else {state->KbRepeatTable[0x23]=0;} |
| 183 | if (shiftKey && !controlKey && !(keyboard[4] & 0x10)) addToKeyboardBuffer(state, 0x24); /* shiftKey + 4 */ |
| 184 | else {state->KbRepeatTable[0x24]=0;} |
| 185 | if (shiftKey && !controlKey && !(keyboard[4] & 0x20)) addToKeyboardBuffer(state, 0x25); /* shiftKey + 5 */ |
| 186 | else {state->KbRepeatTable[0x25]=0;} |
| 187 | if (shiftKey && !controlKey && !(keyboard[4] & 0x80)) addToKeyboardBuffer(state, 0x26); /* shiftKey + 7 */ |
| 188 | else {state->KbRepeatTable[0x26]=0;} |
| 189 | if (!shiftKey && !controlKey && !(keyboard[5] & 0x04)) addToKeyboardBuffer(state, 0x27); /* ' */ |
| 190 | else {state->KbRepeatTable[0x27]=0;} |
| 197 | 191 | |
| 198 | | if (shiftKey && !controlKey && !(keyboard[5] & 0x02)) addToKeyboardBuffer(0x28); /* shiftKey + 9 */ |
| 199 | | else {KbRepeatTable[0x28]=0;} |
| 200 | | if (shiftKey && !controlKey && !(keyboard[4] & 0x01)) addToKeyboardBuffer(0x29); /* shiftKey + 0 */ |
| 201 | | else {KbRepeatTable[0x29]=0;} |
| 202 | | if (shiftKey && !controlKey && !(keyboard[5] & 0x01)) addToKeyboardBuffer(0x2A); /* shiftKey + 8 */ |
| 203 | | else {KbRepeatTable[0x2A]=0;} |
| 204 | | if (!controlKey && !shiftKey && !(keyboard[5] & 0x08)) addToKeyboardBuffer(0x2B); /* + */ |
| 205 | | else {KbRepeatTable[0x2B]=0;} |
| 206 | | if (!controlKey && !shiftKey && !(keyboard[5] & 0x10)) addToKeyboardBuffer(0x2C); /* , */ |
| 207 | | else {KbRepeatTable[0x2C]=0;} |
| 208 | | if (!controlKey && !shiftKey && !(keyboard[3] & 0x40)) addToKeyboardBuffer(0x2D); /* - */ |
| 209 | | else {KbRepeatTable[0x2D]=0;} |
| 210 | | if (!controlKey && !shiftKey && !(keyboard[5] & 0x20)) addToKeyboardBuffer(0x2E); /* . */ |
| 211 | | else {KbRepeatTable[0x2E]=0;} |
| 212 | | if (!controlKey && !shiftKey && !(keyboard[5] & 0x40)) addToKeyboardBuffer(0x2F); /* / */ |
| 213 | | else {KbRepeatTable[0x2F]=0;} |
| 192 | if (shiftKey && !controlKey && !(keyboard[5] & 0x02)) addToKeyboardBuffer(state, 0x28); /* shiftKey + 9 */ |
| 193 | else {state->KbRepeatTable[0x28]=0;} |
| 194 | if (shiftKey && !controlKey && !(keyboard[4] & 0x01)) addToKeyboardBuffer(state, 0x29); /* shiftKey + 0 */ |
| 195 | else {state->KbRepeatTable[0x29]=0;} |
| 196 | if (shiftKey && !controlKey && !(keyboard[5] & 0x01)) addToKeyboardBuffer(state, 0x2A); /* shiftKey + 8 */ |
| 197 | else {state->KbRepeatTable[0x2A]=0;} |
| 198 | if (!controlKey && !shiftKey && !(keyboard[5] & 0x08)) addToKeyboardBuffer(state, 0x2B); /* + */ |
| 199 | else {state->KbRepeatTable[0x2B]=0;} |
| 200 | if (!controlKey && !shiftKey && !(keyboard[5] & 0x10)) addToKeyboardBuffer(state, 0x2C); /* , */ |
| 201 | else {state->KbRepeatTable[0x2C]=0;} |
| 202 | if (!controlKey && !shiftKey && !(keyboard[3] & 0x40)) addToKeyboardBuffer(state, 0x2D); /* - */ |
| 203 | else {state->KbRepeatTable[0x2D]=0;} |
| 204 | if (!controlKey && !shiftKey && !(keyboard[5] & 0x20)) addToKeyboardBuffer(state, 0x2E); /* . */ |
| 205 | else {state->KbRepeatTable[0x2E]=0;} |
| 206 | if (!controlKey && !shiftKey && !(keyboard[5] & 0x40)) addToKeyboardBuffer(state, 0x2F); /* / */ |
| 207 | else {state->KbRepeatTable[0x2F]=0;} |
| 214 | 208 | |
| 215 | | if (!shiftKey && !controlKey && !(keyboard[4] & 0x01)) addToKeyboardBuffer(0x30); /* 0 */ |
| 216 | | else {KbRepeatTable[0x30]=0;} |
| 217 | | if (!shiftKey && !controlKey && !(keyboard[4] & 0x02)) addToKeyboardBuffer(0x31); /* 1 */ |
| 218 | | else {KbRepeatTable[0x31]=0;} |
| 219 | | if (!shiftKey && !controlKey && !(keyboard[4] & 0x04)) addToKeyboardBuffer(0x32); /* 2 */ |
| 220 | | else {KbRepeatTable[0x32]=0;} |
| 221 | | if (!shiftKey && !controlKey && !(keyboard[4] & 0x08)) addToKeyboardBuffer(0x33); /* 3 */ |
| 222 | | else {KbRepeatTable[0x33]=0;} |
| 223 | | if (!shiftKey && !controlKey && !(keyboard[4] & 0x10)) addToKeyboardBuffer(0x34); /* 4 */ |
| 224 | | else {KbRepeatTable[0x34]=0;} |
| 225 | | if (!shiftKey && !controlKey && !(keyboard[4] & 0x20)) addToKeyboardBuffer(0x35); /* 5 */ |
| 226 | | else {KbRepeatTable[0x35]=0;} |
| 227 | | if (!shiftKey && !controlKey && !(keyboard[4] & 0x40)) addToKeyboardBuffer(0x36); /* 6 */ |
| 228 | | else {KbRepeatTable[0x36]=0;} |
| 229 | | if (!shiftKey && !controlKey && !(keyboard[4] & 0x80)) addToKeyboardBuffer(0x37); /* 7 */ |
| 230 | | else {KbRepeatTable[0x37]=0;} |
| 209 | if (!shiftKey && !controlKey && !(keyboard[4] & 0x01)) addToKeyboardBuffer(state, 0x30); /* 0 */ |
| 210 | else {state->KbRepeatTable[0x30]=0;} |
| 211 | if (!shiftKey && !controlKey && !(keyboard[4] & 0x02)) addToKeyboardBuffer(state, 0x31); /* 1 */ |
| 212 | else {state->KbRepeatTable[0x31]=0;} |
| 213 | if (!shiftKey && !controlKey && !(keyboard[4] & 0x04)) addToKeyboardBuffer(state, 0x32); /* 2 */ |
| 214 | else {state->KbRepeatTable[0x32]=0;} |
| 215 | if (!shiftKey && !controlKey && !(keyboard[4] & 0x08)) addToKeyboardBuffer(state, 0x33); /* 3 */ |
| 216 | else {state->KbRepeatTable[0x33]=0;} |
| 217 | if (!shiftKey && !controlKey && !(keyboard[4] & 0x10)) addToKeyboardBuffer(state, 0x34); /* 4 */ |
| 218 | else {state->KbRepeatTable[0x34]=0;} |
| 219 | if (!shiftKey && !controlKey && !(keyboard[4] & 0x20)) addToKeyboardBuffer(state, 0x35); /* 5 */ |
| 220 | else {state->KbRepeatTable[0x35]=0;} |
| 221 | if (!shiftKey && !controlKey && !(keyboard[4] & 0x40)) addToKeyboardBuffer(state, 0x36); /* 6 */ |
| 222 | else {state->KbRepeatTable[0x36]=0;} |
| 223 | if (!shiftKey && !controlKey && !(keyboard[4] & 0x80)) addToKeyboardBuffer(state, 0x37); /* 7 */ |
| 224 | else {state->KbRepeatTable[0x37]=0;} |
| 231 | 225 | |
| 232 | | if (!shiftKey && !controlKey && !(keyboard[5] & 0x01)) addToKeyboardBuffer(0x38); /* 8 */ |
| 233 | | else {KbRepeatTable[0x38]=0;} |
| 234 | | if (!shiftKey && !controlKey && !(keyboard[5] & 0x02)) addToKeyboardBuffer(0x39); /* 9 */ |
| 235 | | else {KbRepeatTable[0x39]=0;} |
| 236 | | if (shiftKey && !controlKey && !(keyboard[3] & 0x80)) addToKeyboardBuffer(0x3A); /* shiftKey + ; */ |
| 237 | | else {KbRepeatTable[0x3A]=0;} |
| 238 | | if (!controlKey && !shiftKey && !(keyboard[3] & 0x80)) addToKeyboardBuffer(0x3B); /* ; */ |
| 239 | | else {KbRepeatTable[0x3B]=0;} |
| 240 | | if (shiftKey && !controlKey && !(keyboard[5] & 0x10)) addToKeyboardBuffer(0x3C); /* shiftKey + , */ |
| 241 | | else {KbRepeatTable[0x3C]=0;} |
| 242 | | if (shiftKey && !controlKey && !(keyboard[5] & 0x08)) addToKeyboardBuffer(0x3D); /* shiftKey + + */ |
| 243 | | else {KbRepeatTable[0x3D]=0;} |
| 244 | | if (shiftKey && !controlKey && !(keyboard[5] & 0x20)) addToKeyboardBuffer(0x3E); /* shiftKey + . */ |
| 245 | | else {KbRepeatTable[0x3E]=0;} |
| 246 | | if (shiftKey && !controlKey && !(keyboard[5] & 0x40)) addToKeyboardBuffer(0x3F); /* shiftKey + / */ |
| 247 | | else {KbRepeatTable[0x3F]=0;} |
| 226 | if (!shiftKey && !controlKey && !(keyboard[5] & 0x01)) addToKeyboardBuffer(state, 0x38); /* 8 */ |
| 227 | else {state->KbRepeatTable[0x38]=0;} |
| 228 | if (!shiftKey && !controlKey && !(keyboard[5] & 0x02)) addToKeyboardBuffer(state, 0x39); /* 9 */ |
| 229 | else {state->KbRepeatTable[0x39]=0;} |
| 230 | if (shiftKey && !controlKey && !(keyboard[3] & 0x80)) addToKeyboardBuffer(state, 0x3A); /* shiftKey + ; */ |
| 231 | else {state->KbRepeatTable[0x3A]=0;} |
| 232 | if (!controlKey && !shiftKey && !(keyboard[3] & 0x80)) addToKeyboardBuffer(state, 0x3B); /* ; */ |
| 233 | else {state->KbRepeatTable[0x3B]=0;} |
| 234 | if (shiftKey && !controlKey && !(keyboard[5] & 0x10)) addToKeyboardBuffer(state, 0x3C); /* shiftKey + , */ |
| 235 | else {state->KbRepeatTable[0x3C]=0;} |
| 236 | if (shiftKey && !controlKey && !(keyboard[5] & 0x08)) addToKeyboardBuffer(state, 0x3D); /* shiftKey + + */ |
| 237 | else {state->KbRepeatTable[0x3D]=0;} |
| 238 | if (shiftKey && !controlKey && !(keyboard[5] & 0x20)) addToKeyboardBuffer(state, 0x3E); /* shiftKey + . */ |
| 239 | else {state->KbRepeatTable[0x3E]=0;} |
| 240 | if (shiftKey && !controlKey && !(keyboard[5] & 0x40)) addToKeyboardBuffer(state, 0x3F); /* shiftKey + / */ |
| 241 | else {state->KbRepeatTable[0x3F]=0;} |
| 248 | 242 | |
| 249 | | if (shiftKey && !controlKey && !(keyboard[4] & 0x04)) addToKeyboardBuffer(0x40); /* shiftKey + 2 */ |
| 250 | | else {KbRepeatTable[0x40]=0;} |
| 251 | | if (shiftKey && !controlKey && !(keyboard[0] & 0x02)) addToKeyboardBuffer(0x41); /* shiftKey + A */ |
| 252 | | else {KbRepeatTable[0x41]=0;} |
| 253 | | if (shiftKey && !controlKey && !(keyboard[0] & 0x04)) addToKeyboardBuffer(0x42); /* shiftKey + B */ |
| 254 | | else {KbRepeatTable[0x42]=0;} |
| 255 | | if (shiftKey && !controlKey && !(keyboard[0] & 0x08)) addToKeyboardBuffer(0x43); /* shiftKey + C */ |
| 256 | | else {KbRepeatTable[0x43]=0;} |
| 257 | | if (shiftKey && !controlKey && !(keyboard[0] & 0x10)) addToKeyboardBuffer(0x44); /* shiftKey + D */ |
| 258 | | else {KbRepeatTable[0x44]=0;} |
| 259 | | if (shiftKey && !controlKey && !(keyboard[0] & 0x20)) addToKeyboardBuffer(0x45); /* shiftKey + E */ |
| 260 | | else {KbRepeatTable[0x45]=0;} |
| 261 | | if (shiftKey && !controlKey && !(keyboard[0] & 0x40)) addToKeyboardBuffer(0x46); /* shiftKey + F */ |
| 262 | | else {KbRepeatTable[0x46]=0;} |
| 263 | | if (shiftKey && !controlKey && !(keyboard[0] & 0x80)) addToKeyboardBuffer(0x47); /* shiftKey + G */ |
| 264 | | else {KbRepeatTable[0x47]=0;} |
| 243 | if (shiftKey && !controlKey && !(keyboard[4] & 0x04)) addToKeyboardBuffer(state, 0x40); /* shiftKey + 2 */ |
| 244 | else {state->KbRepeatTable[0x40]=0;} |
| 245 | if (shiftKey && !controlKey && !(keyboard[0] & 0x02)) addToKeyboardBuffer(state, 0x41); /* shiftKey + A */ |
| 246 | else {state->KbRepeatTable[0x41]=0;} |
| 247 | if (shiftKey && !controlKey && !(keyboard[0] & 0x04)) addToKeyboardBuffer(state, 0x42); /* shiftKey + B */ |
| 248 | else {state->KbRepeatTable[0x42]=0;} |
| 249 | if (shiftKey && !controlKey && !(keyboard[0] & 0x08)) addToKeyboardBuffer(state, 0x43); /* shiftKey + C */ |
| 250 | else {state->KbRepeatTable[0x43]=0;} |
| 251 | if (shiftKey && !controlKey && !(keyboard[0] & 0x10)) addToKeyboardBuffer(state, 0x44); /* shiftKey + D */ |
| 252 | else {state->KbRepeatTable[0x44]=0;} |
| 253 | if (shiftKey && !controlKey && !(keyboard[0] & 0x20)) addToKeyboardBuffer(state, 0x45); /* shiftKey + E */ |
| 254 | else {state->KbRepeatTable[0x45]=0;} |
| 255 | if (shiftKey && !controlKey && !(keyboard[0] & 0x40)) addToKeyboardBuffer(state, 0x46); /* shiftKey + F */ |
| 256 | else {state->KbRepeatTable[0x46]=0;} |
| 257 | if (shiftKey && !controlKey && !(keyboard[0] & 0x80)) addToKeyboardBuffer(state, 0x47); /* shiftKey + G */ |
| 258 | else {state->KbRepeatTable[0x47]=0;} |
| 265 | 259 | |
| 266 | | if (shiftKey && !controlKey && !(keyboard[1] & 0x01)) addToKeyboardBuffer(0x48); /* shiftKey + H */ |
| 267 | | else {KbRepeatTable[0x48]=0;} |
| 268 | | if (shiftKey && !controlKey && !(keyboard[1] & 0x02)) addToKeyboardBuffer(0x49); /* shiftKey + I */ |
| 269 | | else {KbRepeatTable[0x49]=0;} |
| 270 | | if (shiftKey && !controlKey && !(keyboard[1] & 0x04)) addToKeyboardBuffer(0x4A); /* shiftKey + J */ |
| 271 | | else {KbRepeatTable[0x4A]=0;} |
| 272 | | if (shiftKey && !controlKey && !(keyboard[1] & 0x08)) addToKeyboardBuffer(0x4B); /* shiftKey + K */ |
| 273 | | else {KbRepeatTable[0x4B]=0;} |
| 274 | | if (shiftKey && !controlKey && !(keyboard[1] & 0x10)) addToKeyboardBuffer(0x4C); /* shiftKey + L */ |
| 275 | | else {KbRepeatTable[0x4C]=0;} |
| 276 | | if (shiftKey && !controlKey && !(keyboard[1] & 0x20)) addToKeyboardBuffer(0x4D); /* shiftKey + M */ |
| 277 | | else {KbRepeatTable[0x4D]=0;} |
| 278 | | if (shiftKey && !controlKey && !(keyboard[1] & 0x40)) addToKeyboardBuffer(0x4E); /* shiftKey + N */ |
| 279 | | else {KbRepeatTable[0x4E]=0;} |
| 280 | | if (shiftKey && !controlKey && !(keyboard[1] & 0x80)) addToKeyboardBuffer(0x4F); /* shiftKey + O */ |
| 281 | | else {KbRepeatTable[0x4F]=0;} |
| 260 | if (shiftKey && !controlKey && !(keyboard[1] & 0x01)) addToKeyboardBuffer(state, 0x48); /* shiftKey + H */ |
| 261 | else {state->KbRepeatTable[0x48]=0;} |
| 262 | if (shiftKey && !controlKey && !(keyboard[1] & 0x02)) addToKeyboardBuffer(state, 0x49); /* shiftKey + I */ |
| 263 | else {state->KbRepeatTable[0x49]=0;} |
| 264 | if (shiftKey && !controlKey && !(keyboard[1] & 0x04)) addToKeyboardBuffer(state, 0x4A); /* shiftKey + J */ |
| 265 | else {state->KbRepeatTable[0x4A]=0;} |
| 266 | if (shiftKey && !controlKey && !(keyboard[1] & 0x08)) addToKeyboardBuffer(state, 0x4B); /* shiftKey + K */ |
| 267 | else {state->KbRepeatTable[0x4B]=0;} |
| 268 | if (shiftKey && !controlKey && !(keyboard[1] & 0x10)) addToKeyboardBuffer(state, 0x4C); /* shiftKey + L */ |
| 269 | else {state->KbRepeatTable[0x4C]=0;} |
| 270 | if (shiftKey && !controlKey && !(keyboard[1] & 0x20)) addToKeyboardBuffer(state, 0x4D); /* shiftKey + M */ |
| 271 | else {state->KbRepeatTable[0x4D]=0;} |
| 272 | if (shiftKey && !controlKey && !(keyboard[1] & 0x40)) addToKeyboardBuffer(state, 0x4E); /* shiftKey + N */ |
| 273 | else {state->KbRepeatTable[0x4E]=0;} |
| 274 | if (shiftKey && !controlKey && !(keyboard[1] & 0x80)) addToKeyboardBuffer(state, 0x4F); /* shiftKey + O */ |
| 275 | else {state->KbRepeatTable[0x4F]=0;} |
| 282 | 276 | |
| 283 | | if (shiftKey && !controlKey && !(keyboard[2] & 0x01)) addToKeyboardBuffer(0x50); /* shiftKey + P */ |
| 284 | | else {KbRepeatTable[0x50]=0;} |
| 285 | | if (shiftKey && !controlKey && !(keyboard[2] & 0x02)) addToKeyboardBuffer(0x51); /* shiftKey + Q */ |
| 286 | | else {KbRepeatTable[0x51]=0;} |
| 287 | | if (shiftKey && !controlKey && !(keyboard[2] & 0x04)) addToKeyboardBuffer(0x52); /* shiftKey + R */ |
| 288 | | else {KbRepeatTable[0x52]=0;} |
| 289 | | if (shiftKey && !controlKey && !(keyboard[2] & 0x08)) addToKeyboardBuffer(0x53); /* shiftKey + S */ |
| 290 | | else {KbRepeatTable[0x53]=0;} |
| 291 | | if (shiftKey && !controlKey && !(keyboard[2] & 0x10)) addToKeyboardBuffer(0x54); /* shiftKey + T */ |
| 292 | | else {KbRepeatTable[0x54]=0;} |
| 293 | | if (shiftKey && !controlKey && !(keyboard[2] & 0x20)) addToKeyboardBuffer(0x55); /* shiftKey + U */ |
| 294 | | else {KbRepeatTable[0x55]=0;} |
| 295 | | if (shiftKey && !controlKey && !(keyboard[2] & 0x40)) addToKeyboardBuffer(0x56); /* shiftKey + V */ |
| 296 | | else {KbRepeatTable[0x56]=0;} |
| 297 | | if (shiftKey && !controlKey && !(keyboard[2] & 0x80)) addToKeyboardBuffer(0x57); /* shiftKey + W */ |
| 298 | | else {KbRepeatTable[0x57]=0;} |
| 277 | if (shiftKey && !controlKey && !(keyboard[2] & 0x01)) addToKeyboardBuffer(state, 0x50); /* shiftKey + P */ |
| 278 | else {state->KbRepeatTable[0x50]=0;} |
| 279 | if (shiftKey && !controlKey && !(keyboard[2] & 0x02)) addToKeyboardBuffer(state, 0x51); /* shiftKey + Q */ |
| 280 | else {state->KbRepeatTable[0x51]=0;} |
| 281 | if (shiftKey && !controlKey && !(keyboard[2] & 0x04)) addToKeyboardBuffer(state, 0x52); /* shiftKey + R */ |
| 282 | else {state->KbRepeatTable[0x52]=0;} |
| 283 | if (shiftKey && !controlKey && !(keyboard[2] & 0x08)) addToKeyboardBuffer(state, 0x53); /* shiftKey + S */ |
| 284 | else {state->KbRepeatTable[0x53]=0;} |
| 285 | if (shiftKey && !controlKey && !(keyboard[2] & 0x10)) addToKeyboardBuffer(state, 0x54); /* shiftKey + T */ |
| 286 | else {state->KbRepeatTable[0x54]=0;} |
| 287 | if (shiftKey && !controlKey && !(keyboard[2] & 0x20)) addToKeyboardBuffer(state, 0x55); /* shiftKey + U */ |
| 288 | else {state->KbRepeatTable[0x55]=0;} |
| 289 | if (shiftKey && !controlKey && !(keyboard[2] & 0x40)) addToKeyboardBuffer(state, 0x56); /* shiftKey + V */ |
| 290 | else {state->KbRepeatTable[0x56]=0;} |
| 291 | if (shiftKey && !controlKey && !(keyboard[2] & 0x80)) addToKeyboardBuffer(state, 0x57); /* shiftKey + W */ |
| 292 | else {state->KbRepeatTable[0x57]=0;} |
| 299 | 293 | |
| 300 | | if (shiftKey && !controlKey && !(keyboard[3] & 0x01)) addToKeyboardBuffer(0x58); /* shiftKey + X */ |
| 301 | | else {KbRepeatTable[0x58]=0;} |
| 302 | | if (shiftKey && !controlKey && !(keyboard[3] & 0x02)) addToKeyboardBuffer(0x59); /* shiftKey + Y */ |
| 303 | | else {KbRepeatTable[0x59]=0;} |
| 304 | | if (shiftKey && !controlKey && !(keyboard[3] & 0x04)) addToKeyboardBuffer(0x5A); /* shiftKey + Z */ |
| 305 | | else {KbRepeatTable[0x5A]=0;} |
| 306 | | if (!controlKey && !shiftKey && !(keyboard[5] & 0x80)) addToKeyboardBuffer(0x5B); /* [ */ |
| 307 | | else {KbRepeatTable[0x5B]=0;} |
| 308 | | if (!controlKey && !shiftKey && !(keyboard[3] & 0x10)) addToKeyboardBuffer(0x5C); /* \ */ |
| 309 | | else {KbRepeatTable[0x5C]=0;} |
| 310 | | if (!controlKey && !shiftKey && !(keyboard[3] & 0x08)) addToKeyboardBuffer(0x5D); /* ] */ |
| 311 | | else {KbRepeatTable[0x5D]=0;} |
| 312 | | if (!controlKey && !shiftKey && !(keyboard[3] & 0x20)) addToKeyboardBuffer(0x5E); /* ^ */ |
| 313 | | else {KbRepeatTable[0x5E]=0;} |
| 314 | | if (shiftKey && !controlKey && !(keyboard[4] & 0x40)) addToKeyboardBuffer(0x5F); /* shiftKey + 6 */ |
| 315 | | else {KbRepeatTable[0x5F]=0;} |
| 294 | if (shiftKey && !controlKey && !(keyboard[3] & 0x01)) addToKeyboardBuffer(state, 0x58); /* shiftKey + X */ |
| 295 | else {state->KbRepeatTable[0x58]=0;} |
| 296 | if (shiftKey && !controlKey && !(keyboard[3] & 0x02)) addToKeyboardBuffer(state, 0x59); /* shiftKey + Y */ |
| 297 | else {state->KbRepeatTable[0x59]=0;} |
| 298 | if (shiftKey && !controlKey && !(keyboard[3] & 0x04)) addToKeyboardBuffer(state, 0x5A); /* shiftKey + Z */ |
| 299 | else {state->KbRepeatTable[0x5A]=0;} |
| 300 | if (!controlKey && !shiftKey && !(keyboard[5] & 0x80)) addToKeyboardBuffer(state, 0x5B); /* [ */ |
| 301 | else {state->KbRepeatTable[0x5B]=0;} |
| 302 | if (!controlKey && !shiftKey && !(keyboard[3] & 0x10)) addToKeyboardBuffer(state, 0x5C); /* \ */ |
| 303 | else {state->KbRepeatTable[0x5C]=0;} |
| 304 | if (!controlKey && !shiftKey && !(keyboard[3] & 0x08)) addToKeyboardBuffer(state, 0x5D); /* ] */ |
| 305 | else {state->KbRepeatTable[0x5D]=0;} |
| 306 | if (!controlKey && !shiftKey && !(keyboard[3] & 0x20)) addToKeyboardBuffer(state, 0x5E); /* ^ */ |
| 307 | else {state->KbRepeatTable[0x5E]=0;} |
| 308 | if (shiftKey && !controlKey && !(keyboard[4] & 0x40)) addToKeyboardBuffer(state, 0x5F); /* shiftKey + 6 */ |
| 309 | else {state->KbRepeatTable[0x5F]=0;} |
| 316 | 310 | |
| 317 | | if (shiftKey && !controlKey && !(keyboard[3] & 0x40)) addToKeyboardBuffer(0x60); /* shiftKey + - */ |
| 318 | | else {KbRepeatTable[0x60]=0;} |
| 319 | | if (!controlKey && !shiftKey && !(keyboard[0] & 0x02)) addToKeyboardBuffer(0x61); /* A */ |
| 320 | | else {KbRepeatTable[0x61]=0;} |
| 321 | | if (!controlKey && !shiftKey && !(keyboard[0] & 0x04)) addToKeyboardBuffer(0x62); /* B */ |
| 322 | | else {KbRepeatTable[0x62]=0;} |
| 323 | | if (!controlKey && !shiftKey && !(keyboard[0] & 0x08)) addToKeyboardBuffer(0x63); /* C */ |
| 324 | | else {KbRepeatTable[0x63]=0;} |
| 325 | | if (!controlKey && !shiftKey && !(keyboard[0] & 0x10)) addToKeyboardBuffer(0x64); /* D */ |
| 326 | | else {KbRepeatTable[0x64]=0;} |
| 327 | | if (!controlKey && !shiftKey && !(keyboard[0] & 0x20)) addToKeyboardBuffer(0x65); /* E */ |
| 328 | | else {KbRepeatTable[0x65]=0;} |
| 329 | | if (!controlKey && !shiftKey && !(keyboard[0] & 0x40)) addToKeyboardBuffer(0x66); /* F */ |
| 330 | | else {KbRepeatTable[0x66]=0;} |
| 331 | | if (!controlKey && !shiftKey && !(keyboard[0] & 0x80)) addToKeyboardBuffer(0x67); /* G */ |
| 332 | | else {KbRepeatTable[0x67]=0;} |
| 311 | if (shiftKey && !controlKey && !(keyboard[3] & 0x40)) addToKeyboardBuffer(state, 0x60); /* shiftKey + - */ |
| 312 | else {state->KbRepeatTable[0x60]=0;} |
| 313 | if (!controlKey && !shiftKey && !(keyboard[0] & 0x02)) addToKeyboardBuffer(state, 0x61); /* A */ |
| 314 | else {state->KbRepeatTable[0x61]=0;} |
| 315 | if (!controlKey && !shiftKey && !(keyboard[0] & 0x04)) addToKeyboardBuffer(state, 0x62); /* B */ |
| 316 | else {state->KbRepeatTable[0x62]=0;} |
| 317 | if (!controlKey && !shiftKey && !(keyboard[0] & 0x08)) addToKeyboardBuffer(state, 0x63); /* C */ |
| 318 | else {state->KbRepeatTable[0x63]=0;} |
| 319 | if (!controlKey && !shiftKey && !(keyboard[0] & 0x10)) addToKeyboardBuffer(state, 0x64); /* D */ |
| 320 | else {state->KbRepeatTable[0x64]=0;} |
| 321 | if (!controlKey && !shiftKey && !(keyboard[0] & 0x20)) addToKeyboardBuffer(state, 0x65); /* E */ |
| 322 | else {state->KbRepeatTable[0x65]=0;} |
| 323 | if (!controlKey && !shiftKey && !(keyboard[0] & 0x40)) addToKeyboardBuffer(state, 0x66); /* F */ |
| 324 | else {state->KbRepeatTable[0x66]=0;} |
| 325 | if (!controlKey && !shiftKey && !(keyboard[0] & 0x80)) addToKeyboardBuffer(state, 0x67); /* G */ |
| 326 | else {state->KbRepeatTable[0x67]=0;} |
| 333 | 327 | |
| 334 | | if (!controlKey && !shiftKey && !(keyboard[1] & 0x01)) addToKeyboardBuffer(0x68); /* H */ |
| 335 | | else {KbRepeatTable[0x68]=0;} |
| 336 | | if (!controlKey && !shiftKey && !(keyboard[1] & 0x02)) addToKeyboardBuffer(0x69); /* I */ |
| 337 | | else {KbRepeatTable[0x69]=0;} |
| 338 | | if (!controlKey && !shiftKey && !(keyboard[1] & 0x04)) addToKeyboardBuffer(0x6A); /* J */ |
| 339 | | else {KbRepeatTable[0x6A]=0;} |
| 340 | | if (!controlKey && !shiftKey && !(keyboard[1] & 0x08)) addToKeyboardBuffer(0x6B); /* K */ |
| 341 | | else {KbRepeatTable[0x6B]=0;} |
| 342 | | if (!controlKey && !shiftKey && !(keyboard[1] & 0x10)) addToKeyboardBuffer(0x6C); /* L */ |
| 343 | | else {KbRepeatTable[0x6C]=0;} |
| 344 | | if (!controlKey && !shiftKey && !(keyboard[1] & 0x20)) addToKeyboardBuffer(0x6D); /* M */ |
| 345 | | else {KbRepeatTable[0x6D]=0;} |
| 346 | | if (!controlKey && !shiftKey && !(keyboard[1] & 0x40)) addToKeyboardBuffer(0x6E); /* N */ |
| 347 | | else {KbRepeatTable[0x6E]=0;} |
| 348 | | if (!controlKey && !shiftKey && !(keyboard[1] & 0x80)) addToKeyboardBuffer(0x6F); /* O */ |
| 349 | | else {KbRepeatTable[0x6F]=0;} |
| 328 | if (!controlKey && !shiftKey && !(keyboard[1] & 0x01)) addToKeyboardBuffer(state, 0x68); /* H */ |
| 329 | else {state->KbRepeatTable[0x68]=0;} |
| 330 | if (!controlKey && !shiftKey && !(keyboard[1] & 0x02)) addToKeyboardBuffer(state, 0x69); /* I */ |
| 331 | else {state->KbRepeatTable[0x69]=0;} |
| 332 | if (!controlKey && !shiftKey && !(keyboard[1] & 0x04)) addToKeyboardBuffer(state, 0x6A); /* J */ |
| 333 | else {state->KbRepeatTable[0x6A]=0;} |
| 334 | if (!controlKey && !shiftKey && !(keyboard[1] & 0x08)) addToKeyboardBuffer(state, 0x6B); /* K */ |
| 335 | else {state->KbRepeatTable[0x6B]=0;} |
| 336 | if (!controlKey && !shiftKey && !(keyboard[1] & 0x10)) addToKeyboardBuffer(state, 0x6C); /* L */ |
| 337 | else {state->KbRepeatTable[0x6C]=0;} |
| 338 | if (!controlKey && !shiftKey && !(keyboard[1] & 0x20)) addToKeyboardBuffer(state, 0x6D); /* M */ |
| 339 | else {state->KbRepeatTable[0x6D]=0;} |
| 340 | if (!controlKey && !shiftKey && !(keyboard[1] & 0x40)) addToKeyboardBuffer(state, 0x6E); /* N */ |
| 341 | else {state->KbRepeatTable[0x6E]=0;} |
| 342 | if (!controlKey && !shiftKey && !(keyboard[1] & 0x80)) addToKeyboardBuffer(state, 0x6F); /* O */ |
| 343 | else {state->KbRepeatTable[0x6F]=0;} |
| 350 | 344 | |
| 351 | | if (!controlKey && !shiftKey && !(keyboard[2] & 0x01)) addToKeyboardBuffer(0x70); /* P */ |
| 352 | | else {KbRepeatTable[0x70]=0;} |
| 353 | | if (!controlKey && !shiftKey && !(keyboard[2] & 0x02)) addToKeyboardBuffer(0x71); /* Q */ |
| 354 | | else {KbRepeatTable[0x71]=0;} |
| 355 | | if (!controlKey && !shiftKey && !(keyboard[2] & 0x04)) addToKeyboardBuffer(0x72); /* R */ |
| 356 | | else {KbRepeatTable[0x72]=0;} |
| 357 | | if (!controlKey && !shiftKey && !(keyboard[2] & 0x08)) addToKeyboardBuffer(0x73); /* S */ |
| 358 | | else {KbRepeatTable[0x73]=0;} |
| 359 | | if (!controlKey && !shiftKey && !(keyboard[2] & 0x10)) addToKeyboardBuffer(0x74); /* T */ |
| 360 | | else {KbRepeatTable[0x74]=0;} |
| 361 | | if (!controlKey && !shiftKey && !(keyboard[2] & 0x20)) addToKeyboardBuffer(0x75); /* U */ |
| 362 | | else {KbRepeatTable[0x75]=0;} |
| 363 | | if (!controlKey && !shiftKey && !(keyboard[2] & 0x40)) addToKeyboardBuffer(0x76); /* V */ |
| 364 | | else {KbRepeatTable[0x76]=0;} |
| 365 | | if (!controlKey && !shiftKey && !(keyboard[2] & 0x80)) addToKeyboardBuffer(0x77); /* W */ |
| 366 | | else {KbRepeatTable[0x77]=0;} |
| 345 | if (!controlKey && !shiftKey && !(keyboard[2] & 0x01)) addToKeyboardBuffer(state, 0x70); /* P */ |
| 346 | else {state->KbRepeatTable[0x70]=0;} |
| 347 | if (!controlKey && !shiftKey && !(keyboard[2] & 0x02)) addToKeyboardBuffer(state, 0x71); /* Q */ |
| 348 | else {state->KbRepeatTable[0x71]=0;} |
| 349 | if (!controlKey && !shiftKey && !(keyboard[2] & 0x04)) addToKeyboardBuffer(state, 0x72); /* R */ |
| 350 | else {state->KbRepeatTable[0x72]=0;} |
| 351 | if (!controlKey && !shiftKey && !(keyboard[2] & 0x08)) addToKeyboardBuffer(state, 0x73); /* S */ |
| 352 | else {state->KbRepeatTable[0x73]=0;} |
| 353 | if (!controlKey && !shiftKey && !(keyboard[2] & 0x10)) addToKeyboardBuffer(state, 0x74); /* T */ |
| 354 | else {state->KbRepeatTable[0x74]=0;} |
| 355 | if (!controlKey && !shiftKey && !(keyboard[2] & 0x20)) addToKeyboardBuffer(state, 0x75); /* U */ |
| 356 | else {state->KbRepeatTable[0x75]=0;} |
| 357 | if (!controlKey && !shiftKey && !(keyboard[2] & 0x40)) addToKeyboardBuffer(state, 0x76); /* V */ |
| 358 | else {state->KbRepeatTable[0x76]=0;} |
| 359 | if (!controlKey && !shiftKey && !(keyboard[2] & 0x80)) addToKeyboardBuffer(state, 0x77); /* W */ |
| 360 | else {state->KbRepeatTable[0x77]=0;} |
| 367 | 361 | |
| 368 | | if (!controlKey && !shiftKey && !(keyboard[3] & 0x01)) addToKeyboardBuffer(0x78); /* X */ |
| 369 | | else {KbRepeatTable[0x78]=0;} |
| 370 | | if (!controlKey && !shiftKey && !(keyboard[3] & 0x02)) addToKeyboardBuffer(0x79); /* Y */ |
| 371 | | else {KbRepeatTable[0x79]=0;} |
| 372 | | if (!controlKey && !shiftKey && !(keyboard[3] & 0x04)) addToKeyboardBuffer(0x7A); /* Z */ |
| 373 | | else {KbRepeatTable[0x7A]=0;} |
| 374 | | if (shiftKey && !controlKey && !(keyboard[5] & 0x80)) addToKeyboardBuffer(0x7B); /* shiftKey + [ */ |
| 375 | | else {KbRepeatTable[0x7B]=0;} |
| 376 | | if (shiftKey && !controlKey && !(keyboard[3] & 0x10)) addToKeyboardBuffer(0x7C); /* shiftKey + \ */ |
| 377 | | else {KbRepeatTable[0x7C]=0;} |
| 378 | | if (shiftKey && !controlKey && !(keyboard[3] & 0x08)) addToKeyboardBuffer(0x7D); /* shiftKey + ] */ |
| 379 | | else {KbRepeatTable[0x7D]=0;} |
| 380 | | if (shiftKey && !controlKey && !(keyboard[3] & 0x20)) addToKeyboardBuffer(0x7E); /* shiftKey + ^ */ |
| 381 | | else {KbRepeatTable[0x7E]=0;} |
| 382 | | if (controlKey && !shiftKey && !(keyboard[7] & 0x80)) addToKeyboardBuffer(0x7F); /* controlKey + DELETE */ |
| 383 | | else {KbRepeatTable[0x7F]=0;} |
| 362 | if (!controlKey && !shiftKey && !(keyboard[3] & 0x01)) addToKeyboardBuffer(state, 0x78); /* X */ |
| 363 | else {state->KbRepeatTable[0x78]=0;} |
| 364 | if (!controlKey && !shiftKey && !(keyboard[3] & 0x02)) addToKeyboardBuffer(state, 0x79); /* Y */ |
| 365 | else {state->KbRepeatTable[0x79]=0;} |
| 366 | if (!controlKey && !shiftKey && !(keyboard[3] & 0x04)) addToKeyboardBuffer(state, 0x7A); /* Z */ |
| 367 | else {state->KbRepeatTable[0x7A]=0;} |
| 368 | if (shiftKey && !controlKey && !(keyboard[5] & 0x80)) addToKeyboardBuffer(state, 0x7B); /* shiftKey + [ */ |
| 369 | else {state->KbRepeatTable[0x7B]=0;} |
| 370 | if (shiftKey && !controlKey && !(keyboard[3] & 0x10)) addToKeyboardBuffer(state, 0x7C); /* shiftKey + \ */ |
| 371 | else {state->KbRepeatTable[0x7C]=0;} |
| 372 | if (shiftKey && !controlKey && !(keyboard[3] & 0x08)) addToKeyboardBuffer(state, 0x7D); /* shiftKey + ] */ |
| 373 | else {state->KbRepeatTable[0x7D]=0;} |
| 374 | if (shiftKey && !controlKey && !(keyboard[3] & 0x20)) addToKeyboardBuffer(state, 0x7E); /* shiftKey + ^ */ |
| 375 | else {state->KbRepeatTable[0x7E]=0;} |
| 376 | if (controlKey && !shiftKey && !(keyboard[7] & 0x80)) addToKeyboardBuffer(state, 0x7F); /* controlKey + DELETE */ |
| 377 | else {state->KbRepeatTable[0x7F]=0;} |
| 384 | 378 | |
| 385 | | if (!shiftKey && !(keyboard[8] & 0x01)) addToKeyboardBuffer(0x80); /* HOME */ |
| 386 | | else {KbRepeatTable[0x80]=0;} |
| 387 | | if (!shiftKey && !(keyboard[6] & 0x01)) addToKeyboardBuffer(0x81); /* I */ |
| 388 | | else {KbRepeatTable[0x81]=0;} |
| 389 | | if (!shiftKey && !(keyboard[6] & 0x02)) addToKeyboardBuffer(0x82); /* II */ |
| 390 | | else {KbRepeatTable[0x82]=0;} |
| 391 | | if (!shiftKey && !(keyboard[6] & 0x04)) addToKeyboardBuffer(0x83); /* III */ |
| 392 | | else {KbRepeatTable[0x83]=0;} |
| 393 | | if (!shiftKey && !(keyboard[6] & 0x08)) addToKeyboardBuffer(0x84); /* IV */ |
| 394 | | else {KbRepeatTable[0x84]=0;} |
| 395 | | if (!shiftKey && !(keyboard[6] & 0x10)) addToKeyboardBuffer(0x85); /* V */ |
| 396 | | else {KbRepeatTable[0x85]=0;} |
| 397 | | if (!shiftKey && !(keyboard[6] & 0x20)) addToKeyboardBuffer(0x86); /* VI */ |
| 398 | | else {KbRepeatTable[0x86]=0;} |
| 379 | if (!shiftKey && !(keyboard[8] & 0x01)) addToKeyboardBuffer(state, 0x80); /* HOME */ |
| 380 | else {state->KbRepeatTable[0x80]=0;} |
| 381 | if (!shiftKey && !(keyboard[6] & 0x01)) addToKeyboardBuffer(state, 0x81); /* I */ |
| 382 | else {state->KbRepeatTable[0x81]=0;} |
| 383 | if (!shiftKey && !(keyboard[6] & 0x02)) addToKeyboardBuffer(state, 0x82); /* II */ |
| 384 | else {state->KbRepeatTable[0x82]=0;} |
| 385 | if (!shiftKey && !(keyboard[6] & 0x04)) addToKeyboardBuffer(state, 0x83); /* III */ |
| 386 | else {state->KbRepeatTable[0x83]=0;} |
| 387 | if (!shiftKey && !(keyboard[6] & 0x08)) addToKeyboardBuffer(state, 0x84); /* IV */ |
| 388 | else {state->KbRepeatTable[0x84]=0;} |
| 389 | if (!shiftKey && !(keyboard[6] & 0x10)) addToKeyboardBuffer(state, 0x85); /* V */ |
| 390 | else {state->KbRepeatTable[0x85]=0;} |
| 391 | if (!shiftKey && !(keyboard[6] & 0x20)) addToKeyboardBuffer(state, 0x86); /* VI */ |
| 392 | else {state->KbRepeatTable[0x86]=0;} |
| 399 | 393 | /* 0x87 - Unused */ |
| 400 | 394 | |
| 401 | 395 | /* 0x88 - Unused */ |
| 402 | | if (shiftKey && !controlKey && !(keyboard[6] & 0x01)) addToKeyboardBuffer(0x89); /* shiftKey + I */ |
| 403 | | else {KbRepeatTable[0x89]=0;} |
| 404 | | if (shiftKey && !controlKey && !(keyboard[6] & 0x02)) addToKeyboardBuffer(0x8A); /* shiftKey + II */ |
| 405 | | else {KbRepeatTable[0x8A]=0;} |
| 406 | | if (shiftKey && !controlKey && !(keyboard[6] & 0x04)) addToKeyboardBuffer(0x8B); /* shiftKey + III */ |
| 407 | | else {KbRepeatTable[0x8B]=0;} |
| 408 | | if (shiftKey && !controlKey && !(keyboard[6] & 0x08)) addToKeyboardBuffer(0x8C); /* shiftKey + IV */ |
| 409 | | else {KbRepeatTable[0x8C]=0;} |
| 410 | | if (shiftKey && !controlKey && !(keyboard[6] & 0x10)) addToKeyboardBuffer(0x8D); /* shiftKey + V */ |
| 411 | | else {KbRepeatTable[0x8D]=0;} |
| 412 | | if (shiftKey && !controlKey && !(keyboard[6] & 0x20)) addToKeyboardBuffer(0x8E); /* shiftKey + VI */ |
| 413 | | else {KbRepeatTable[0x8E]=0;} |
| 396 | if (shiftKey && !controlKey && !(keyboard[6] & 0x01)) addToKeyboardBuffer(state, 0x89); /* shiftKey + I */ |
| 397 | else {state->KbRepeatTable[0x89]=0;} |
| 398 | if (shiftKey && !controlKey && !(keyboard[6] & 0x02)) addToKeyboardBuffer(state, 0x8A); /* shiftKey + II */ |
| 399 | else {state->KbRepeatTable[0x8A]=0;} |
| 400 | if (shiftKey && !controlKey && !(keyboard[6] & 0x04)) addToKeyboardBuffer(state, 0x8B); /* shiftKey + III */ |
| 401 | else {state->KbRepeatTable[0x8B]=0;} |
| 402 | if (shiftKey && !controlKey && !(keyboard[6] & 0x08)) addToKeyboardBuffer(state, 0x8C); /* shiftKey + IV */ |
| 403 | else {state->KbRepeatTable[0x8C]=0;} |
| 404 | if (shiftKey && !controlKey && !(keyboard[6] & 0x10)) addToKeyboardBuffer(state, 0x8D); /* shiftKey + V */ |
| 405 | else {state->KbRepeatTable[0x8D]=0;} |
| 406 | if (shiftKey && !controlKey && !(keyboard[6] & 0x20)) addToKeyboardBuffer(state, 0x8E); /* shiftKey + VI */ |
| 407 | else {state->KbRepeatTable[0x8E]=0;} |
| 414 | 408 | /* 0x8F - Unused */ |
| 415 | 409 | |
| 416 | | if (!shiftKey && !(keyboard[7] & 0x01)) addToKeyboardBuffer(0x90); /* WILD CARD */ |
| 417 | | else {KbRepeatTable[0x90]=0;} |
| 418 | | if (!shiftKey && !(keyboard[7] & 0x02)) addToKeyboardBuffer(0x91); /* UNDO */ |
| 419 | | else {KbRepeatTable[0x91]=0;} |
| 420 | | if (!shiftKey && !(keyboard[7] & 0x04)) addToKeyboardBuffer(0x92); /* MOVE */ |
| 421 | | else {KbRepeatTable[0x92]=0;} |
| 422 | | if (!shiftKey && !(keyboard[7] & 0x08)) addToKeyboardBuffer(0x93); /* STORE */ |
| 423 | | else {KbRepeatTable[0x93]=0;} |
| 424 | | if (!shiftKey && !(keyboard[7] & 0x10)) addToKeyboardBuffer(0x94); /* INSERT */ |
| 425 | | else {KbRepeatTable[0x94]=0;} |
| 426 | | if (!shiftKey && !(keyboard[7] & 0x20)) addToKeyboardBuffer(0x95); /* PRINT */ |
| 427 | | else {KbRepeatTable[0x95]=0;} |
| 428 | | if (!shiftKey && !(keyboard[7] & 0x40)) addToKeyboardBuffer(0x96); /* CLEAR */ |
| 429 | | else {KbRepeatTable[0x96]=0;} |
| 430 | | if (!shiftKey && !(keyboard[7] & 0x80)) addToKeyboardBuffer(0x97); /* DELETE */ |
| 431 | | else {KbRepeatTable[0x97]=0;} |
| 410 | if (!shiftKey && !(keyboard[7] & 0x01)) addToKeyboardBuffer(state, 0x90); /* WILD CARD */ |
| 411 | else {state->KbRepeatTable[0x90]=0;} |
| 412 | if (!shiftKey && !(keyboard[7] & 0x02)) addToKeyboardBuffer(state, 0x91); /* UNDO */ |
| 413 | else {state->KbRepeatTable[0x91]=0;} |
| 414 | if (!shiftKey && !(keyboard[7] & 0x04)) addToKeyboardBuffer(state, 0x92); /* MOVE */ |
| 415 | else {state->KbRepeatTable[0x92]=0;} |
| 416 | if (!shiftKey && !(keyboard[7] & 0x08)) addToKeyboardBuffer(state, 0x93); /* STORE */ |
| 417 | else {state->KbRepeatTable[0x93]=0;} |
| 418 | if (!shiftKey && !(keyboard[7] & 0x10)) addToKeyboardBuffer(state, 0x94); /* INSERT */ |
| 419 | else {state->KbRepeatTable[0x94]=0;} |
| 420 | if (!shiftKey && !(keyboard[7] & 0x20)) addToKeyboardBuffer(state, 0x95); /* PRINT */ |
| 421 | else {state->KbRepeatTable[0x95]=0;} |
| 422 | if (!shiftKey && !(keyboard[7] & 0x40)) addToKeyboardBuffer(state, 0x96); /* CLEAR */ |
| 423 | else {state->KbRepeatTable[0x96]=0;} |
| 424 | if (!shiftKey && !(keyboard[7] & 0x80)) addToKeyboardBuffer(state, 0x97); /* DELETE */ |
| 425 | else {state->KbRepeatTable[0x97]=0;} |
| 432 | 426 | |
| 433 | | if (shiftKey && !controlKey && !(keyboard[7] & 0x01)) addToKeyboardBuffer(0x98); /* shiftKey + WILD CARD */ |
| 434 | | else {KbRepeatTable[0x98]=0;} |
| 435 | | if (shiftKey && !controlKey && !(keyboard[7] & 0x02)) addToKeyboardBuffer(0x99); /* shiftKey + UNDO */ |
| 436 | | else {KbRepeatTable[0x99]=0;} |
| 437 | | if (shiftKey && !controlKey && !(keyboard[7] & 0x04)) addToKeyboardBuffer(0x9A); /* shiftKey + MOVE */ |
| 438 | | else {KbRepeatTable[0x9A]=0;} |
| 439 | | if (shiftKey && !controlKey && !(keyboard[7] & 0x08)) addToKeyboardBuffer(0x9B); /* shiftKey + STORE */ |
| 440 | | else {KbRepeatTable[0x9B]=0;} |
| 441 | | if (shiftKey && !controlKey && !(keyboard[7] & 0x10)) addToKeyboardBuffer(0x9C); /* shiftKey + INSERT */ |
| 442 | | else {KbRepeatTable[0x9C]=0;} |
| 443 | | if (shiftKey && !controlKey && !(keyboard[7] & 0x20)) addToKeyboardBuffer(0x9D); /* shiftKey + PRINT */ |
| 444 | | else {KbRepeatTable[0x9D]=0;} |
| 445 | | if (shiftKey && !controlKey && !(keyboard[7] & 0x40)) addToKeyboardBuffer(0x9E); /* shiftKey + CLEAR */ |
| 446 | | else {KbRepeatTable[0x9E]=0;} |
| 447 | | if (shiftKey && !controlKey && !(keyboard[7] & 0x80)) addToKeyboardBuffer(0x9F); /* shiftKey + DELETE */ |
| 448 | | else {KbRepeatTable[0x9F]=0;} |
| 427 | if (shiftKey && !controlKey && !(keyboard[7] & 0x01)) addToKeyboardBuffer(state, 0x98); /* shiftKey + WILD CARD */ |
| 428 | else {state->KbRepeatTable[0x98]=0;} |
| 429 | if (shiftKey && !controlKey && !(keyboard[7] & 0x02)) addToKeyboardBuffer(state, 0x99); /* shiftKey + UNDO */ |
| 430 | else {state->KbRepeatTable[0x99]=0;} |
| 431 | if (shiftKey && !controlKey && !(keyboard[7] & 0x04)) addToKeyboardBuffer(state, 0x9A); /* shiftKey + MOVE */ |
| 432 | else {state->KbRepeatTable[0x9A]=0;} |
| 433 | if (shiftKey && !controlKey && !(keyboard[7] & 0x08)) addToKeyboardBuffer(state, 0x9B); /* shiftKey + STORE */ |
| 434 | else {state->KbRepeatTable[0x9B]=0;} |
| 435 | if (shiftKey && !controlKey && !(keyboard[7] & 0x10)) addToKeyboardBuffer(state, 0x9C); /* shiftKey + INSERT */ |
| 436 | else {state->KbRepeatTable[0x9C]=0;} |
| 437 | if (shiftKey && !controlKey && !(keyboard[7] & 0x20)) addToKeyboardBuffer(state, 0x9D); /* shiftKey + PRINT */ |
| 438 | else {state->KbRepeatTable[0x9D]=0;} |
| 439 | if (shiftKey && !controlKey && !(keyboard[7] & 0x40)) addToKeyboardBuffer(state, 0x9E); /* shiftKey + CLEAR */ |
| 440 | else {state->KbRepeatTable[0x9E]=0;} |
| 441 | if (shiftKey && !controlKey && !(keyboard[7] & 0x80)) addToKeyboardBuffer(state, 0x9F); /* shiftKey + DELETE */ |
| 442 | else {state->KbRepeatTable[0x9F]=0;} |
| 449 | 443 | |
| 450 | | if (!controlKey && !(keyboard[8] & 0x02)) addToKeyboardBuffer(0xA0); /* UP ARROW */ |
| 451 | | else {KbRepeatTable[0xA0]=0;} |
| 452 | | if (!controlKey && !(keyboard[8] & 0x10)) addToKeyboardBuffer(0xA1); /* RIGHT ARROW */ |
| 453 | | else {KbRepeatTable[0xA1]=0;} |
| 454 | | if (!controlKey && !(keyboard[8] & 0x04)) addToKeyboardBuffer(0xA2); /* DOWN ARROW */ |
| 455 | | else {KbRepeatTable[0xA2]=0;} |
| 456 | | if (!controlKey && !(keyboard[8] & 0x08)) addToKeyboardBuffer(0xA3); /* LEFT ARROW */ |
| 457 | | else {KbRepeatTable[0xA3]=0;} |
| 458 | | if (controlKey && !shiftKey && !(keyboard[8] & 0x02)) addToKeyboardBuffer(0xA4); /* controlKey + UP ARROW */ |
| 459 | | else {KbRepeatTable[0xA4]=0;} |
| 460 | | if (controlKey && !shiftKey && !(keyboard[8] & 0x10)) addToKeyboardBuffer(0xA5); /* controlKey + RIGHT ARROW */ |
| 461 | | else {KbRepeatTable[0xA5]=0;} |
| 462 | | if (controlKey && !shiftKey && !(keyboard[8] & 0x04)) addToKeyboardBuffer(0xA6); /* controlKey + DOWN ARROW */ |
| 463 | | else {KbRepeatTable[0xA6]=0;} |
| 464 | | if (controlKey && !shiftKey && !(keyboard[8] & 0x08)) addToKeyboardBuffer(0xA7); /* controlKey + LEFT ARROW */ |
| 465 | | else {KbRepeatTable[0xA7]=0;} |
| 444 | if (!controlKey && !(keyboard[8] & 0x02)) addToKeyboardBuffer(state, 0xA0); /* UP ARROW */ |
| 445 | else {state->KbRepeatTable[0xA0]=0;} |
| 446 | if (!controlKey && !(keyboard[8] & 0x10)) addToKeyboardBuffer(state, 0xA1); /* RIGHT ARROW */ |
| 447 | else {state->KbRepeatTable[0xA1]=0;} |
| 448 | if (!controlKey && !(keyboard[8] & 0x04)) addToKeyboardBuffer(state, 0xA2); /* DOWN ARROW */ |
| 449 | else {state->KbRepeatTable[0xA2]=0;} |
| 450 | if (!controlKey && !(keyboard[8] & 0x08)) addToKeyboardBuffer(state, 0xA3); /* LEFT ARROW */ |
| 451 | else {state->KbRepeatTable[0xA3]=0;} |
| 452 | if (controlKey && !shiftKey && !(keyboard[8] & 0x02)) addToKeyboardBuffer(state, 0xA4); /* controlKey + UP ARROW */ |
| 453 | else {state->KbRepeatTable[0xA4]=0;} |
| 454 | if (controlKey && !shiftKey && !(keyboard[8] & 0x10)) addToKeyboardBuffer(state, 0xA5); /* controlKey + RIGHT ARROW */ |
| 455 | else {state->KbRepeatTable[0xA5]=0;} |
| 456 | if (controlKey && !shiftKey && !(keyboard[8] & 0x04)) addToKeyboardBuffer(state, 0xA6); /* controlKey + DOWN ARROW */ |
| 457 | else {state->KbRepeatTable[0xA6]=0;} |
| 458 | if (controlKey && !shiftKey && !(keyboard[8] & 0x08)) addToKeyboardBuffer(state, 0xA7); /* controlKey + LEFT ARROW */ |
| 459 | else {state->KbRepeatTable[0xA7]=0;} |
| 466 | 460 | |
| 467 | | if (!controlKey && !(keyboard[8] & 0x02) && !(keyboard[8] & 0x10)) addToKeyboardBuffer(0xA8); /* UP ARROW + RIGHT ARROW */ |
| 468 | | else {KbRepeatTable[0xA8]=0;} |
| 469 | | if (!controlKey && !(keyboard[8] & 0x10) && !(keyboard[8] & 0x04)) addToKeyboardBuffer(0xA9); /* RIGHT ARROW + DOWN ARROW */ |
| 470 | | else {KbRepeatTable[0xA9]=0;} |
| 471 | | if (!controlKey && !(keyboard[8] & 0x04) && !(keyboard[8] & 0x08)) addToKeyboardBuffer(0xAA); /* DOWN ARROW + LEFT ARROW */ |
| 472 | | else {KbRepeatTable[0xAA]=0;} |
| 473 | | if (!controlKey && !(keyboard[8] & 0x08) && !(keyboard[8] & 0x02)) addToKeyboardBuffer(0xAB); /* LEFT ARROW + UP ARROW */ |
| 474 | | else {KbRepeatTable[0xAB]=0;} |
| 475 | | if (!controlKey && !(keyboard[8] & 0x01) && !(keyboard[8] & 0x02)) addToKeyboardBuffer(0xAC); /* HOME + UP ARROW */ |
| 476 | | else {KbRepeatTable[0xAC]=0;} |
| 477 | | if (!controlKey && !(keyboard[8] & 0x01) && !(keyboard[8] & 0x10)) addToKeyboardBuffer(0xAD); /* HOME + RIGHT ARROW */ |
| 478 | | else {KbRepeatTable[0xAD]=0;} |
| 479 | | if (!controlKey && !(keyboard[8] & 0x01) && !(keyboard[8] & 0x04)) addToKeyboardBuffer(0xAE); /* HOME + DOWN ARROW */ |
| 480 | | else {KbRepeatTable[0xAE]=0;} |
| 481 | | if (!controlKey && !(keyboard[8] & 0x01) && !(keyboard[8] & 0x08)) addToKeyboardBuffer(0xAF); /* HOME + LEFT ARROW */ |
| 482 | | else {KbRepeatTable[0xAF]=0;} |
| 461 | if (!controlKey && !(keyboard[8] & 0x02) && !(keyboard[8] & 0x10)) addToKeyboardBuffer(state, 0xA8); /* UP ARROW + RIGHT ARROW */ |
| 462 | else {state->KbRepeatTable[0xA8]=0;} |
| 463 | if (!controlKey && !(keyboard[8] & 0x10) && !(keyboard[8] & 0x04)) addToKeyboardBuffer(state, 0xA9); /* RIGHT ARROW + DOWN ARROW */ |
| 464 | else {state->KbRepeatTable[0xA9]=0;} |
| 465 | if (!controlKey && !(keyboard[8] & 0x04) && !(keyboard[8] & 0x08)) addToKeyboardBuffer(state, 0xAA); /* DOWN ARROW + LEFT ARROW */ |
| 466 | else {state->KbRepeatTable[0xAA]=0;} |
| 467 | if (!controlKey && !(keyboard[8] & 0x08) && !(keyboard[8] & 0x02)) addToKeyboardBuffer(state, 0xAB); /* LEFT ARROW + UP ARROW */ |
| 468 | else {state->KbRepeatTable[0xAB]=0;} |
| 469 | if (!controlKey && !(keyboard[8] & 0x01) && !(keyboard[8] & 0x02)) addToKeyboardBuffer(state, 0xAC); /* HOME + UP ARROW */ |
| 470 | else {state->KbRepeatTable[0xAC]=0;} |
| 471 | if (!controlKey && !(keyboard[8] & 0x01) && !(keyboard[8] & 0x10)) addToKeyboardBuffer(state, 0xAD); /* HOME + RIGHT ARROW */ |
| 472 | else {state->KbRepeatTable[0xAD]=0;} |
| 473 | if (!controlKey && !(keyboard[8] & 0x01) && !(keyboard[8] & 0x04)) addToKeyboardBuffer(state, 0xAE); /* HOME + DOWN ARROW */ |
| 474 | else {state->KbRepeatTable[0xAE]=0;} |
| 475 | if (!controlKey && !(keyboard[8] & 0x01) && !(keyboard[8] & 0x08)) addToKeyboardBuffer(state, 0xAF); /* HOME + LEFT ARROW */ |
| 476 | else {state->KbRepeatTable[0xAF]=0;} |
| 483 | 477 | |
| 484 | 478 | /* 0xB0-0xB7 - Unused */ |
| 485 | 479 | |
| 486 | | if (shiftKey && !controlKey && !(keyboard[9] & 0x02)) addToKeyboardBuffer(0xB8); /* shiftKey + BACKSPACE */ |
| 487 | | else {KbRepeatTable[0xB8]=0;} |
| 488 | | if (shiftKey && !controlKey && !(keyboard[8] & 0x20)) addToKeyboardBuffer(0xB9); /* shiftKey + TAB */ |
| 489 | | else {KbRepeatTable[0xB9]=0;} |
| 480 | if (shiftKey && !controlKey && !(keyboard[9] & 0x02)) addToKeyboardBuffer(state, 0xB8); /* shiftKey + BACKSPACE */ |
| 481 | else {state->KbRepeatTable[0xB8]=0;} |
| 482 | if (shiftKey && !controlKey && !(keyboard[8] & 0x20)) addToKeyboardBuffer(state, 0xB9); /* shiftKey + TAB */ |
| 483 | else {state->KbRepeatTable[0xB9]=0;} |
| 490 | 484 | /* 0xBA-0xEF - Unused */ |
| 491 | 485 | |
| 492 | 486 | /* 0xF0-0xFF - Reserved for internal use by keyboard software */ |
| r9648 | r9649 | |
| 494 | 488 | |
| 495 | 489 | static void master6801_behaviour(running_machine *machine, int offset, int data) |
| 496 | 490 | { |
| 491 | adam_state *state = machine->driver_data<adam_state>(); |
| 497 | 492 | /* |
| 498 | 493 | The Master MC6801 controls all AdamNet operations, keyboard, tapes, disks... |
| 499 | 494 | We are going to "simulate" the behaviour of the master 6801, because we does not have the 2kbytes ROM DUMP |
| r9648 | r9649 | |
| 507 | 502 | UINT8 *ram; |
| 508 | 503 | |
| 509 | 504 | ram = memory_region(machine, "maincpu"); |
| 510 | | if (offset == adam_pcb) |
| 505 | if (offset == state->pcb) |
| 511 | 506 | { |
| 512 | 507 | switch (data) |
| 513 | 508 | { |
| r9648 | r9649 | |
| 519 | 514 | ram[offset] = 0x82; |
| 520 | 515 | //logerror("Synchronizing the Master 6801 clock\n"); |
| 521 | 516 | break; |
| 522 | | case 3: /* Request to relocate adam_pcb */ |
| 517 | case 3: /* Request to relocate state->pcb */ |
| 523 | 518 | ram[offset] = 0x83; /* Must return 0x83 if success */ |
| 524 | 519 | //ram[offset] = 0x9B; /* Time Out */ |
| 525 | | logerror("Request to relocate adam_pcb from %04Xh to %04Xh... not implemented... but returns OK\n", adam_pcb, (ram[adam_pcb+1]|ram[adam_pcb+2]<<8)); |
| 520 | logerror("Request to relocate state->pcb from %04Xh to %04Xh... not implemented... but returns OK\n", state->pcb, (ram[state->pcb+1]|ram[state->pcb+2]<<8)); |
| 526 | 521 | break; |
| 527 | 522 | } |
| 528 | 523 | } |
| 529 | 524 | |
| 530 | | for(DCB_Num=1;DCB_Num<=ram[adam_pcb+3];DCB_Num++) /* Test status of each DCB in adam_pcb table */ |
| 525 | for(DCB_Num=1;DCB_Num<=ram[state->pcb+3];DCB_Num++) /* Test status of each DCB in state->pcb table */ |
| 531 | 526 | { |
| 532 | | statusDCB = (adam_pcb+4)+(DCB_Num-1)*21; |
| 527 | statusDCB = (state->pcb+4)+(DCB_Num-1)*21; |
| 533 | 528 | if (offset==statusDCB) |
| 534 | 529 | { |
| 535 | 530 | //logerror("Accesing DCB %02Xh\n", DCB_Num); |
| r9648 | r9649 | |
| 609 | 604 | */ |
| 610 | 605 | if (deviceNum==1) |
| 611 | 606 | { |
| 612 | | kbcode=getKeyFromBuffer(); |
| 607 | kbcode=getKeyFromBuffer(state); |
| 613 | 608 | if (kbcode>0) |
| 614 | 609 | { |
| 615 | 610 | ram[buffer] = kbcode; /* Key pressed */ |
| r9648 | r9649 | |
| 663 | 658 | |
| 664 | 659 | WRITE8_HANDLER( adam_common_writes_w ) |
| 665 | 660 | { |
| 666 | | switch (adam_upper_memory) |
| 661 | adam_state *state = space->machine->driver_data<adam_state>(); |
| 662 | switch (state->upper_memory) |
| 667 | 663 | { |
| 668 | 664 | case 0: /* Internal RAM */ |
| 669 | 665 | memory_region(space->machine, "maincpu")[0x08000+offset] = data; |
| 670 | | if (offset>=(adam_pcb-0x08000)) master6801_behaviour(space->machine, offset+0x08000, data); |
| 666 | if (offset>=(state->pcb-0x08000)) master6801_behaviour(space->machine, offset+0x08000, data); |
| 671 | 667 | break; |
| 672 | 668 | case 1: /* ROM Expansion */ |
| 673 | 669 | break; |
| r9648 | r9649 | |
| 681 | 677 | |
| 682 | 678 | READ8_HANDLER( adamnet_r ) |
| 683 | 679 | { |
| 684 | | //logerror("adam_net_data Read %2xh\n",adam_net_data); |
| 685 | | return adam_net_data; |
| 680 | adam_state *state = space->machine->driver_data<adam_state>(); |
| 681 | //logerror("adam_net_data Read %2xh\n",state->net_data); |
| 682 | return state->net_data; |
| 686 | 683 | } |
| 687 | 684 | |
| 688 | 685 | WRITE8_HANDLER( adamnet_w ) |
| 689 | 686 | { |
| 687 | adam_state *state = space->machine->driver_data<adam_state>(); |
| 690 | 688 | /* |
| 691 | 689 | If SmartWriter ROM is selected on lower Z80 memory |
| 692 | 690 | if data bit1 is 1 -> Lower 32k = EOS otherwise Lower 32k = SmartWriter |
| r9648 | r9649 | |
| 696 | 694 | |
| 697 | 695 | if (data==0x0F) |
| 698 | 696 | adam_reset_pcb(space->machine); |
| 699 | | if ( (adam_lower_memory==0) && ((data&0x02)!=(adam_net_data&0x02)) ) |
| 697 | if ( (state->lower_memory==0) && ((data&0x02)!=(state->net_data&0x02)) ) |
| 700 | 698 | { |
| 701 | 699 | if (data&0x02) |
| 702 | 700 | { |
| r9648 | r9649 | |
| 723 | 721 | memory_set_bankptr(space->machine, "bank9", BankBase+0x3A000); /* Write protecting ROM */ |
| 724 | 722 | } |
| 725 | 723 | } |
| 726 | | adam_net_data = data; |
| 724 | state->net_data = data; |
| 727 | 725 | } |
| 728 | 726 | |
| 729 | 727 | READ8_HANDLER( adam_memory_map_controller_r ) |
| 730 | 728 | { |
| 731 | | return (adam_upper_memory << 2) + adam_lower_memory; |
| 729 | adam_state *state = space->machine->driver_data<adam_state>(); |
| 730 | return (state->upper_memory << 2) + state->lower_memory; |
| 732 | 731 | } |
| 733 | 732 | |
| 734 | 733 | WRITE8_HANDLER( adam_memory_map_controller_w ) |
| 735 | 734 | { |
| 735 | adam_state *state = space->machine->driver_data<adam_state>(); |
| 736 | 736 | /* |
| 737 | 737 | Writes to ports 0x60 to 0x7F set memory map: |
| 738 | 738 | |
| r9648 | r9649 | |
| 752 | 752 | |
| 753 | 753 | */ |
| 754 | 754 | |
| 755 | | adam_lower_memory = (data & 0x03); |
| 756 | | adam_upper_memory = (data & 0x0C)>>2; |
| 755 | state->lower_memory = (data & 0x03); |
| 756 | state->upper_memory = (data & 0x0C)>>2; |
| 757 | 757 | adam_set_memory_banks(space->machine); |
| 758 | | //logerror("Configurando la memoria, L:%02xh, U:%02xh\n", adam_lower_memory, adam_upper_memory); |
| 758 | //logerror("Configurando la memoria, L:%02xh, U:%02xh\n", state->lower_memory, state->upper_memory); |
| 759 | 759 | } |
| 760 | 760 | |
| 761 | 761 | READ8_HANDLER(adam_video_r) |
| r9648 | r9649 | |
| 783 | 783 | |
| 784 | 784 | READ8_HANDLER ( adam_paddle_r ) |
| 785 | 785 | { |
| 786 | adam_state *state = space->machine->driver_data<adam_state>(); |
| 786 | 787 | |
| 787 | 788 | if (!(input_port_read(space->machine, "controllers") & 0x0F)) return (0xFF); /* If no controllers enabled */ |
| 788 | 789 | /* Player 1 */ |
| 789 | 790 | if ((offset & 0x02)==0) |
| 790 | 791 | { |
| 791 | 792 | /* Keypad and fire 1 (SAC Yellow Button) */ |
| 792 | | if (joy_mode==0) |
| 793 | if (state->joy_mode==0) |
| 793 | 794 | { |
| 794 | 795 | int inport0,inport1,inport6,data; |
| 795 | 796 | |
| r9648 | r9649 | |
| 827 | 828 | |
| 828 | 829 | if (inport6&0x07) /* If Extra Contollers enabled */ |
| 829 | 830 | { |
| 830 | | if (adam_joy_stat[0]==0) |
| 831 | if (state->joy_stat[0]==0) |
| 831 | 832 | data |= 0x30; /* Spinner Move Left */ |
| 832 | | else if (adam_joy_stat[0]==1) |
| 833 | else if (state->joy_stat[0]==1) |
| 833 | 834 | data |= 0x20; /* Spinner Move Right */ |
| 834 | 835 | } |
| 835 | 836 | return data | 0x80; |
| r9648 | r9649 | |
| 839 | 840 | else |
| 840 | 841 | { |
| 841 | 842 | /* Keypad and fire 1 */ |
| 842 | | if (joy_mode==0) |
| 843 | if (state->joy_mode==0) |
| 843 | 844 | { |
| 844 | 845 | int inport3,inport4,data; |
| 845 | 846 | |
| r9648 | r9649 | |
| 874 | 875 | |
| 875 | 876 | if (inport6&0x02) /* If Roller Controller enabled */ |
| 876 | 877 | { |
| 877 | | if (adam_joy_stat[1]==0) data|=0x30; |
| 878 | | else if (adam_joy_stat[1]==1) data|=0x20; |
| 878 | if (state->joy_stat[1]==0) data|=0x30; |
| 879 | else if (state->joy_stat[1]==1) data|=0x20; |
| 879 | 880 | } |
| 880 | 881 | |
| 881 | 882 | return data | 0x80; |
| r9648 | r9649 | |
| 887 | 888 | |
| 888 | 889 | WRITE8_HANDLER ( adam_paddle_toggle_off ) |
| 889 | 890 | { |
| 890 | | joy_mode = 0; |
| 891 | | return; |
| 891 | adam_state *state = space->machine->driver_data<adam_state>(); |
| 892 | state->joy_mode = 0; |
| 892 | 893 | } |
| 893 | 894 | |
| 894 | 895 | WRITE8_HANDLER ( adam_paddle_toggle_on ) |
| 895 | 896 | { |
| 896 | | joy_mode = 1; |
| 897 | | return; |
| 897 | adam_state *state = space->machine->driver_data<adam_state>(); |
| 898 | state->joy_mode = 1; |
| 898 | 899 | } |
src/mess/machine/amstrad.c
| r9648 | r9649 | |
| 68 | 68 | 0xff, 0x77, 0xb3, 0x51, 0xa8, 0xd4, 0x62, 0x39, 0x9c, 0x46, 0x2b, 0x15, 0x8a, 0xcd, 0xee |
| 69 | 69 | }; |
| 70 | 70 | |
| 71 | | static int amstrad_system_type; |
| 72 | | static UINT8 aleste_mode; |
| 73 | | static int amstrad_plus_irq_cause; // part of the interrupt vector for IM 2. 6 = raster IRQ, 4 = DMA channel 2, 2 = DMA channel 1, 0 = DMA channel 0 |
| 74 | 71 | |
| 75 | 72 | |
| 76 | | /**************************** |
| 77 | | * Gate Array data (CPC) - |
| 78 | | ****************************/ |
| 79 | | static struct { |
| 80 | | bitmap_t *bitmap; /* The bitmap we work on */ |
| 81 | | UINT8 pen_selected; /* Pen selection */ |
| 82 | | UINT8 mrer; /* Mode and ROM Enable Register */ |
| 83 | | UINT8 upper_bank; |
| 84 | 73 | |
| 85 | | /* input signals from CRTC */ |
| 86 | | int vsync; |
| 87 | | int hsync; |
| 88 | | int de; |
| 89 | | int ma; |
| 90 | | int ra; |
| 91 | 74 | |
| 92 | | /* used for timing */ |
| 93 | | int hsync_after_vsync_counter; |
| 94 | | int hsync_counter; /* The gate array counts CRTC HSYNC pulses using an internal 6-bit counter. */ |
| 95 | | |
| 96 | | /* used for drawing the screen */ |
| 97 | | attotime last_draw_time; |
| 98 | | int y; |
| 99 | | UINT16 *draw_p; /* Position in the bitmap where we are currently drawing */ |
| 100 | | UINT16 colour; |
| 101 | | UINT16 address; |
| 102 | | UINT8 *mode_lookup; |
| 103 | | UINT8 data; |
| 104 | | UINT8 ticks; |
| 105 | | UINT8 ticks_increment; |
| 106 | | UINT16 line_ticks; |
| 107 | | UINT8 colour_ticks; |
| 108 | | UINT8 max_colour_ticks; |
| 109 | | } gate_array; |
| 110 | | |
| 111 | | |
| 112 | | /**************************** |
| 113 | | * ASIC data (CPC plus) |
| 114 | | ****************************/ |
| 115 | | static struct { |
| 116 | | UINT8 *ram; /* pointer to RAM used for the CPC+ ASIC memory-mapped registers */ |
| 117 | | UINT8 enabled; /* Are CPC plus features enabled/unlocked */ |
| 118 | | UINT8 pri; /* Programmable raster interrupt */ |
| 119 | | UINT8 seqptr; /* Current position in the ASIC unlocking sequence */ |
| 120 | | UINT8 rmr2; /* ROM mapping register 2 */ |
| 121 | | UINT16 split_ma_base; /* Used to handle split screen support */ |
| 122 | | UINT16 split_ma_started; /* Used to handle split screen support */ |
| 123 | | UINT16 vpos; /* Current logical scanline */ |
| 124 | | UINT16 h_start; /* Position where DE became active */ |
| 125 | | UINT16 h_end; /* Position where DE became inactive */ |
| 126 | | UINT8 addr_6845; /* We need these to store a shadow copy of R1 of the mc6845 */ |
| 127 | | UINT8 horiz_disp; |
| 128 | | UINT8 hscroll; |
| 129 | | UINT8 de_start; /* flag to check if DE is been enabled this frame yet */ |
| 130 | | |
| 131 | | /* DMA */ |
| 132 | | UINT8 dma_status; |
| 133 | | UINT8 dma_clear; /* Set if DMA interrupts are to be cleared automatically */ |
| 134 | | UINT8 dma_prescaler[3]; /* DMA channel prescaler */ |
| 135 | | UINT16 dma_repeat[3]; /* Location of the DMA channel's last repeat */ |
| 136 | | UINT16 dma_addr[3]; /* DMA channel address */ |
| 137 | | UINT16 dma_loopcount[3]; /* Count loops taken on this channel */ |
| 138 | | UINT16 dma_pause[3]; /* DMA pause count */ |
| 139 | | } asic; |
| 140 | | |
| 141 | | |
| 142 | 75 | /* Ram configuration */ |
| 143 | | static int amstrad_GateArray_RamConfiguration = 0; |
| 144 | 76 | |
| 145 | 77 | /* pointers to current ram configuration selected for banks */ |
| 146 | | static unsigned char *AmstradCPC_RamBanks[4]; |
| 147 | | static unsigned char *Aleste_RamBanks[4]; |
| 148 | | static int aleste_active_page[4]; // page mapped to CPU RAM (is readable?) |
| 149 | 78 | |
| 150 | 79 | /* the hardware allows selection of 256 ROMs. Rom 0 is usually BASIC and Rom 7 is AMSDOS */ |
| 151 | 80 | /* With the CPC hardware, if a expansion ROM is not connected, BASIC rom will be selected instead */ |
| 152 | | static unsigned char *Amstrad_ROM_Table[256]; |
| 153 | 81 | /* data present on input of ppi, and data written to ppi output */ |
| 154 | 82 | #define amstrad_ppi_PortA 0 |
| 155 | 83 | #define amstrad_ppi_PortB 1 |
| 156 | 84 | #define amstrad_ppi_PortC 2 |
| 157 | 85 | |
| 158 | | static UINT8 ppi_port_inputs[3]; |
| 159 | | static UINT8 ppi_port_outputs[3]; |
| 160 | 86 | |
| 161 | | static int aleste_rtc_function; |
| 162 | | static int aleste_fdc_int; |
| 163 | 87 | |
| 164 | 88 | /*------------------ |
| 165 | 89 | - Ram Management - |
| r9648 | r9649 | |
| 179 | 103 | }; |
| 180 | 104 | |
| 181 | 105 | |
| 182 | | static int prev_reg; |
| 183 | 106 | |
| 184 | 107 | //static int amstrad_CRTC_CR = 0; /* CR = Cursor Enabled */ |
| 185 | 108 | |
| r9648 | r9649 | |
| 187 | 110 | /* this is updated from the eventlist and reflects the current state |
| 188 | 111 | of the render colours - these may be different to the current colour palette values */ |
| 189 | 112 | /* colours can be changed at any time and will take effect immediatly */ |
| 190 | | static UINT16 amstrad_GateArray_render_colours[17]; |
| 191 | 113 | |
| 192 | | static UINT8 mode0_lookup[256]; |
| 193 | | static UINT8 mode1_lookup[256]; |
| 194 | | static UINT8 mode2_lookup[256]; |
| 195 | 114 | |
| 196 | 115 | |
| 197 | 116 | /* The Amstrad CPC has a fixed palette of 27 colours generated from 3 levels of Red, Green and Blue. |
| r9648 | r9649 | |
| 296 | 215 | |
| 297 | 216 | WRITE_LINE_DEVICE_HANDLER( aleste_interrupt ) |
| 298 | 217 | { |
| 218 | amstrad_state *drvstate = device->machine->driver_data<amstrad_state>(); |
| 299 | 219 | if(state == CLEAR_LINE) |
| 300 | | aleste_fdc_int = 0; |
| 220 | drvstate->aleste_fdc_int = 0; |
| 301 | 221 | else |
| 302 | | aleste_fdc_int = 1; |
| 222 | drvstate->aleste_fdc_int = 1; |
| 303 | 223 | } |
| 304 | 224 | |
| 305 | 225 | |
| r9648 | r9649 | |
| 444 | 364 | } |
| 445 | 365 | |
| 446 | 366 | |
| 447 | | static void amstrad_init_lookups(void) |
| 367 | static void amstrad_init_lookups( amstrad_state *state ) |
| 448 | 368 | { |
| 449 | 369 | int i; |
| 450 | 370 | |
| 451 | 371 | for ( i = 0; i < 256; i++ ) |
| 452 | 372 | { |
| 453 | | mode0_lookup[i] = ( ( i & 0x80 ) >> 7 ) | ( ( i & 0x20 ) >> 3 ) | ( ( i & 0x08 ) >> 2 ) | ( ( i & 0x02 ) << 2 ); |
| 454 | | mode1_lookup[i] = ( ( i & 0x80 ) >> 7 ) | ( ( i & 0x08 ) >> 2 ); |
| 455 | | mode2_lookup[i] = ( ( i & 0x80 ) >> 7 ); |
| 373 | state->mode0_lookup[i] = ( ( i & 0x80 ) >> 7 ) | ( ( i & 0x20 ) >> 3 ) | ( ( i & 0x08 ) >> 2 ) | ( ( i & 0x02 ) << 2 ); |
| 374 | state->mode1_lookup[i] = ( ( i & 0x80 ) >> 7 ) | ( ( i & 0x08 ) >> 2 ); |
| 375 | state->mode2_lookup[i] = ( ( i & 0x80 ) >> 7 ); |
| 456 | 376 | } |
| 457 | 377 | } |
| 458 | 378 | |
| 459 | 379 | |
| 460 | 380 | /* Set the new screen mode (0,1,2,4) from the GateArray */ |
| 461 | | static void amstrad_vh_update_mode( void ) |
| 381 | static void amstrad_vh_update_mode( amstrad_state *state ) |
| 462 | 382 | { |
| 463 | | if ( amstrad_system_type == SYSTEM_PLUS || amstrad_system_type == SYSTEM_GX4000 ) |
| 383 | if ( state->system_type == SYSTEM_PLUS || state->system_type == SYSTEM_GX4000 ) |
| 464 | 384 | { |
| 465 | 385 | /* select a cpc plus mode */ |
| 466 | | switch ( gate_array.mrer & 0x03 ) |
| 386 | switch ( state->gate_array.mrer & 0x03 ) |
| 467 | 387 | { |
| 468 | 388 | case 0: /* Mode 0: 160x200, 16 colours */ |
| 469 | | gate_array.mode_lookup = mode0_lookup; |
| 470 | | gate_array.max_colour_ticks = 4; |
| 471 | | gate_array.ticks_increment = 1; |
| 389 | state->gate_array.mode_lookup = state->mode0_lookup; |
| 390 | state->gate_array.max_colour_ticks = 4; |
| 391 | state->gate_array.ticks_increment = 1; |
| 472 | 392 | break; |
| 473 | 393 | |
| 474 | 394 | case 1: /* Mode 1: 320x200, 4 colous */ |
| 475 | | gate_array.mode_lookup = mode1_lookup; |
| 476 | | gate_array.max_colour_ticks = 2; |
| 477 | | gate_array.ticks_increment = 1; |
| 395 | state->gate_array.mode_lookup = state->mode1_lookup; |
| 396 | state->gate_array.max_colour_ticks = 2; |
| 397 | state->gate_array.ticks_increment = 1; |
| 478 | 398 | break; |
| 479 | 399 | |
| 480 | 400 | case 2: /* Mode 2: 640x200, 2 colours */ |
| 481 | | gate_array.mode_lookup = mode2_lookup; |
| 482 | | gate_array.max_colour_ticks = 1; |
| 483 | | gate_array.ticks_increment = 1; |
| 401 | state->gate_array.mode_lookup = state->mode2_lookup; |
| 402 | state->gate_array.max_colour_ticks = 1; |
| 403 | state->gate_array.ticks_increment = 1; |
| 484 | 404 | break; |
| 485 | 405 | |
| 486 | 406 | case 3: /* Mode 3: 160x200, 4 colours */ |
| 487 | | gate_array.mode_lookup = mode0_lookup; |
| 488 | | gate_array.max_colour_ticks = 4; |
| 489 | | gate_array.ticks_increment = 1; |
| 407 | state->gate_array.mode_lookup = state->mode0_lookup; |
| 408 | state->gate_array.max_colour_ticks = 4; |
| 409 | state->gate_array.ticks_increment = 1; |
| 490 | 410 | break; |
| 491 | 411 | } |
| 492 | 412 | } |
| 493 | 413 | else |
| 494 | 414 | { |
| 495 | | if ( aleste_mode & 0x02 ) |
| 415 | if ( state->aleste_mode & 0x02 ) |
| 496 | 416 | { |
| 497 | 417 | /* select an aleste mode */ |
| 498 | | switch ( gate_array.mrer & 0x03 ) |
| 418 | switch ( state->gate_array.mrer & 0x03 ) |
| 499 | 419 | { |
| 500 | 420 | case 0: /* Aleste Mode 0 (= Amstrad CPC mode 2): 640x200, 2 colours */ |
| 501 | | gate_array.mode_lookup = mode2_lookup; |
| 502 | | gate_array.max_colour_ticks = 1; |
| 503 | | gate_array.ticks_increment = 1; |
| 421 | state->gate_array.mode_lookup = state->mode2_lookup; |
| 422 | state->gate_array.max_colour_ticks = 1; |
| 423 | state->gate_array.ticks_increment = 1; |
| 504 | 424 | break; |
| 505 | 425 | |
| 506 | 426 | case 1: /* Aleste mode 1 (= Amstrad CPC mode 1): 320x200, 4 colours */ |
| 507 | | gate_array.mode_lookup = mode1_lookup; |
| 508 | | gate_array.max_colour_ticks = 2; |
| 509 | | gate_array.ticks_increment = 1; |
| 427 | state->gate_array.mode_lookup = state->mode1_lookup; |
| 428 | state->gate_array.max_colour_ticks = 2; |
| 429 | state->gate_array.ticks_increment = 1; |
| 510 | 430 | break; |
| 511 | 431 | |
| 512 | 432 | case 2: /* Aleste mode 2: 4 colours */ |
| 513 | | gate_array.mode_lookup = mode1_lookup; |
| 514 | | gate_array.max_colour_ticks = 1; |
| 515 | | gate_array.ticks_increment = 2; |
| 433 | state->gate_array.mode_lookup = state->mode1_lookup; |
| 434 | state->gate_array.max_colour_ticks = 1; |
| 435 | state->gate_array.ticks_increment = 2; |
| 516 | 436 | break; |
| 517 | 437 | |
| 518 | 438 | case 3: /* Aleste mode 3: 16 colours */ |
| 519 | | gate_array.mode_lookup = mode0_lookup; |
| 520 | | gate_array.max_colour_ticks = 2; |
| 521 | | gate_array.ticks_increment = 2; |
| 439 | state->gate_array.mode_lookup = state->mode0_lookup; |
| 440 | state->gate_array.max_colour_ticks = 2; |
| 441 | state->gate_array.ticks_increment = 2; |
| 522 | 442 | break; |
| 523 | 443 | } |
| 524 | 444 | } |
| 525 | 445 | else |
| 526 | 446 | { |
| 527 | 447 | /* select an original cpc mode */ |
| 528 | | switch ( gate_array.mrer & 0x03 ) |
| 448 | switch ( state->gate_array.mrer & 0x03 ) |
| 529 | 449 | { |
| 530 | 450 | case 0: /* Mode 0: 160x200, 16 colours */ |
| 531 | | gate_array.mode_lookup = mode0_lookup; |
| 532 | | gate_array.max_colour_ticks = 4; |
| 533 | | gate_array.ticks_increment = 1; |
| 451 | state->gate_array.mode_lookup = state->mode0_lookup; |
| 452 | state->gate_array.max_colour_ticks = 4; |
| 453 | state->gate_array.ticks_increment = 1; |
| 534 | 454 | break; |
| 535 | 455 | |
| 536 | 456 | case 1: /* Mode 1: 320x200, 4 colous */ |
| 537 | | gate_array.mode_lookup = mode1_lookup; |
| 538 | | gate_array.max_colour_ticks = 2; |
| 539 | | gate_array.ticks_increment = 1; |
| 457 | state->gate_array.mode_lookup = state->mode1_lookup; |
| 458 | state->gate_array.max_colour_ticks = 2; |
| 459 | state->gate_array.ticks_increment = 1; |
| 540 | 460 | break; |
| 541 | 461 | |
| 542 | 462 | case 2: /* Mode 2: 640x200, 2 colours */ |
| 543 | | gate_array.mode_lookup = mode2_lookup; |
| 544 | | gate_array.max_colour_ticks = 1; |
| 545 | | gate_array.ticks_increment = 1; |
| 463 | state->gate_array.mode_lookup = state->mode2_lookup; |
| 464 | state->gate_array.max_colour_ticks = 1; |
| 465 | state->gate_array.ticks_increment = 1; |
| 546 | 466 | break; |
| 547 | 467 | |
| 548 | 468 | case 3: /* Mode 3: 160x200, 4 colours */ |
| 549 | | gate_array.mode_lookup = mode0_lookup; |
| 550 | | gate_array.max_colour_ticks = 4; |
| 551 | | gate_array.ticks_increment = 1; |
| 469 | state->gate_array.mode_lookup = state->mode0_lookup; |
| 470 | state->gate_array.max_colour_ticks = 4; |
| 471 | state->gate_array.ticks_increment = 1; |
| 552 | 472 | break; |
| 553 | 473 | } |
| 554 | 474 | } |
| r9648 | r9649 | |
| 571 | 491 | |
| 572 | 492 | static void amstrad_plus_dma_parse(running_machine *machine, int channel) |
| 573 | 493 | { |
| 494 | amstrad_state *state = machine->driver_data<amstrad_state>(); |
| 574 | 495 | unsigned short command; |
| 575 | 496 | |
| 576 | | if( asic.dma_addr[channel] & 0x01) |
| 577 | | asic.dma_addr[channel]++; // align to even address |
| 497 | if( state->asic.dma_addr[channel] & 0x01) |
| 498 | state->asic.dma_addr[channel]++; // align to even address |
| 578 | 499 | |
| 579 | | if ( asic.dma_pause[channel] != 0 ) |
| 500 | if ( state->asic.dma_pause[channel] != 0 ) |
| 580 | 501 | { // do nothing, this channel is paused |
| 581 | | asic.dma_prescaler[channel]--; |
| 582 | | if ( asic.dma_prescaler[channel] == 0 ) |
| 502 | state->asic.dma_prescaler[channel]--; |
| 503 | if ( state->asic.dma_prescaler[channel] == 0 ) |
| 583 | 504 | { |
| 584 | | asic.dma_pause[channel]--; |
| 585 | | asic.dma_prescaler[channel] = asic.ram[0x2c02 + (4*channel)] + 1; |
| 505 | state->asic.dma_pause[channel]--; |
| 506 | state->asic.dma_prescaler[channel] = state->asic.ram[0x2c02 + (4*channel)] + 1; |
| 586 | 507 | } |
| 587 | 508 | return; |
| 588 | 509 | } |
| 589 | | command = (messram_get_ptr(machine->device("messram"))[asic.dma_addr[channel]+1] << 8) + messram_get_ptr(machine->device("messram"))[asic.dma_addr[channel]]; |
| 590 | | // logerror("DMA #%i: address %04x: command %04x\n",channel,asic.dma_addr[channel],command); |
| 510 | command = (messram_get_ptr(machine->device("messram"))[state->asic.dma_addr[channel]+1] << 8) + messram_get_ptr(machine->device("messram"))[state->asic.dma_addr[channel]]; |
| 511 | // logerror("DMA #%i: address %04x: command %04x\n",channel,state->asic.dma_addr[channel],command); |
| 591 | 512 | switch (command & 0xf000) |
| 592 | 513 | { |
| 593 | 514 | case 0x0000: // Load PSG register |
| r9648 | r9649 | |
| 595 | 516 | running_device *ay8910 = machine->device("ay"); |
| 596 | 517 | ay8910_address_w(ay8910, 0, (command & 0x0f00) >> 8); |
| 597 | 518 | ay8910_data_w(ay8910, 0, command & 0x00ff); |
| 598 | | ay8910_address_w(ay8910, 0, prev_reg); |
| 519 | ay8910_address_w(ay8910, 0, state->prev_reg); |
| 599 | 520 | } |
| 600 | 521 | logerror("DMA %i: LOAD %i, %i\n",channel,(command & 0x0f00) >> 8, command & 0x00ff); |
| 601 | 522 | break; |
| 602 | 523 | case 0x1000: // Pause for n HSYNCs (0 - 4095) |
| 603 | | asic.dma_pause[channel] = (command & 0x0fff) - 1; |
| 524 | state->asic.dma_pause[channel] = (command & 0x0fff) - 1; |
| 604 | 525 | logerror("DMA %i: PAUSE %i\n",channel,command & 0x0fff); |
| 605 | 526 | break; |
| 606 | 527 | case 0x2000: // Beginning of repeat loop |
| 607 | | asic.dma_repeat[channel] = asic.dma_addr[channel]; |
| 608 | | asic.dma_loopcount[channel] = (command & 0x0fff); |
| 528 | state->asic.dma_repeat[channel] = state->asic.dma_addr[channel]; |
| 529 | state->asic.dma_loopcount[channel] = (command & 0x0fff); |
| 609 | 530 | logerror("DMA %i: REPEAT %i\n",channel,command & 0x0fff); |
| 610 | 531 | break; |
| 611 | 532 | case 0x4000: // Control functions |
| 612 | 533 | if (command & 0x01) // Loop back to last Repeat instruction |
| 613 | 534 | { |
| 614 | | if (asic.dma_loopcount[channel] > 0) |
| 535 | if (state->asic.dma_loopcount[channel] > 0) |
| 615 | 536 | { |
| 616 | | asic.dma_addr[channel] = asic.dma_repeat[channel]; |
| 617 | | logerror("DMA %i: LOOP (%i left)\n",channel,asic.dma_loopcount[channel]); |
| 618 | | asic.dma_loopcount[channel]--; |
| 537 | state->asic.dma_addr[channel] = state->asic.dma_repeat[channel]; |
| 538 | logerror("DMA %i: LOOP (%i left)\n",channel,state->asic.dma_loopcount[channel]); |
| 539 | state->asic.dma_loopcount[channel]--; |
| 619 | 540 | } |
| 620 | 541 | else |
| 621 | 542 | logerror("DMA %i: LOOP (end)\n",channel); |
| 622 | 543 | } |
| 623 | 544 | if (command & 0x10) // Cause interrupt |
| 624 | 545 | { |
| 625 | | amstrad_plus_irq_cause = channel * 2; |
| 626 | | asic.ram[0x2c0f] |= (0x40 >> channel); |
| 546 | state->plus_irq_cause = channel * 2; |
| 547 | state->asic.ram[0x2c0f] |= (0x40 >> channel); |
| 627 | 548 | cputag_set_input_line(machine, "maincpu", 0, ASSERT_LINE); |
| 628 | 549 | logerror("DMA %i: INT\n",channel); |
| 629 | 550 | } |
| 630 | 551 | if (command & 0x20) // Stop processing on this channel |
| 631 | 552 | { |
| 632 | | asic.dma_status &= ~(0x01 << channel); |
| 553 | state->asic.dma_status &= ~(0x01 << channel); |
| 633 | 554 | logerror("DMA %i: STOP\n",channel); |
| 634 | 555 | } |
| 635 | 556 | break; |
| 636 | 557 | default: |
| 637 | | logerror("DMA: Unknown DMA command - %04x - at address &%04x\n",command,asic.dma_addr[channel]); |
| 558 | logerror("DMA: Unknown DMA command - %04x - at address &%04x\n",command,state->asic.dma_addr[channel]); |
| 638 | 559 | } |
| 639 | | asic.dma_addr[channel] += 2; // point to next DMA instruction |
| 560 | state->asic.dma_addr[channel] += 2; // point to next DMA instruction |
| 640 | 561 | } |
| 641 | 562 | |
| 642 | 563 | |
| 643 | 564 | static void amstrad_plus_handle_dma(running_machine *machine) |
| 644 | 565 | { |
| 645 | | if ( asic.dma_status & 0x01 ) // DMA channel 0 |
| 566 | amstrad_state *state = machine->driver_data<amstrad_state>(); |
| 567 | if ( state->asic.dma_status & 0x01 ) // DMA channel 0 |
| 646 | 568 | amstrad_plus_dma_parse( machine, 0 ); |
| 647 | 569 | |
| 648 | | if ( asic.dma_status & 0x02 ) // DMA channel 1 |
| 570 | if ( state->asic.dma_status & 0x02 ) // DMA channel 1 |
| 649 | 571 | amstrad_plus_dma_parse( machine, 1 ); |
| 650 | 572 | |
| 651 | | if ( asic.dma_status & 0x04 ) // DMA channel 2 |
| 573 | if ( state->asic.dma_status & 0x04 ) // DMA channel 2 |
| 652 | 574 | amstrad_plus_dma_parse( machine, 2 ); |
| 653 | 575 | } |
| 654 | 576 | |
| r9648 | r9649 | |
| 656 | 578 | /* Set the new colour from the GateArray */ |
| 657 | 579 | static void amstrad_vh_update_colour(running_machine *machine, int PenIndex, UINT16 hw_colour_index) |
| 658 | 580 | { |
| 659 | | if ( amstrad_system_type == SYSTEM_PLUS || amstrad_system_type == SYSTEM_GX4000 ) |
| 581 | amstrad_state *state = machine->driver_data<amstrad_state>(); |
| 582 | if ( state->system_type == SYSTEM_PLUS || state->system_type == SYSTEM_GX4000 ) |
| 660 | 583 | { |
| 661 | 584 | int val; |
| 662 | 585 | |
| r9648 | r9649 | |
| 665 | 588 | /* CPC+/GX4000 - normal palette changes through the Gate Array also makes the corresponding change in the ASIC palette */ |
| 666 | 589 | val = (amstrad_palette[hw_colour_index] & 0xf00000) >> 16; /* red */ |
| 667 | 590 | val |= (amstrad_palette[hw_colour_index] & 0x0000f0) >> 4; /* blue */ |
| 668 | | asic.ram[0x2400+PenIndex*2] = val; |
| 591 | state->asic.ram[0x2400+PenIndex*2] = val; |
| 669 | 592 | val = (amstrad_palette[hw_colour_index] & 0x00f000) >> 12; /* green */ |
| 670 | | asic.ram[0x2401+PenIndex*2] = val; |
| 593 | state->asic.ram[0x2401+PenIndex*2] = val; |
| 671 | 594 | } |
| 672 | 595 | else |
| 673 | 596 | { |
| 674 | 597 | amstrad_update_video( machine ); |
| 675 | 598 | } |
| 676 | | amstrad_GateArray_render_colours[PenIndex] = hw_colour_index; |
| 599 | state->GateArray_render_colours[PenIndex] = hw_colour_index; |
| 677 | 600 | } |
| 678 | 601 | |
| 679 | 602 | |
| 680 | 603 | static void aleste_vh_update_colour(running_machine *machine, int PenIndex, UINT16 hw_colour_index) |
| 681 | 604 | { |
| 605 | amstrad_state *state = machine->driver_data<amstrad_state>(); |
| 682 | 606 | amstrad_update_video( machine ); |
| 683 | | amstrad_GateArray_render_colours[PenIndex] = hw_colour_index+32; |
| 607 | state->GateArray_render_colours[PenIndex] = hw_colour_index+32; |
| 684 | 608 | } |
| 685 | 609 | |
| 686 | 610 | |
| 687 | 611 | INLINE void amstrad_gate_array_get_video_data( running_machine *machine ) |
| 688 | 612 | { |
| 689 | | if ( aleste_mode & 0x02 ) |
| 690 | | gate_array.address = ( ( gate_array.ma & 0x2000 ) << 2 ) | ( ( gate_array.ra & 0x06 ) << 11 ) | ( ( gate_array.ra & 0x01 ) << 14 ) | ( ( gate_array.ma & 0x7ff ) << 1 ); |
| 613 | amstrad_state *state = machine->driver_data<amstrad_state>(); |
| 614 | if ( state->aleste_mode & 0x02 ) |
| 615 | state->gate_array.address = ( ( state->gate_array.ma & 0x2000 ) << 2 ) | ( ( state->gate_array.ra & 0x06 ) << 11 ) | ( ( state->gate_array.ra & 0x01 ) << 14 ) | ( ( state->gate_array.ma & 0x7ff ) << 1 ); |
| 691 | 616 | else |
| 692 | | gate_array.address = ( ( gate_array.ma & 0x3000 ) << 2 ) | ( ( gate_array.ra & 0x07 ) << 11 ) | ( ( gate_array.ma & 0x3ff ) << 1 ); |
| 693 | | gate_array.data = messram_get_ptr(machine->device("messram"))[ gate_array.address ]; |
| 694 | | gate_array.colour = amstrad_GateArray_render_colours[ gate_array.mode_lookup[gate_array.data] ]; |
| 695 | | gate_array.colour_ticks = gate_array.max_colour_ticks; |
| 696 | | gate_array.ticks = 0; |
| 617 | state->gate_array.address = ( ( state->gate_array.ma & 0x3000 ) << 2 ) | ( ( state->gate_array.ra & 0x07 ) << 11 ) | ( ( state->gate_array.ma & 0x3ff ) << 1 ); |
| 618 | state->gate_array.data = messram_get_ptr(machine->device("messram"))[ state->gate_array.address ]; |
| 619 | state->gate_array.colour = state->GateArray_render_colours[ state->gate_array.mode_lookup[state->gate_array.data] ]; |
| 620 | state->gate_array.colour_ticks = state->gate_array.max_colour_ticks; |
| 621 | state->gate_array.ticks = 0; |
| 697 | 622 | } |
| 698 | 623 | |
| 699 | 624 | |
| 700 | 625 | INLINE void amstrad_update_video( running_machine *machine ) |
| 701 | 626 | { |
| 627 | amstrad_state *state = machine->driver_data<amstrad_state>(); |
| 702 | 628 | attotime now = timer_get_time(machine); |
| 703 | 629 | |
| 704 | | if ( gate_array.draw_p ) |
| 630 | if ( state->gate_array.draw_p ) |
| 705 | 631 | { |
| 706 | | UINT32 cycles_passed = attotime_to_ticks( attotime_sub( now, gate_array.last_draw_time ), XTAL_16MHz ); |
| 632 | UINT32 cycles_passed = attotime_to_ticks( attotime_sub( now, state->gate_array.last_draw_time ), XTAL_16MHz ); |
| 707 | 633 | |
| 708 | 634 | while( cycles_passed ) |
| 709 | 635 | { |
| 710 | | if ( ! gate_array.de || ( ( aleste_mode & 0x02 ) && ! ( aleste_mode & 0x08 ) ) ) |
| 636 | if ( ! state->gate_array.de || ( ( state->aleste_mode & 0x02 ) && ! ( state->aleste_mode & 0x08 ) ) ) |
| 711 | 637 | { |
| 712 | | *gate_array.draw_p = amstrad_GateArray_render_colours[ 16 ]; |
| 638 | *state->gate_array.draw_p = state->GateArray_render_colours[ 16 ]; |
| 713 | 639 | } |
| 714 | 640 | else |
| 715 | 641 | { |
| 716 | | *gate_array.draw_p = gate_array.colour; |
| 717 | | gate_array.colour_ticks--; |
| 718 | | if ( ! gate_array.colour_ticks ) |
| 642 | *state->gate_array.draw_p = state->gate_array.colour; |
| 643 | state->gate_array.colour_ticks--; |
| 644 | if ( ! state->gate_array.colour_ticks ) |
| 719 | 645 | { |
| 720 | | gate_array.data <<= 1; |
| 721 | | gate_array.colour = amstrad_GateArray_render_colours[ gate_array.mode_lookup[gate_array.data] ]; |
| 722 | | gate_array.colour_ticks = gate_array.max_colour_ticks; |
| 646 | state->gate_array.data <<= 1; |
| 647 | state->gate_array.colour = state->GateArray_render_colours[ state->gate_array.mode_lookup[state->gate_array.data] ]; |
| 648 | state->gate_array.colour_ticks = state->gate_array.max_colour_ticks; |
| 723 | 649 | } |
| 724 | | gate_array.ticks += gate_array.ticks_increment; |
| 725 | | switch( gate_array.ticks) |
| 650 | state->gate_array.ticks += state->gate_array.ticks_increment; |
| 651 | switch( state->gate_array.ticks) |
| 726 | 652 | { |
| 727 | 653 | case 8: |
| 728 | | gate_array.data = messram_get_ptr(machine->device("messram"))[ gate_array.address + 1 ]; |
| 729 | | gate_array.colour = amstrad_GateArray_render_colours[ gate_array.mode_lookup[gate_array.data] ]; |
| 654 | state->gate_array.data = messram_get_ptr(machine->device("messram"))[ state->gate_array.address + 1 ]; |
| 655 | state->gate_array.colour = state->GateArray_render_colours[ state->gate_array.mode_lookup[state->gate_array.data] ]; |
| 730 | 656 | break; |
| 731 | 657 | case 16: |
| 732 | | gate_array.ma += 1; /* If we were synced with the 6845 mc6845_get_ma should return this value */ |
| 658 | state->gate_array.ma += 1; /* If we were synced with the 6845 mc6845_get_ma should return this value */ |
| 733 | 659 | amstrad_gate_array_get_video_data( machine ); |
| 734 | 660 | break; |
| 735 | 661 | } |
| 736 | 662 | } |
| 737 | | gate_array.draw_p++; |
| 663 | state->gate_array.draw_p++; |
| 738 | 664 | cycles_passed--; |
| 739 | | gate_array.line_ticks++; |
| 740 | | if ( gate_array.line_ticks > gate_array.bitmap->width ) |
| 665 | state->gate_array.line_ticks++; |
| 666 | if ( state->gate_array.line_ticks > state->gate_array.bitmap->width ) |
| 741 | 667 | { |
| 742 | | gate_array.draw_p = NULL; |
| 668 | state->gate_array.draw_p = NULL; |
| 743 | 669 | cycles_passed = 0; |
| 744 | 670 | } |
| 745 | 671 | } |
| 746 | 672 | } |
| 747 | 673 | |
| 748 | | gate_array.last_draw_time = now; |
| 674 | state->gate_array.last_draw_time = now; |
| 749 | 675 | } |
| 750 | 676 | |
| 751 | 677 | |
| 752 | 678 | INLINE void amstrad_plus_gate_array_get_video_data( running_machine *machine ) |
| 753 | 679 | { |
| 680 | amstrad_state *state = machine->driver_data<amstrad_state>(); |
| 754 | 681 | UINT16 caddr; |
| 755 | | UINT16 ma = ( gate_array.ma - asic.split_ma_started ) + asic.split_ma_base; |
| 756 | | UINT16 ra = gate_array.ra + ( ( asic.ram[0x2804] >> 4 ) & 0x07 ); |
| 682 | UINT16 ma = ( state->gate_array.ma - state->asic.split_ma_started ) + state->asic.split_ma_base; |
| 683 | UINT16 ra = state->gate_array.ra + ( ( state->asic.ram[0x2804] >> 4 ) & 0x07 ); |
| 757 | 684 | |
| 758 | 685 | if ( ra > 7 ) |
| 759 | 686 | { |
| 760 | | ma += asic.horiz_disp; |
| 687 | ma += state->asic.horiz_disp; |
| 761 | 688 | } |
| 762 | | gate_array.address = ( ( ma & 0x3000 ) << 2 ) | ( ( gate_array.ra & 0x07 ) << 11 ) | ( ( ma & 0x3ff ) << 1 ); |
| 763 | | gate_array.data = messram_get_ptr(machine->device("messram"))[ gate_array.address ]; |
| 764 | | caddr = 0x2400 + gate_array.mode_lookup[gate_array.data] * 2; |
| 765 | | gate_array.colour = asic.ram[caddr] + ( asic.ram[caddr+1] << 8 ); |
| 766 | | gate_array.colour_ticks = gate_array.max_colour_ticks; |
| 767 | | gate_array.ticks = 0; |
| 689 | state->gate_array.address = ( ( ma & 0x3000 ) << 2 ) | ( ( state->gate_array.ra & 0x07 ) << 11 ) | ( ( ma & 0x3ff ) << 1 ); |
| 690 | state->gate_array.data = messram_get_ptr(machine->device("messram"))[ state->gate_array.address ]; |
| 691 | caddr = 0x2400 + state->gate_array.mode_lookup[state->gate_array.data] * 2; |
| 692 | state->gate_array.colour = state->asic.ram[caddr] + ( state->asic.ram[caddr+1] << 8 ); |
| 693 | state->gate_array.colour_ticks = state->gate_array.max_colour_ticks; |
| 694 | state->gate_array.ticks = 0; |
| 768 | 695 | } |
| 769 | 696 | |
| 770 | 697 | |
| 771 | 698 | INLINE void amstrad_plus_update_video( running_machine *machine ) |
| 772 | 699 | { |
| 700 | amstrad_state *state = machine->driver_data<amstrad_state>(); |
| 773 | 701 | attotime now = timer_get_time(machine); |
| 774 | 702 | |
| 775 | | if ( gate_array.draw_p ) |
| 703 | if ( state->gate_array.draw_p ) |
| 776 | 704 | { |
| 777 | | UINT32 cycles_passed = attotime_to_ticks( attotime_sub( now, gate_array.last_draw_time ), XTAL_16MHz ); |
| 705 | UINT32 cycles_passed = attotime_to_ticks( attotime_sub( now, state->gate_array.last_draw_time ), XTAL_16MHz ); |
| 778 | 706 | |
| 779 | 707 | while( cycles_passed ) |
| 780 | 708 | { |
| 781 | | if ( ! gate_array.de ) |
| 709 | if ( ! state->gate_array.de ) |
| 782 | 710 | { |
| 783 | | *gate_array.draw_p = asic.ram[0x2420] + ( asic.ram[0x2421] << 8 ); |
| 711 | *state->gate_array.draw_p = state->asic.ram[0x2420] + ( state->asic.ram[0x2421] << 8 ); |
| 784 | 712 | } |
| 785 | 713 | else |
| 786 | 714 | { |
| 787 | | *gate_array.draw_p = gate_array.colour; |
| 715 | *state->gate_array.draw_p = state->gate_array.colour; |
| 788 | 716 | |
| 789 | | if ( asic.hscroll ) |
| 717 | if ( state->asic.hscroll ) |
| 790 | 718 | { |
| 791 | | asic.hscroll--; |
| 792 | | if ( asic.hscroll == 0 ) |
| 719 | state->asic.hscroll--; |
| 720 | if ( state->asic.hscroll == 0 ) |
| 793 | 721 | amstrad_plus_gate_array_get_video_data( machine ); |
| 794 | 722 | } |
| 795 | 723 | else |
| 796 | 724 | { |
| 797 | | gate_array.colour_ticks--; |
| 798 | | if ( ! gate_array.colour_ticks ) |
| 725 | state->gate_array.colour_ticks--; |
| 726 | if ( ! state->gate_array.colour_ticks ) |
| 799 | 727 | { |
| 800 | 728 | UINT16 caddr; |
| 801 | 729 | |
| 802 | | gate_array.data <<= 1; |
| 803 | | caddr = 0x2400 + gate_array.mode_lookup[gate_array.data] * 2; |
| 804 | | gate_array.colour = asic.ram[caddr] + ( asic.ram[caddr+1] << 8 ); |
| 805 | | gate_array.colour_ticks = gate_array.max_colour_ticks; |
| 730 | state->gate_array.data <<= 1; |
| 731 | caddr = 0x2400 + state->gate_array.mode_lookup[state->gate_array.data] * 2; |
| 732 | state->gate_array.colour = state->asic.ram[caddr] + ( state->asic.ram[caddr+1] << 8 ); |
| 733 | state->gate_array.colour_ticks = state->gate_array.max_colour_ticks; |
| 806 | 734 | } |
| 807 | | gate_array.ticks += gate_array.ticks_increment; |
| 808 | | switch( gate_array.ticks) |
| 735 | state->gate_array.ticks += state->gate_array.ticks_increment; |
| 736 | switch( state->gate_array.ticks) |
| 809 | 737 | { |
| 810 | 738 | case 8: |
| 811 | 739 | { |
| 812 | 740 | UINT16 caddr; |
| 813 | 741 | |
| 814 | | gate_array.data = messram_get_ptr(machine->device("messram"))[ gate_array.address + 1 ]; |
| 815 | | caddr = 0x2400 + gate_array.mode_lookup[gate_array.data] * 2; |
| 816 | | gate_array.colour = asic.ram[caddr] + ( asic.ram[caddr+1] << 8 ); |
| 742 | state->gate_array.data = messram_get_ptr(machine->device("messram"))[ state->gate_array.address + 1 ]; |
| 743 | caddr = 0x2400 + state->gate_array.mode_lookup[state->gate_array.data] * 2; |
| 744 | state->gate_array.colour = state->asic.ram[caddr] + ( state->asic.ram[caddr+1] << 8 ); |
| 817 | 745 | } |
| 818 | 746 | break; |
| 819 | 747 | case 16: |
| 820 | | gate_array.ma += 1; /* If we were synced with the 6845 mc6845_get_ma should return this value */ |
| 748 | state->gate_array.ma += 1; /* If we were synced with the 6845 mc6845_get_ma should return this value */ |
| 821 | 749 | amstrad_plus_gate_array_get_video_data( machine ); |
| 822 | 750 | break; |
| 823 | 751 | } |
| 824 | 752 | } |
| 825 | 753 | } |
| 826 | | gate_array.draw_p++; |
| 754 | state->gate_array.draw_p++; |
| 827 | 755 | cycles_passed--; |
| 828 | | gate_array.line_ticks++; |
| 829 | | if ( gate_array.line_ticks > gate_array.bitmap->width ) |
| 756 | state->gate_array.line_ticks++; |
| 757 | if ( state->gate_array.line_ticks > state->gate_array.bitmap->width ) |
| 830 | 758 | { |
| 831 | | gate_array.draw_p = NULL; |
| 759 | state->gate_array.draw_p = NULL; |
| 832 | 760 | cycles_passed = 0; |
| 833 | 761 | } |
| 834 | 762 | } |
| 835 | 763 | } |
| 836 | 764 | |
| 837 | | gate_array.last_draw_time = now; |
| 765 | state->gate_array.last_draw_time = now; |
| 838 | 766 | } |
| 839 | 767 | |
| 840 | 768 | |
| 841 | 769 | INLINE void amstrad_plus_update_video_sprites( running_machine *machine ) |
| 842 | 770 | { |
| 843 | | UINT16 *p = BITMAP_ADDR16( gate_array.bitmap, gate_array.y, asic.h_start ); |
| 771 | amstrad_state *state = machine->driver_data<amstrad_state>(); |
| 772 | UINT16 *p = BITMAP_ADDR16( state->gate_array.bitmap, state->gate_array.y, state->asic.h_start ); |
| 844 | 773 | int i; |
| 845 | 774 | |
| 846 | | if ( gate_array.y < 0 ) |
| 775 | if ( state->gate_array.y < 0 ) |
| 847 | 776 | return; |
| 848 | 777 | |
| 849 | 778 | for ( i = 15 * 8; i >= 0; i -= 8 ) |
| 850 | 779 | { |
| 851 | | UINT8 xmag = ( asic.ram[ 0x2000 + i + 4 ] >> 2 ) & 0x03; |
| 852 | | UINT8 ymag = asic.ram[ 0x2000 + i + 4 ] & 0x03; |
| 780 | UINT8 xmag = ( state->asic.ram[ 0x2000 + i + 4 ] >> 2 ) & 0x03; |
| 781 | UINT8 ymag = state->asic.ram[ 0x2000 + i + 4 ] & 0x03; |
| 853 | 782 | |
| 854 | 783 | /* Check if sprite is enabled */ |
| 855 | 784 | if ( xmag && ymag ) |
| 856 | 785 | { |
| 857 | | INT16 spr_x = asic.ram[ 0x2000 + i ] + ( asic.ram[ 0x2001 + i ] << 8 ); |
| 858 | | INT16 spr_y = asic.ram[ 0x2002 + i ] + ( asic.ram[ 0x2003 + i ] << 8 ); |
| 786 | INT16 spr_x = state->asic.ram[ 0x2000 + i ] + ( state->asic.ram[ 0x2001 + i ] << 8 ); |
| 787 | INT16 spr_y = state->asic.ram[ 0x2002 + i ] + ( state->asic.ram[ 0x2003 + i ] << 8 ); |
| 859 | 788 | |
| 860 | 789 | xmag -= 1; |
| 861 | 790 | ymag -= 1; |
| 862 | 791 | |
| 863 | 792 | /* Check if sprite would appear on this scanline */ |
| 864 | | if ( spr_y <= asic.vpos && asic.vpos < spr_y + ( 16 << ymag ) && spr_x < ( asic.h_end - asic.h_start ) && spr_x + ( 16 << xmag ) > 0 ) |
| 793 | if ( spr_y <= state->asic.vpos && state->asic.vpos < spr_y + ( 16 << ymag ) && spr_x < ( state->asic.h_end - state->asic.h_start ) && spr_x + ( 16 << xmag ) > 0 ) |
| 865 | 794 | { |
| 866 | | UINT16 spr_addr = i * 32 + ( ( ( asic.vpos - spr_y ) >> ymag ) * 16 ); |
| 795 | UINT16 spr_addr = i * 32 + ( ( ( state->asic.vpos - spr_y ) >> ymag ) * 16 ); |
| 867 | 796 | int j, k; |
| 868 | 797 | |
| 869 | 798 | for ( j = 0; j < 16; j++ ) |
| r9648 | r9649 | |
| 872 | 801 | { |
| 873 | 802 | INT16 x = spr_x + ( j << xmag ) + k; |
| 874 | 803 | |
| 875 | | if ( x >= 0 && x < ( asic.h_end - asic.h_start ) ) |
| 804 | if ( x >= 0 && x < ( state->asic.h_end - state->asic.h_start ) ) |
| 876 | 805 | { |
| 877 | | UINT8 spr_col = ( asic.ram[ spr_addr + j ] & 0x0f ) * 2; |
| 806 | UINT8 spr_col = ( state->asic.ram[ spr_addr + j ] & 0x0f ) * 2; |
| 878 | 807 | |
| 879 | 808 | if ( spr_col ) |
| 880 | | p[x] = asic.ram[ 0x2420 + spr_col ] + ( asic.ram[ 0x2421 + spr_col ] << 8 ); |
| 809 | p[x] = state->asic.ram[ 0x2420 + spr_col ] + ( state->asic.ram[ 0x2421 + spr_col ] << 8 ); |
| 881 | 810 | } |
| 882 | 811 | } |
| 883 | 812 | } |
| r9648 | r9649 | |
| 889 | 818 | |
| 890 | 819 | static WRITE_LINE_DEVICE_HANDLER( amstrad_hsync_changed ) |
| 891 | 820 | { |
| 821 | amstrad_state *drvstate = device->machine->driver_data<amstrad_state>(); |
| 892 | 822 | amstrad_update_video( device->machine ); |
| 893 | 823 | |
| 894 | 824 | /* The gate array reacts to de-assertion of the hsycnc 6845 line */ |
| 895 | | if ( gate_array.hsync && !state ) |
| 825 | if ( drvstate->gate_array.hsync && !state ) |
| 896 | 826 | { |
| 897 | | gate_array.hsync_counter++; |
| 827 | drvstate->gate_array.hsync_counter++; |
| 898 | 828 | /* Advance to next drawing line */ |
| 899 | | gate_array.y++; |
| 900 | | gate_array.line_ticks = 0; |
| 901 | | if ( gate_array.y >= 0 && gate_array.y < gate_array.bitmap->height ) |
| 829 | drvstate->gate_array.y++; |
| 830 | drvstate->gate_array.line_ticks = 0; |
| 831 | if ( drvstate->gate_array.y >= 0 && drvstate->gate_array.y < drvstate->gate_array.bitmap->height ) |
| 902 | 832 | { |
| 903 | | gate_array.draw_p = BITMAP_ADDR16( gate_array.bitmap, gate_array.y, 0 ); |
| 833 | drvstate->gate_array.draw_p = BITMAP_ADDR16( drvstate->gate_array.bitmap, drvstate->gate_array.y, 0 ); |
| 904 | 834 | } |
| 905 | 835 | else |
| 906 | 836 | { |
| 907 | | gate_array.draw_p = NULL; |
| 837 | drvstate->gate_array.draw_p = NULL; |
| 908 | 838 | } |
| 909 | 839 | |
| 910 | | if ( gate_array.hsync_after_vsync_counter != 0 ) // counters still operate regardless of PRI state |
| 840 | if ( drvstate->gate_array.hsync_after_vsync_counter != 0 ) // counters still operate regardless of PRI state |
| 911 | 841 | { |
| 912 | | gate_array.hsync_after_vsync_counter--; |
| 842 | drvstate->gate_array.hsync_after_vsync_counter--; |
| 913 | 843 | |
| 914 | | if (gate_array.hsync_after_vsync_counter == 0) |
| 844 | if (drvstate->gate_array.hsync_after_vsync_counter == 0) |
| 915 | 845 | { |
| 916 | | if (gate_array.hsync_counter >= 32) |
| 846 | if (drvstate->gate_array.hsync_counter >= 32) |
| 917 | 847 | { |
| 918 | 848 | cputag_set_input_line(device->machine, "maincpu", 0, ASSERT_LINE); |
| 919 | 849 | } |
| 920 | | gate_array.hsync_counter = 0; |
| 850 | drvstate->gate_array.hsync_counter = 0; |
| 921 | 851 | } |
| 922 | 852 | } |
| 923 | 853 | |
| 924 | | if ( gate_array.hsync_counter >= 52 ) |
| 854 | if ( drvstate->gate_array.hsync_counter >= 52 ) |
| 925 | 855 | { |
| 926 | | gate_array.hsync_counter = 0; |
| 856 | drvstate->gate_array.hsync_counter = 0; |
| 927 | 857 | cputag_set_input_line(device->machine, "maincpu", 0, ASSERT_LINE); |
| 928 | 858 | } |
| 929 | 859 | } |
| 930 | | gate_array.hsync = state ? 1 : 0; |
| 860 | drvstate->gate_array.hsync = state ? 1 : 0; |
| 931 | 861 | } |
| 932 | 862 | |
| 933 | 863 | |
| 934 | 864 | static WRITE_LINE_DEVICE_HANDLER( amstrad_plus_hsync_changed ) |
| 935 | 865 | { |
| 866 | amstrad_state *drvstate = device->machine->driver_data<amstrad_state>(); |
| 936 | 867 | amstrad_plus_update_video( device->machine ); |
| 937 | 868 | |
| 938 | | if ( gate_array.hsync && !state ) |
| 869 | if ( drvstate->gate_array.hsync && !state ) |
| 939 | 870 | { |
| 940 | | gate_array.hsync_counter++; |
| 871 | drvstate->gate_array.hsync_counter++; |
| 941 | 872 | /* Advance to next drawing line */ |
| 942 | | gate_array.y++; |
| 943 | | gate_array.line_ticks = 0; |
| 944 | | if ( gate_array.y >= 0 && gate_array.y < gate_array.bitmap->height ) |
| 873 | drvstate->gate_array.y++; |
| 874 | drvstate->gate_array.line_ticks = 0; |
| 875 | if ( drvstate->gate_array.y >= 0 && drvstate->gate_array.y < drvstate->gate_array.bitmap->height ) |
| 945 | 876 | { |
| 946 | | gate_array.draw_p = BITMAP_ADDR16( gate_array.bitmap, gate_array.y, 0 ); |
| 877 | drvstate->gate_array.draw_p = BITMAP_ADDR16( drvstate->gate_array.bitmap, drvstate->gate_array.y, 0 ); |
| 947 | 878 | } |
| 948 | 879 | else |
| 949 | 880 | { |
| 950 | | gate_array.draw_p = NULL; |
| 881 | drvstate->gate_array.draw_p = NULL; |
| 951 | 882 | } |
| 952 | 883 | |
| 953 | | if ( gate_array.hsync_after_vsync_counter != 0 ) // counters still operate regardless of PRI state |
| 884 | if ( drvstate->gate_array.hsync_after_vsync_counter != 0 ) // counters still operate regardless of PRI state |
| 954 | 885 | { |
| 955 | | gate_array.hsync_after_vsync_counter--; |
| 886 | drvstate->gate_array.hsync_after_vsync_counter--; |
| 956 | 887 | |
| 957 | | if (gate_array.hsync_after_vsync_counter == 0) |
| 888 | if (drvstate->gate_array.hsync_after_vsync_counter == 0) |
| 958 | 889 | { |
| 959 | | if (gate_array.hsync_counter >= 32) |
| 890 | if (drvstate->gate_array.hsync_counter >= 32) |
| 960 | 891 | { |
| 961 | | if( asic.pri == 0 || asic.enabled == 0) |
| 892 | if( drvstate->asic.pri == 0 || drvstate->asic.enabled == 0) |
| 962 | 893 | { |
| 963 | 894 | cputag_set_input_line(device->machine, "maincpu", 0, ASSERT_LINE); |
| 964 | 895 | } |
| 965 | 896 | } |
| 966 | | gate_array.hsync_counter = 0; |
| 897 | drvstate->gate_array.hsync_counter = 0; |
| 967 | 898 | } |
| 968 | 899 | } |
| 969 | 900 | |
| 970 | | if ( gate_array.hsync_counter >= 52 ) |
| 901 | if ( drvstate->gate_array.hsync_counter >= 52 ) |
| 971 | 902 | { |
| 972 | | gate_array.hsync_counter = 0; |
| 973 | | if ( asic.pri == 0 || asic.enabled == 0 ) |
| 903 | drvstate->gate_array.hsync_counter = 0; |
| 904 | if ( drvstate->asic.pri == 0 || drvstate->asic.enabled == 0 ) |
| 974 | 905 | { |
| 975 | 906 | cputag_set_input_line(device->machine, "maincpu", 0, ASSERT_LINE); |
| 976 | 907 | } |
| 977 | 908 | } |
| 978 | 909 | |
| 979 | | if ( asic.enabled ) |
| 910 | if ( drvstate->asic.enabled ) |
| 980 | 911 | { |
| 981 | 912 | // CPC+/GX4000 Programmable Raster Interrupt (disabled if &6800 in ASIC RAM is 0) |
| 982 | | if ( asic.pri != 0 ) |
| 913 | if ( drvstate->asic.pri != 0 ) |
| 983 | 914 | { |
| 984 | | if ( asic.pri == asic.vpos - 1 ) |
| 915 | if ( drvstate->asic.pri == drvstate->asic.vpos - 1 ) |
| 985 | 916 | { |
| 986 | | logerror("PRI: triggered, scanline %d\n",asic.pri); |
| 917 | logerror("PRI: triggered, scanline %d\n",drvstate->asic.pri); |
| 987 | 918 | cputag_set_input_line(device->machine, "maincpu", 0, ASSERT_LINE); |
| 988 | | amstrad_plus_irq_cause = 0x06; // raster interrupt vector |
| 989 | | gate_array.hsync_counter &= ~0x20; // ASIC PRI resets the MSB of the raster counter |
| 919 | drvstate->plus_irq_cause = 0x06; // raster interrupt vector |
| 920 | drvstate->gate_array.hsync_counter &= ~0x20; // ASIC PRI resets the MSB of the raster counter |
| 990 | 921 | } |
| 991 | 922 | } |
| 992 | 923 | // CPC+/GX4000 Split screen registers (disabled if &6801 in ASIC RAM is 0) |
| 993 | | if(asic.ram[0x2801] != 0) |
| 924 | if(drvstate->asic.ram[0x2801] != 0) |
| 994 | 925 | { |
| 995 | | if ( asic.ram[0x2801] == asic.vpos - 1 ) // split occurs here (hopefully) |
| 926 | if ( drvstate->asic.ram[0x2801] == drvstate->asic.vpos - 1 ) // split occurs here (hopefully) |
| 996 | 927 | { |
| 997 | | logerror("SSCR: Split screen occured at scanline %d\n",asic.ram[0x2801]); |
| 928 | logerror("SSCR: Split screen occured at scanline %d\n",drvstate->asic.ram[0x2801]); |
| 998 | 929 | } |
| 999 | 930 | } |
| 1000 | 931 | // CPC+/GX4000 DMA channels |
| 1001 | 932 | amstrad_plus_handle_dma(device->machine); // a DMA command is handled at the leading edge of HSYNC (every 64us) |
| 1002 | | if(asic.de_start != 0) |
| 1003 | | asic.vpos++; |
| 933 | if(drvstate->asic.de_start != 0) |
| 934 | drvstate->asic.vpos++; |
| 1004 | 935 | } |
| 1005 | 936 | } |
| 1006 | | gate_array.hsync = state ? 1 : 0; |
| 937 | drvstate->gate_array.hsync = state ? 1 : 0; |
| 1007 | 938 | } |
| 1008 | 939 | |
| 1009 | 940 | |
| 1010 | 941 | static WRITE_LINE_DEVICE_HANDLER( amstrad_vsync_changed ) |
| 1011 | 942 | { |
| 943 | amstrad_state *drvstate = device->machine->driver_data<amstrad_state>(); |
| 1012 | 944 | amstrad_update_video( device->machine ); |
| 1013 | 945 | |
| 1014 | | if ( ! gate_array.vsync && state ) |
| 946 | if ( ! drvstate->gate_array.vsync && state ) |
| 1015 | 947 | { |
| 1016 | 948 | /* Reset the amstrad_CRTC_HS_After_VS_Counter */ |
| 1017 | | gate_array.hsync_after_vsync_counter = 3; |
| 949 | drvstate->gate_array.hsync_after_vsync_counter = 3; |
| 1018 | 950 | |
| 1019 | 951 | /* Start of new frame */ |
| 1020 | | gate_array.y = -1; |
| 1021 | | asic.vpos = 1; |
| 1022 | | asic.de_start = 0; |
| 952 | drvstate->gate_array.y = -1; |
| 953 | drvstate->asic.vpos = 1; |
| 954 | drvstate->asic.de_start = 0; |
| 1023 | 955 | } |
| 1024 | 956 | |
| 1025 | | gate_array.vsync = state ? 1 : 0; |
| 957 | drvstate->gate_array.vsync = state ? 1 : 0; |
| 1026 | 958 | |
| 1027 | 959 | /* Schedule a write to PC2 */ |
| 1028 | 960 | timer_set( device->machine, attotime_zero, NULL, 0, amstrad_pc2_low ); |
| r9648 | r9649 | |
| 1031 | 963 | |
| 1032 | 964 | static WRITE_LINE_DEVICE_HANDLER( amstrad_plus_vsync_changed ) |
| 1033 | 965 | { |
| 966 | amstrad_state *drvstate = device->machine->driver_data<amstrad_state>(); |
| 1034 | 967 | amstrad_plus_update_video( device->machine ); |
| 1035 | 968 | |
| 1036 | | if ( ! gate_array.vsync && state ) |
| 969 | if ( ! drvstate->gate_array.vsync && state ) |
| 1037 | 970 | { |
| 1038 | 971 | /* Reset the amstrad_CRTC_HS_After_VS_Counter */ |
| 1039 | | gate_array.hsync_after_vsync_counter = 3; |
| 972 | drvstate->gate_array.hsync_after_vsync_counter = 3; |
| 1040 | 973 | |
| 1041 | 974 | /* Start of new frame */ |
| 1042 | | gate_array.y = -1; |
| 1043 | | asic.vpos = 1; |
| 1044 | | asic.de_start = 0; |
| 975 | drvstate->gate_array.y = -1; |
| 976 | drvstate->asic.vpos = 1; |
| 977 | drvstate->asic.de_start = 0; |
| 1045 | 978 | } |
| 1046 | 979 | |
| 1047 | | gate_array.vsync = state ? 1 : 0; |
| 980 | drvstate->gate_array.vsync = state ? 1 : 0; |
| 1048 | 981 | |
| 1049 | 982 | /* Schedule a write to PC2 */ |
| 1050 | 983 | timer_set( device->machine, attotime_zero, NULL, 0, amstrad_pc2_low ); |
| r9648 | r9649 | |
| 1053 | 986 | |
| 1054 | 987 | static WRITE_LINE_DEVICE_HANDLER( amstrad_de_changed ) |
| 1055 | 988 | { |
| 989 | amstrad_state *drvstate = device->machine->driver_data<amstrad_state>(); |
| 1056 | 990 | amstrad_update_video( device->machine ); |
| 1057 | 991 | |
| 1058 | | if ( ! gate_array.de && state ) |
| 992 | if ( ! drvstate->gate_array.de && state ) |
| 1059 | 993 | { |
| 1060 | 994 | /* DE became active, store the starting MA and RA signals */ |
| 1061 | 995 | running_device *mc6845 = device->machine->device("mc6845" ); |
| 1062 | 996 | |
| 1063 | | gate_array.ma = mc6845_get_ma( mc6845 ); |
| 1064 | | gate_array.ra = mc6845_get_ra( mc6845 ); |
| 1065 | | logerror("y = %d; ma = %02x; ra = %02x, address = %04x\n", gate_array.y, gate_array.ma, gate_array.ra, ( ( gate_array.ma & 0x3000 ) << 2 ) | ( ( gate_array.ra & 0x07 ) << 11 ) | ( ( gate_array.ma & 0x3ff ) << 1 ) ); |
| 997 | drvstate->gate_array.ma = mc6845_get_ma( mc6845 ); |
| 998 | drvstate->gate_array.ra = mc6845_get_ra( mc6845 ); |
| 999 | logerror("y = %d; ma = %02x; ra = %02x, address = %04x\n", drvstate->gate_array.y, drvstate->gate_array.ma, drvstate->gate_array.ra, ( ( drvstate->gate_array.ma & 0x3000 ) << 2 ) | ( ( drvstate->gate_array.ra & 0x07 ) << 11 ) | ( ( drvstate->gate_array.ma & 0x3ff ) << 1 ) ); |
| 1066 | 1000 | amstrad_gate_array_get_video_data( device->machine ); |
| 1067 | | asic.de_start = 1; |
| 1001 | drvstate->asic.de_start = 1; |
| 1068 | 1002 | } |
| 1069 | 1003 | |
| 1070 | | gate_array.de = state ? 1 : 0; |
| 1004 | drvstate->gate_array.de = state ? 1 : 0; |
| 1071 | 1005 | } |
| 1072 | 1006 | |
| 1073 | 1007 | |
| 1074 | 1008 | static WRITE_LINE_DEVICE_HANDLER( amstrad_plus_de_changed ) |
| 1075 | 1009 | { |
| 1010 | amstrad_state *drvstate = device->machine->driver_data<amstrad_state>(); |
| 1076 | 1011 | amstrad_plus_update_video( device->machine ); |
| 1077 | 1012 | |
| 1078 | | if ( ! gate_array.de && state ) |
| 1013 | if ( ! drvstate->gate_array.de && state ) |
| 1079 | 1014 | { |
| 1080 | 1015 | /* DE became active, store the starting MA and RA signals */ |
| 1081 | 1016 | running_device *mc6845 = device->machine->device("mc6845" ); |
| 1082 | 1017 | |
| 1083 | | gate_array.ma = mc6845_get_ma( mc6845 ); |
| 1084 | | gate_array.ra = mc6845_get_ra( mc6845 ); |
| 1085 | | asic.h_start = gate_array.line_ticks; |
| 1086 | | asic.de_start = 1; |
| 1018 | drvstate->gate_array.ma = mc6845_get_ma( mc6845 ); |
| 1019 | drvstate->gate_array.ra = mc6845_get_ra( mc6845 ); |
| 1020 | drvstate->asic.h_start = drvstate->gate_array.line_ticks; |
| 1021 | drvstate->asic.de_start = 1; |
| 1087 | 1022 | |
| 1088 | 1023 | /* Start of screen */ |
| 1089 | | if ( asic.vpos == 1 ) |
| 1024 | if ( drvstate->asic.vpos == 1 ) |
| 1090 | 1025 | { |
| 1091 | | asic.split_ma_base = 0x0000; |
| 1092 | | asic.split_ma_started = 0x0000; |
| 1026 | drvstate->asic.split_ma_base = 0x0000; |
| 1027 | drvstate->asic.split_ma_started = 0x0000; |
| 1093 | 1028 | } |
| 1094 | 1029 | /* Start of split screen section */ |
| 1095 | | else if ( asic.enabled && asic.ram[0x2801] != 0 && asic.ram[0x2801] == asic.vpos - 1 ) |
| 1030 | else if ( drvstate->asic.enabled && drvstate->asic.ram[0x2801] != 0 && drvstate->asic.ram[0x2801] == drvstate->asic.vpos - 1 ) |
| 1096 | 1031 | { |
| 1097 | | asic.split_ma_started = gate_array.ma; |
| 1098 | | asic.split_ma_base = ( asic.ram[0x2802] << 8 ) | asic.ram[0x2803]; |
| 1032 | drvstate->asic.split_ma_started = drvstate->gate_array.ma; |
| 1033 | drvstate->asic.split_ma_base = ( drvstate->asic.ram[0x2802] << 8 ) | drvstate->asic.ram[0x2803]; |
| 1099 | 1034 | } |
| 1100 | 1035 | |
| 1101 | | gate_array.colour = asic.ram[0x2420] + ( asic.ram[0x2421] << 8 ); |
| 1102 | | asic.hscroll = asic.ram[0x2804] & 0x0f; |
| 1036 | drvstate->gate_array.colour = drvstate->asic.ram[0x2420] + ( drvstate->asic.ram[0x2421] << 8 ); |
| 1037 | drvstate->asic.hscroll = drvstate->asic.ram[0x2804] & 0x0f; |
| 1103 | 1038 | |
| 1104 | | if ( asic.hscroll == 0 ) |
| 1039 | if ( drvstate->asic.hscroll == 0 ) |
| 1105 | 1040 | amstrad_plus_gate_array_get_video_data( device->machine ); |
| 1106 | 1041 | } |
| 1107 | 1042 | |
| 1108 | | if ( gate_array.de && ! state ) |
| 1043 | if ( drvstate->gate_array.de && ! state ) |
| 1109 | 1044 | { |
| 1110 | | asic.h_end = gate_array.line_ticks; |
| 1045 | drvstate->asic.h_end = drvstate->gate_array.line_ticks; |
| 1111 | 1046 | amstrad_plus_update_video_sprites( device->machine ); |
| 1112 | 1047 | } |
| 1113 | 1048 | |
| 1114 | | gate_array.de = state ? 1 : 0; |
| 1049 | drvstate->gate_array.de = state ? 1 : 0; |
| 1115 | 1050 | } |
| 1116 | 1051 | |
| 1117 | 1052 | |
| 1118 | 1053 | VIDEO_START( amstrad ) |
| 1119 | 1054 | { |
| 1055 | amstrad_state *state = machine->driver_data<amstrad_state>(); |
| 1120 | 1056 | screen_device *screen = downcast<screen_device *>(machine->device("screen")); |
| 1121 | 1057 | |
| 1122 | | amstrad_init_lookups(); |
| 1058 | amstrad_init_lookups(state); |
| 1123 | 1059 | |
| 1124 | | gate_array.bitmap = auto_bitmap_alloc( machine, screen->width(), screen->height(), screen->format() ); |
| 1125 | | gate_array.hsync_after_vsync_counter = 3; |
| 1060 | state->gate_array.bitmap = auto_bitmap_alloc( machine, screen->width(), screen->height(), screen->format() ); |
| 1061 | state->gate_array.hsync_after_vsync_counter = 3; |
| 1126 | 1062 | } |
| 1127 | 1063 | |
| 1128 | 1064 | |
| 1129 | 1065 | VIDEO_UPDATE( amstrad ) |
| 1130 | 1066 | { |
| 1131 | | copybitmap( bitmap, gate_array.bitmap, 0, 0, 0, 0, cliprect ); |
| 1067 | amstrad_state *state = screen->machine->driver_data<amstrad_state>(); |
| 1068 | copybitmap( bitmap, state->gate_array.bitmap, 0, 0, 0, 0, cliprect ); |
| 1132 | 1069 | return 0; |
| 1133 | 1070 | } |
| 1134 | 1071 | |
| r9648 | r9649 | |
| 1167 | 1104 | Multiface emulation |
| 1168 | 1105 | ****************************************************************************************/ |
| 1169 | 1106 | |
| 1170 | | static unsigned char *multiface_ram; |
| 1171 | | static unsigned long multiface_flags; |
| 1172 | 1107 | |
| 1173 | 1108 | /* stop button has been pressed */ |
| 1174 | 1109 | #define MULTIFACE_STOP_BUTTON_PRESSED 0x0001 |
| r9648 | r9649 | |
| 1192 | 1127 | /* used to setup computer if a snapshot was specified */ |
| 1193 | 1128 | DIRECT_UPDATE_HANDLER( amstrad_multiface_directoverride ) |
| 1194 | 1129 | { |
| 1130 | amstrad_state *state = machine->driver_data<amstrad_state>(); |
| 1195 | 1131 | int pc; |
| 1196 | 1132 | |
| 1197 | 1133 | pc = cpu_get_pc(machine->device("maincpu")); |
| r9648 | r9649 | |
| 1213 | 1149 | if (pc==0x0164) |
| 1214 | 1150 | { |
| 1215 | 1151 | /* first call? */ |
| 1216 | | multiface_flags |= MULTIFACE_VISIBLE; |
| 1152 | state->multiface_flags |= MULTIFACE_VISIBLE; |
| 1217 | 1153 | } |
| 1218 | 1154 | else if (pc==0x0c98) |
| 1219 | 1155 | { |
| 1220 | 1156 | /* second call */ |
| 1221 | 1157 | |
| 1222 | 1158 | /* no longer visible */ |
| 1223 | | multiface_flags &= ~(MULTIFACE_VISIBLE|MULTIFACE_STOP_BUTTON_PRESSED); |
| 1159 | state->multiface_flags &= ~(MULTIFACE_VISIBLE|MULTIFACE_STOP_BUTTON_PRESSED); |
| 1224 | 1160 | |
| 1225 | 1161 | /* clear op base override */ |
| 1226 | 1162 | cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM)->set_direct_update_handler(direct_update_delegate_create_static(amstrad_default, *machine)); |
| r9648 | r9649 | |
| 1231 | 1167 | |
| 1232 | 1168 | static void multiface_init(running_machine *machine) |
| 1233 | 1169 | { |
| 1170 | amstrad_state *state = machine->driver_data<amstrad_state>(); |
| 1234 | 1171 | /* after a reset the multiface is visible */ |
| 1235 | | multiface_flags = MULTIFACE_VISIBLE; |
| 1172 | state->multiface_flags = MULTIFACE_VISIBLE; |
| 1236 | 1173 | |
| 1237 | 1174 | /* allocate ram */ |
| 1238 | | multiface_ram = auto_alloc_array(machine, UINT8, 8192); |
| 1175 | state->multiface_ram = auto_alloc_array(machine, UINT8, 8192); |
| 1239 | 1176 | } |
| 1240 | 1177 | |
| 1241 | 1178 | /* call when a system reset is done */ |
| 1242 | | static void multiface_reset(void) |
| 1179 | static void multiface_reset(amstrad_state *state) |
| 1243 | 1180 | { |
| 1244 | 1181 | /* stop button not pressed and ram/rom disabled */ |
| 1245 | | multiface_flags &= ~(MULTIFACE_STOP_BUTTON_PRESSED | |
| 1182 | state->multiface_flags &= ~(MULTIFACE_STOP_BUTTON_PRESSED | |
| 1246 | 1183 | MULTIFACE_RAM_ROM_ENABLED); |
| 1247 | 1184 | /* as on the real hardware the multiface is visible after a reset! */ |
| 1248 | | multiface_flags |= MULTIFACE_VISIBLE; |
| 1185 | state->multiface_flags |= MULTIFACE_VISIBLE; |
| 1249 | 1186 | } |
| 1250 | 1187 | |
| 1251 | 1188 | static int multiface_hardware_enabled(running_machine *machine) |
| 1252 | 1189 | { |
| 1253 | | if (multiface_ram!=NULL) |
| 1190 | amstrad_state *state = machine->driver_data<amstrad_state>(); |
| 1191 | if (state->multiface_ram!=NULL) |
| 1254 | 1192 | { |
| 1255 | 1193 | if ((input_port_read(machine, "multiface") & 0x01)!=0) |
| 1256 | 1194 | { |
| r9648 | r9649 | |
| 1264 | 1202 | |
| 1265 | 1203 | static void multiface_rethink_memory(running_machine *machine) |
| 1266 | 1204 | { |
| 1205 | amstrad_state *state = machine->driver_data<amstrad_state>(); |
| 1267 | 1206 | unsigned char *multiface_rom; |
| 1268 | 1207 | |
| 1269 | 1208 | /* multiface hardware enabled? */ |
| r9648 | r9649 | |
| 1273 | 1212 | multiface_rom = &memory_region(machine, "maincpu")[0x01C000]; |
| 1274 | 1213 | |
| 1275 | 1214 | if ( |
| 1276 | | ((multiface_flags & MULTIFACE_RAM_ROM_ENABLED)!=0) && |
| 1277 | | ((gate_array.mrer & 0x04) == 0) |
| 1215 | ((state->multiface_flags & MULTIFACE_RAM_ROM_ENABLED)!=0) && |
| 1216 | ((state->gate_array.mrer & 0x04) == 0) |
| 1278 | 1217 | ) |
| 1279 | 1218 | { |
| 1280 | 1219 | |
| 1281 | 1220 | /* set bank addressess */ |
| 1282 | 1221 | memory_set_bankptr(machine,"bank1", multiface_rom); |
| 1283 | | memory_set_bankptr(machine,"bank2", multiface_ram); |
| 1222 | memory_set_bankptr(machine,"bank2", state->multiface_ram); |
| 1284 | 1223 | memory_set_bankptr(machine,"bank9", multiface_rom); |
| 1285 | | memory_set_bankptr(machine,"bank10", multiface_ram); |
| 1224 | memory_set_bankptr(machine,"bank10", state->multiface_ram); |
| 1286 | 1225 | } |
| 1287 | 1226 | } |
| 1288 | 1227 | |
| r9648 | r9649 | |
| 1290 | 1229 | /* simulate the stop button has been pressed */ |
| 1291 | 1230 | static void multiface_stop(running_machine *machine) |
| 1292 | 1231 | { |
| 1232 | amstrad_state *state = machine->driver_data<amstrad_state>(); |
| 1293 | 1233 | /* multiface hardware enabled? */ |
| 1294 | 1234 | if (!multiface_hardware_enabled(machine)) |
| 1295 | 1235 | return; |
| 1296 | 1236 | |
| 1297 | 1237 | /* if stop button not already pressed, do press action */ |
| 1298 | 1238 | /* pressing stop button while multiface is running has no effect */ |
| 1299 | | if ((multiface_flags & MULTIFACE_STOP_BUTTON_PRESSED)==0) |
| 1239 | if ((state->multiface_flags & MULTIFACE_STOP_BUTTON_PRESSED)==0) |
| 1300 | 1240 | { |
| 1301 | 1241 | /* initialise 0065 toggle */ |
| 1302 | | /*multiface_flags &= ~MULTIFACE_0065_TOGGLE;*/ |
| 1242 | /*state->multiface_flags &= ~MULTIFACE_0065_TOGGLE;*/ |
| 1303 | 1243 | |
| 1304 | | multiface_flags |= MULTIFACE_RAM_ROM_ENABLED; |
| 1244 | state->multiface_flags |= MULTIFACE_RAM_ROM_ENABLED; |
| 1305 | 1245 | |
| 1306 | 1246 | /* stop button has been pressed, furthur pressess will not issue a NMI */ |
| 1307 | | multiface_flags |= MULTIFACE_STOP_BUTTON_PRESSED; |
| 1247 | state->multiface_flags |= MULTIFACE_STOP_BUTTON_PRESSED; |
| 1308 | 1248 | |
| 1309 | | gate_array.mrer &=~0x04; |
| 1249 | state->gate_array.mrer &=~0x04; |
| 1310 | 1250 | |
| 1311 | 1251 | /* page rom into memory */ |
| 1312 | 1252 | multiface_rethink_memory(machine); |
| r9648 | r9649 | |
| 1324 | 1264 | /* any io writes are passed through here */ |
| 1325 | 1265 | static WRITE8_HANDLER(multiface_io_write) |
| 1326 | 1266 | { |
| 1267 | amstrad_state *state = space->machine->driver_data<amstrad_state>(); |
| 1327 | 1268 | /* multiface hardware enabled? */ |
| 1328 | 1269 | if (!multiface_hardware_enabled(space->machine)) |
| 1329 | 1270 | return; |
| 1330 | 1271 | |
| 1331 | 1272 | /* visible? */ |
| 1332 | | if (multiface_flags & MULTIFACE_VISIBLE) |
| 1273 | if (state->multiface_flags & MULTIFACE_VISIBLE) |
| 1333 | 1274 | { |
| 1334 | 1275 | if (offset==0x0fee8) |
| 1335 | 1276 | { |
| 1336 | | multiface_flags |= MULTIFACE_RAM_ROM_ENABLED; |
| 1277 | state->multiface_flags |= MULTIFACE_RAM_ROM_ENABLED; |
| 1337 | 1278 | amstrad_rethinkMemory(space->machine); |
| 1338 | 1279 | } |
| 1339 | 1280 | |
| 1340 | 1281 | if (offset==0x0feea) |
| 1341 | 1282 | { |
| 1342 | | multiface_flags &= ~MULTIFACE_RAM_ROM_ENABLED; |
| 1283 | state->multiface_flags &= ~MULTIFACE_RAM_ROM_ENABLED; |
| 1343 | 1284 | amstrad_rethinkMemory(space->machine); |
| 1344 | 1285 | } |
| 1345 | 1286 | } |
| r9648 | r9649 | |
| 1356 | 1297 | /* pen index */ |
| 1357 | 1298 | case 0x00: |
| 1358 | 1299 | { |
| 1359 | | multiface_ram[0x01fcf] = data; |
| 1300 | state->multiface_ram[0x01fcf] = data; |
| 1360 | 1301 | |
| 1361 | 1302 | } |
| 1362 | 1303 | break; |
| r9648 | r9649 | |
| 1366 | 1307 | { |
| 1367 | 1308 | int pen_index; |
| 1368 | 1309 | |
| 1369 | | pen_index = multiface_ram[0x01fcf] & 0x0f; |
| 1310 | pen_index = state->multiface_ram[0x01fcf] & 0x0f; |
| 1370 | 1311 | |
| 1371 | | if (multiface_ram[0x01fcf] & 0x010) |
| 1312 | if (state->multiface_ram[0x01fcf] & 0x010) |
| 1372 | 1313 | { |
| 1373 | 1314 | |
| 1374 | | multiface_ram[0x01fdf + pen_index] = data; |
| 1315 | state->multiface_ram[0x01fdf + pen_index] = data; |
| 1375 | 1316 | } |
| 1376 | 1317 | else |
| 1377 | 1318 | { |
| 1378 | | multiface_ram[0x01f90 + pen_index] = data & 0x01f; |
| 1319 | state->multiface_ram[0x01f90 + pen_index] = data & 0x01f; |
| 1379 | 1320 | } |
| 1380 | 1321 | |
| 1381 | 1322 | } |
| r9648 | r9649 | |
| 1385 | 1326 | case 0x080: |
| 1386 | 1327 | { |
| 1387 | 1328 | |
| 1388 | | multiface_ram[0x01fef] = data; |
| 1329 | state->multiface_ram[0x01fef] = data; |
| 1389 | 1330 | |
| 1390 | 1331 | } |
| 1391 | 1332 | break; |
| r9648 | r9649 | |
| 1394 | 1335 | case 0x0c0: |
| 1395 | 1336 | { |
| 1396 | 1337 | |
| 1397 | | multiface_ram[0x01fff] = data; |
| 1338 | state->multiface_ram[0x01fff] = data; |
| 1398 | 1339 | |
| 1399 | 1340 | } |
| 1400 | 1341 | break; |
| r9648 | r9649 | |
| 1411 | 1352 | /* crtc register index */ |
| 1412 | 1353 | case 0x0bc: |
| 1413 | 1354 | { |
| 1414 | | multiface_ram[0x01cff] = data; |
| 1355 | state->multiface_ram[0x01cff] = data; |
| 1415 | 1356 | } |
| 1416 | 1357 | break; |
| 1417 | 1358 | |
| r9648 | r9649 | |
| 1420 | 1361 | { |
| 1421 | 1362 | int reg_index; |
| 1422 | 1363 | |
| 1423 | | reg_index = multiface_ram[0x01cff] & 0x0f; |
| 1364 | reg_index = state->multiface_ram[0x01cff] & 0x0f; |
| 1424 | 1365 | |
| 1425 | | multiface_ram[0x01db0 + reg_index] = data; |
| 1366 | state->multiface_ram[0x01db0 + reg_index] = data; |
| 1426 | 1367 | } |
| 1427 | 1368 | break; |
| 1428 | 1369 | |
| r9648 | r9649 | |
| 1430 | 1371 | /* 8255 ppi control */ |
| 1431 | 1372 | case 0x0f7: |
| 1432 | 1373 | { |
| 1433 | | multiface_ram[0x017ff] = data; |
| 1374 | state->multiface_ram[0x017ff] = data; |
| 1434 | 1375 | |
| 1435 | 1376 | } |
| 1436 | 1377 | break; |
| r9648 | r9649 | |
| 1438 | 1379 | /* rom select */ |
| 1439 | 1380 | case 0x0df: |
| 1440 | 1381 | { |
| 1441 | | multiface_ram[0x01aac] = data; |
| 1382 | state->multiface_ram[0x01aac] = data; |
| 1442 | 1383 | } |
| 1443 | 1384 | break; |
| 1444 | 1385 | |
| r9648 | r9649 | |
| 1458 | 1399 | -----------------*/ |
| 1459 | 1400 | static void amstrad_setLowerRom(running_machine *machine) |
| 1460 | 1401 | { |
| 1402 | amstrad_state *state = machine->driver_data<amstrad_state>(); |
| 1461 | 1403 | UINT8 *bank_base; |
| 1462 | 1404 | |
| 1463 | 1405 | /* b2 : "1" Lower rom area disable or "0" Lower rom area enable */ |
| 1464 | | if ( amstrad_system_type == SYSTEM_CPC || amstrad_system_type == SYSTEM_ALESTE ) |
| 1406 | if ( state->system_type == SYSTEM_CPC || state->system_type == SYSTEM_ALESTE ) |
| 1465 | 1407 | { |
| 1466 | | if ((gate_array.mrer & (1<<2)) == 0) |
| 1408 | if ((state->gate_array.mrer & (1<<2)) == 0) |
| 1467 | 1409 | { |
| 1468 | 1410 | bank_base = &memory_region(machine, "maincpu")[0x010000]; |
| 1469 | 1411 | } |
| 1470 | 1412 | else |
| 1471 | 1413 | { |
| 1472 | | if(aleste_mode & 0x04) |
| 1473 | | bank_base = Aleste_RamBanks[0]; |
| 1414 | if(state->aleste_mode & 0x04) |
| 1415 | bank_base = state->Aleste_RamBanks[0]; |
| 1474 | 1416 | else |
| 1475 | | bank_base = AmstradCPC_RamBanks[0]; |
| 1417 | bank_base = state->AmstradCPC_RamBanks[0]; |
| 1476 | 1418 | } |
| 1477 | 1419 | memory_set_bankptr(machine,"bank1", bank_base); |
| 1478 | 1420 | memory_set_bankptr(machine,"bank2", bank_base+0x02000); |
| r9648 | r9649 | |
| 1481 | 1423 | { |
| 1482 | 1424 | address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 1483 | 1425 | |
| 1484 | | if ( asic.enabled && ( asic.rmr2 & 0x18 ) == 0x18 ) |
| 1426 | if ( state->asic.enabled && ( state->asic.rmr2 & 0x18 ) == 0x18 ) |
| 1485 | 1427 | { |
| 1486 | 1428 | memory_install_read8_handler(space, 0x4000, 0x5fff, 0, 0, amstrad_plus_asic_4000_r); |
| 1487 | 1429 | memory_install_read8_handler(space, 0x6000, 0x7fff, 0, 0, amstrad_plus_asic_6000_r); |
| r9648 | r9649 | |
| 1496 | 1438 | memory_install_write_bank(space, 0x6000, 0x7fff, 0, 0, "bank12"); |
| 1497 | 1439 | } |
| 1498 | 1440 | |
| 1499 | | if(AmstradCPC_RamBanks[0] != NULL) |
| 1441 | if(state->AmstradCPC_RamBanks[0] != NULL) |
| 1500 | 1442 | { |
| 1501 | | memory_set_bankptr(machine,"bank1", AmstradCPC_RamBanks[0]); |
| 1502 | | memory_set_bankptr(machine,"bank2", AmstradCPC_RamBanks[0]+0x2000); |
| 1503 | | memory_set_bankptr(machine,"bank3", AmstradCPC_RamBanks[1]); |
| 1504 | | memory_set_bankptr(machine,"bank4", AmstradCPC_RamBanks[1]+0x2000); |
| 1505 | | memory_set_bankptr(machine,"bank5", AmstradCPC_RamBanks[2]); |
| 1506 | | memory_set_bankptr(machine,"bank6", AmstradCPC_RamBanks[2]+0x2000); |
| 1443 | memory_set_bankptr(machine,"bank1", state->AmstradCPC_RamBanks[0]); |
| 1444 | memory_set_bankptr(machine,"bank2", state->AmstradCPC_RamBanks[0]+0x2000); |
| 1445 | memory_set_bankptr(machine,"bank3", state->AmstradCPC_RamBanks[1]); |
| 1446 | memory_set_bankptr(machine,"bank4", state->AmstradCPC_RamBanks[1]+0x2000); |
| 1447 | memory_set_bankptr(machine,"bank5", state->AmstradCPC_RamBanks[2]); |
| 1448 | memory_set_bankptr(machine,"bank6", state->AmstradCPC_RamBanks[2]+0x2000); |
| 1507 | 1449 | } |
| 1508 | 1450 | |
| 1509 | | if ( (gate_array.mrer & (1<<2)) == 0) |
| 1451 | if ( (state->gate_array.mrer & (1<<2)) == 0) |
| 1510 | 1452 | { // ASIC secondary lower ROM selection (bit 5: 1 = enabled) |
| 1511 | | if ( asic.enabled ) |
| 1453 | if ( state->asic.enabled ) |
| 1512 | 1454 | { |
| 1513 | | // logerror("L-ROM: Lower ROM enabled, cart bank %i\n", asic.rmr2 & 0x07 ); |
| 1514 | | bank_base = &memory_region(machine, "maincpu")[0x4000 * ( asic.rmr2 & 0x07 )]; |
| 1515 | | switch( asic.rmr2 & 0x18 ) |
| 1455 | // logerror("L-ROM: Lower ROM enabled, cart bank %i\n", state->asic.rmr2 & 0x07 ); |
| 1456 | bank_base = &memory_region(machine, "maincpu")[0x4000 * ( state->asic.rmr2 & 0x07 )]; |
| 1457 | switch( state->asic.rmr2 & 0x18 ) |
| 1516 | 1458 | { |
| 1517 | 1459 | case 0x00: |
| 1518 | 1460 | // logerror("L-ROM: located at &0000\n"); |
| r9648 | r9649 | |
| 1551 | 1493 | -----------------*/ |
| 1552 | 1494 | static void amstrad_setUpperRom(running_machine *machine) |
| 1553 | 1495 | { |
| 1496 | amstrad_state *state = machine->driver_data<amstrad_state>(); |
| 1554 | 1497 | UINT8 *bank_base = NULL; |
| 1555 | 1498 | |
| 1556 | 1499 | /* b3 : "1" Upper rom area disable or "0" Upper rom area enable */ |
| 1557 | | if ( ! ( gate_array.mrer & 0x08 ) ) |
| 1500 | if ( ! ( state->gate_array.mrer & 0x08 ) ) |
| 1558 | 1501 | { |
| 1559 | | bank_base = Amstrad_ROM_Table[ gate_array.upper_bank ]; |
| 1502 | bank_base = state->Amstrad_ROM_Table[ state->gate_array.upper_bank ]; |
| 1560 | 1503 | } |
| 1561 | 1504 | else |
| 1562 | 1505 | { |
| 1563 | | if(aleste_mode & 0x04) |
| 1564 | | bank_base = Aleste_RamBanks[3]; |
| 1506 | if(state->aleste_mode & 0x04) |
| 1507 | bank_base = state->Aleste_RamBanks[3]; |
| 1565 | 1508 | else |
| 1566 | | bank_base = AmstradCPC_RamBanks[3]; |
| 1509 | bank_base = state->AmstradCPC_RamBanks[3]; |
| 1567 | 1510 | } |
| 1568 | 1511 | |
| 1569 | 1512 | if (bank_base) |
| r9648 | r9649 | |
| 1596 | 1539 | */ |
| 1597 | 1540 | static void AmstradCPC_GA_SetRamConfiguration(running_machine *machine) |
| 1598 | 1541 | { |
| 1599 | | int ConfigurationIndex = amstrad_GateArray_RamConfiguration & 0x07; |
| 1542 | amstrad_state *state = machine->driver_data<amstrad_state>(); |
| 1543 | int ConfigurationIndex = state->GateArray_RamConfiguration & 0x07; |
| 1600 | 1544 | int BankIndex,i; |
| 1601 | 1545 | unsigned char *BankAddr; |
| 1602 | 1546 | |
| 1603 | 1547 | /* if b5 = 0 */ |
| 1604 | | if(((amstrad_GateArray_RamConfiguration) & (1<<5)) == 0) |
| 1548 | if(((state->GateArray_RamConfiguration) & (1<<5)) == 0) |
| 1605 | 1549 | { |
| 1606 | 1550 | for (i=0;i<4;i++) |
| 1607 | 1551 | { |
| 1608 | 1552 | BankIndex = RamConfigurations[(ConfigurationIndex << 2) + i]; |
| 1609 | 1553 | BankAddr = messram_get_ptr(machine->device("messram")) + (BankIndex << 14); |
| 1610 | | Aleste_RamBanks[i] = BankAddr; |
| 1611 | | AmstradCPC_RamBanks[i] = BankAddr; |
| 1554 | state->Aleste_RamBanks[i] = BankAddr; |
| 1555 | state->AmstradCPC_RamBanks[i] = BankAddr; |
| 1612 | 1556 | } |
| 1613 | 1557 | } |
| 1614 | 1558 | else |
| r9648 | r9649 | |
| 1686 | 1630 | |
| 1687 | 1631 | WRITE8_HANDLER( amstrad_plus_asic_4000_w ) |
| 1688 | 1632 | { |
| 1633 | amstrad_state *state = space->machine->driver_data<amstrad_state>(); |
| 1689 | 1634 | // logerror("ASIC: Write to register at &%04x\n",offset+0x4000); |
| 1690 | | asic.ram[offset] = data & 0x0f; |
| 1635 | state->asic.ram[offset] = data & 0x0f; |
| 1691 | 1636 | } |
| 1692 | 1637 | |
| 1693 | 1638 | |
| 1694 | 1639 | WRITE8_HANDLER( amstrad_plus_asic_6000_w ) |
| 1695 | 1640 | { |
| 1696 | | asic.ram[offset+0x2000] = data; |
| 1641 | amstrad_state *state = space->machine->driver_data<amstrad_state>(); |
| 1642 | state->asic.ram[offset+0x2000] = data; |
| 1697 | 1643 | if(offset >= 0x0400 && offset < 0x440 && ( offset & 0x01 ) ) // ASIC palette |
| 1698 | 1644 | { |
| 1699 | | asic.ram[ offset + 0x2000 ] = data & 0x0f; |
| 1645 | state->asic.ram[ offset + 0x2000 ] = data & 0x0f; |
| 1700 | 1646 | } |
| 1701 | 1647 | if(offset == 0x0800) // Programmable raster interrupt |
| 1702 | 1648 | { |
| 1703 | 1649 | // logerror("ASIC: Wrote %02x to PRI\n",data); |
| 1704 | | asic.pri = data; |
| 1650 | state->asic.pri = data; |
| 1705 | 1651 | } |
| 1706 | 1652 | if(offset >= 0x0801 && offset <= 0x0803) // Split screen registers |
| 1707 | 1653 | { |
| 1708 | | logerror("ASIC: Split screen at line %i, address &%04x\n",asic.ram[0x2801],asic.ram[0x2803] + (asic.ram[0x2802] << 8)); |
| 1654 | logerror("ASIC: Split screen at line %i, address &%04x\n",state->asic.ram[0x2801],state->asic.ram[0x2803] + (state->asic.ram[0x2802] << 8)); |
| 1709 | 1655 | } |
| 1710 | 1656 | if(offset == 0x0804) // Soft scroll register |
| 1711 | 1657 | { |
| r9648 | r9649 | |
| 1715 | 1661 | // high 5 bits go to interrupt vector |
| 1716 | 1662 | int vector; |
| 1717 | 1663 | |
| 1718 | | if ( asic.enabled ) |
| 1664 | if ( state->asic.enabled ) |
| 1719 | 1665 | { |
| 1720 | | vector = (data & 0xf8) + (amstrad_plus_irq_cause); |
| 1666 | vector = (data & 0xf8) + (state->plus_irq_cause); |
| 1721 | 1667 | cpu_set_input_line_vector(space->machine->device("maincpu"), 0, vector); |
| 1722 | 1668 | logerror("ASIC: IM 2 vector write %02x, data = &%02x\n",vector,data); |
| 1723 | 1669 | } |
| 1724 | | asic.dma_clear = data & 0x01; |
| 1670 | state->asic.dma_clear = data & 0x01; |
| 1725 | 1671 | } |
| 1726 | 1672 | // DMA channels |
| 1727 | 1673 | switch(offset) |
| 1728 | 1674 | { |
| 1729 | 1675 | case 0x0c00: |
| 1730 | 1676 | case 0x0c01: |
| 1731 | | asic.dma_addr[0] = (asic.ram[0x2c01] << 8) + asic.ram[0x2c00]; |
| 1732 | | asic.dma_status &= ~0x01; |
| 1733 | | logerror("ASIC: DMA 0 address set to &%04x\n",asic.dma_addr[0]); |
| 1677 | state->asic.dma_addr[0] = (state->asic.ram[0x2c01] << 8) + state->asic.ram[0x2c00]; |
| 1678 | state->asic.dma_status &= ~0x01; |
| 1679 | logerror("ASIC: DMA 0 address set to &%04x\n",state->asic.dma_addr[0]); |
| 1734 | 1680 | break; |
| 1735 | 1681 | case 0x0c04: |
| 1736 | 1682 | case 0x0c05: |
| 1737 | | asic.dma_addr[1] = (asic.ram[0x2c05] << 8) + asic.ram[0x2c04]; |
| 1738 | | asic.dma_status &= ~0x02; |
| 1739 | | logerror("ASIC: DMA 1 address set to &%04x\n",asic.dma_addr[1]); |
| 1683 | state->asic.dma_addr[1] = (state->asic.ram[0x2c05] << 8) + state->asic.ram[0x2c04]; |
| 1684 | state->asic.dma_status &= ~0x02; |
| 1685 | logerror("ASIC: DMA 1 address set to &%04x\n",state->asic.dma_addr[1]); |
| 1740 | 1686 | break; |
| 1741 | 1687 | case 0x0c08: |
| 1742 | 1688 | case 0x0c09: |
| 1743 | | asic.dma_addr[2] = (asic.ram[0x2c09] << 8) + asic.ram[0x2c08]; |
| 1744 | | asic.dma_status &= ~0x04; |
| 1745 | | logerror("ASIC: DMA 2 address set to &%04x\n",asic.dma_addr[2]); |
| 1689 | state->asic.dma_addr[2] = (state->asic.ram[0x2c09] << 8) + state->asic.ram[0x2c08]; |
| 1690 | state->asic.dma_status &= ~0x04; |
| 1691 | logerror("ASIC: DMA 2 address set to &%04x\n",state->asic.dma_addr[2]); |
| 1746 | 1692 | break; |
| 1747 | 1693 | case 0x0c02: |
| 1748 | | asic.dma_prescaler[0] = data + 1; |
| 1694 | state->asic.dma_prescaler[0] = data + 1; |
| 1749 | 1695 | logerror("ASIC: DMA 0 pause prescaler set to %i\n",data); |
| 1750 | 1696 | break; |
| 1751 | 1697 | case 0x0c06: |
| 1752 | | asic.dma_prescaler[1] = data + 1; |
| 1698 | state->asic.dma_prescaler[1] = data + 1; |
| 1753 | 1699 | logerror("ASIC: DMA 1 pause prescaler set to %i\n",data); |
| 1754 | 1700 | break; |
| 1755 | 1701 | case 0x0c0a: |
| 1756 | | asic.dma_prescaler[2] = data + 1; |
| 1702 | state->asic.dma_prescaler[2] = data + 1; |
| 1757 | 1703 | logerror("ASIC: DMA 2 pause prescaler set to %i\n",data); |
| 1758 | 1704 | break; |
| 1759 | 1705 | case 0x0c0f: |
| 1760 | | asic.dma_status = data; |
| 1706 | state->asic.dma_status = data; |
| 1761 | 1707 | logerror("ASIC: DMA status write - %02x\n",data); |
| 1762 | 1708 | if(data & 0x40) |
| 1763 | 1709 | { |
| 1764 | 1710 | logerror("ASIC: DMA 0 IRQ acknowledge\n"); |
| 1765 | 1711 | cputag_set_input_line(space->machine, "maincpu", 0, CLEAR_LINE); |
| 1766 | | amstrad_plus_irq_cause = 0x06; |
| 1767 | | asic.ram[0x2c0f] &= ~0x40; |
| 1712 | state->plus_irq_cause = 0x06; |
| 1713 | state->asic.ram[0x2c0f] &= ~0x40; |
| 1768 | 1714 | } |
| 1769 | 1715 | if(data & 0x20) |
| 1770 | 1716 | { |
| 1771 | 1717 | logerror("ASIC: DMA 1 IRQ acknowledge\n"); |
| 1772 | 1718 | cputag_set_input_line(space->machine, "maincpu", 0, CLEAR_LINE); |
| 1773 | | amstrad_plus_irq_cause = 0x06; |
| 1774 | | asic.ram[0x2c0f] &= ~0x20; |
| 1719 | state->plus_irq_cause = 0x06; |
| 1720 | state->asic.ram[0x2c0f] &= ~0x20; |
| 1775 | 1721 | } |
| 1776 | 1722 | if(data & 0x10) |
| 1777 | 1723 | { |
| 1778 | 1724 | logerror("ASIC: DMA 2 IRQ acknowledge\n"); |
| 1779 | 1725 | cputag_set_input_line(space->machine, "maincpu", 0, CLEAR_LINE); |
| 1780 | | amstrad_plus_irq_cause = 0x06; |
| 1781 | | asic.ram[0x2c0f] &= ~0x10; |
| 1726 | state->plus_irq_cause = 0x06; |
| 1727 | state->asic.ram[0x2c0f] &= ~0x10; |
| 1782 | 1728 | } |
| 1783 | 1729 | break; |
| 1784 | 1730 | } |
| r9648 | r9649 | |
| 1787 | 1733 | |
| 1788 | 1734 | READ8_HANDLER( amstrad_plus_asic_4000_r ) |
| 1789 | 1735 | { |
| 1736 | amstrad_state *state = space->machine->driver_data<amstrad_state>(); |
| 1790 | 1737 | // logerror("RAM: read from &%04x\n",offset+0x4000); |
| 1791 | | return asic.ram[offset]; |
| 1738 | return state->asic.ram[offset]; |
| 1792 | 1739 | } |
| 1793 | 1740 | |
| 1794 | 1741 | |
| 1795 | 1742 | READ8_HANDLER( amstrad_plus_asic_6000_r ) |
| 1796 | 1743 | { |
| 1744 | amstrad_state *state = space->machine->driver_data<amstrad_state>(); |
| 1797 | 1745 | // logerror("RAM: read from &%04x\n",offset+0x6000); |
| 1798 | 1746 | // Analogue ports |
| 1799 | 1747 | if(offset == 0x0808) |
| r9648 | r9649 | |
| 1824 | 1772 | if(offset == 0x0c0f) // DMA status and control |
| 1825 | 1773 | { |
| 1826 | 1774 | int result = 0; |
| 1827 | | if(amstrad_plus_irq_cause == 0x00) |
| 1775 | if(state->plus_irq_cause == 0x00) |
| 1828 | 1776 | result |= 0x40; |
| 1829 | | if(amstrad_plus_irq_cause == 0x02) |
| 1777 | if(state->plus_irq_cause == 0x02) |
| 1830 | 1778 | result |= 0x20; |
| 1831 | | if(amstrad_plus_irq_cause == 0x04) |
| 1779 | if(state->plus_irq_cause == 0x04) |
| 1832 | 1780 | result |= 0x10; |
| 1833 | | if(amstrad_plus_irq_cause == 0x06) |
| 1781 | if(state->plus_irq_cause == 0x06) |
| 1834 | 1782 | result |= 0x80; |
| 1835 | 1783 | return result; |
| 1836 | 1784 | } |
| 1837 | 1785 | #endif |
| 1838 | | return asic.ram[offset+0x2000]; |
| 1786 | return state->asic.ram[offset+0x2000]; |
| 1839 | 1787 | } |
| 1840 | 1788 | |
| 1841 | 1789 | |
| 1842 | 1790 | /* used for loading snapshot only ! */ |
| 1843 | 1791 | static void AmstradCPC_PALWrite(running_machine *machine, int data) |
| 1844 | 1792 | { |
| 1793 | amstrad_state *state = machine->driver_data<amstrad_state>(); |
| 1845 | 1794 | if ((data & 0x0c0)==0x0c0) |
| 1846 | 1795 | { |
| 1847 | | amstrad_GateArray_RamConfiguration = data; |
| 1796 | state->GateArray_RamConfiguration = data; |
| 1848 | 1797 | AmstradCPC_GA_SetRamConfiguration(machine); |
| 1849 | 1798 | } |
| 1850 | 1799 | } |
| r9648 | r9649 | |
| 1872 | 1821 | |
| 1873 | 1822 | static void amstrad_GateArray_write(running_machine *machine, UINT8 dataToGateArray) |
| 1874 | 1823 | { |
| 1824 | amstrad_state *state = machine->driver_data<amstrad_state>(); |
| 1875 | 1825 | /* Get Bit 7 and 6 of the dataToGateArray = Gate Array function selected */ |
| 1876 | 1826 | switch ((dataToGateArray & 0xc0)>>6) |
| 1877 | 1827 | { |
| r9648 | r9649 | |
| 1888 | 1838 | case 0x00: |
| 1889 | 1839 | /* Select Border Number, get b4 */ |
| 1890 | 1840 | /* if b4 = 0 : Select Pen Number, get b3-b0 */ |
| 1891 | | gate_array.pen_selected = ( dataToGateArray & 0x10 ) ? 0x10 : ( dataToGateArray & 0x0f ); |
| 1841 | state->gate_array.pen_selected = ( dataToGateArray & 0x10 ) ? 0x10 : ( dataToGateArray & 0x0f ); |
| 1892 | 1842 | break; |
| 1893 | 1843 | |
| 1894 | 1844 | /* Colour selection |
| r9648 | r9649 | |
| 1904 | 1854 | 1 x | |
| 1905 | 1855 | 0 x |*/ |
| 1906 | 1856 | case 0x01: |
| 1907 | | amstrad_vh_update_colour( machine, gate_array.pen_selected, (dataToGateArray & 0x1F)); |
| 1857 | amstrad_vh_update_colour( machine, state->gate_array.pen_selected, (dataToGateArray & 0x1F)); |
| 1908 | 1858 | break; |
| 1909 | 1859 | |
| 1910 | 1860 | /* Select screen mode and rom configuration |
| r9648 | r9649 | |
| 1938 | 1888 | /* If bit 5 is enabled on a CPC Plus/GX4000 when the ASIC is unlocked, sets the lower ROM position and cart bank |
| 1939 | 1889 | b5 = 1, b4b3 = RAM position for lower ROM area and if the ASIC registers are visible at &4000, |
| 1940 | 1890 | b2b1b0 = cartridge bank to read from lower ROM area (0-7 only) */ |
| 1941 | | if ( amstrad_system_type == SYSTEM_PLUS || amstrad_system_type == SYSTEM_GX4000 ) |
| 1891 | if ( state->system_type == SYSTEM_PLUS || state->system_type == SYSTEM_GX4000 ) |
| 1942 | 1892 | { |
| 1943 | | if ( asic.enabled && (dataToGateArray & 0x20) ) |
| 1893 | if ( state->asic.enabled && (dataToGateArray & 0x20) ) |
| 1944 | 1894 | { |
| 1945 | | asic.rmr2 = dataToGateArray; |
| 1895 | state->asic.rmr2 = dataToGateArray; |
| 1946 | 1896 | } |
| 1947 | 1897 | else |
| 1948 | 1898 | { |
| 1949 | | gate_array.mrer = dataToGateArray; |
| 1899 | state->gate_array.mrer = dataToGateArray; |
| 1950 | 1900 | } |
| 1951 | 1901 | } |
| 1952 | 1902 | else |
| 1953 | 1903 | { |
| 1954 | | gate_array.mrer = dataToGateArray; |
| 1904 | state->gate_array.mrer = dataToGateArray; |
| 1955 | 1905 | } |
| 1956 | 1906 | |
| 1957 | 1907 | /* If bit 4 of the "Select screen mode and rom configuration" register of the Gate-Array is set to "1" |
| 1958 | 1908 | then the interrupt request is cleared and the 6-bit counter is reset to "0". */ |
| 1959 | | if ( gate_array.mrer & 0x10 ) |
| 1909 | if ( state->gate_array.mrer & 0x10 ) |
| 1960 | 1910 | { |
| 1961 | | gate_array.hsync_counter = 0; |
| 1911 | state->gate_array.hsync_counter = 0; |
| 1962 | 1912 | cputag_set_input_line(machine, "maincpu", 0, CLEAR_LINE); |
| 1963 | 1913 | } |
| 1964 | 1914 | |
| r9648 | r9649 | |
| 1967 | 1917 | amstrad_setUpperRom(machine); |
| 1968 | 1918 | |
| 1969 | 1919 | /* b1b0 mode */ |
| 1970 | | amstrad_vh_update_mode(); |
| 1920 | amstrad_vh_update_mode(state); |
| 1971 | 1921 | |
| 1972 | 1922 | break; |
| 1973 | 1923 | |
| r9648 | r9649 | |
| 1979 | 1929 | In the 464+ and 6128+ this function is performed by the ASIC or a memory expansion. |
| 1980 | 1930 | */ |
| 1981 | 1931 | case 0x03: |
| 1982 | | amstrad_GateArray_RamConfiguration = dataToGateArray; |
| 1932 | state->GateArray_RamConfiguration = dataToGateArray; |
| 1983 | 1933 | break; |
| 1984 | 1934 | |
| 1985 | 1935 | default: |
| r9648 | r9649 | |
| 1990 | 1940 | |
| 1991 | 1941 | static WRITE8_HANDLER( aleste_msx_mapper ) |
| 1992 | 1942 | { |
| 1943 | amstrad_state *state = space->machine->driver_data<amstrad_state>(); |
| 1993 | 1944 | int page = (offset & 0x0300) >> 8; |
| 1994 | 1945 | int ramptr = (data & 0x1f) * 0x4000; |
| 1995 | 1946 | int rampage = data & 0x1f; |
| r9648 | r9649 | |
| 2002 | 1953 | amstrad_GateArray_write(space->machine, data); |
| 2003 | 1954 | break; |
| 2004 | 1955 | case 1: // Colour select (6-bit palette) |
| 2005 | | aleste_vh_update_colour( space->machine, gate_array.pen_selected, data & 0x3f ); |
| 1956 | aleste_vh_update_colour( space->machine, state->gate_array.pen_selected, data & 0x3f ); |
| 2006 | 1957 | break; |
| 2007 | 1958 | case 2: // Screen mode, Upper/Lower ROM select |
| 2008 | 1959 | amstrad_GateArray_write(space->machine, data); |
| r9648 | r9649 | |
| 2015 | 1966 | memory_set_bankptr(space->machine,"bank2",messram_get_ptr(space->machine->device("messram"))+ramptr+0x2000); |
| 2016 | 1967 | memory_set_bankptr(space->machine,"bank9",messram_get_ptr(space->machine->device("messram"))+ramptr); |
| 2017 | 1968 | memory_set_bankptr(space->machine,"bank10",messram_get_ptr(space->machine->device("messram"))+ramptr+0x2000); |
| 2018 | | Aleste_RamBanks[0] = messram_get_ptr(space->machine->device("messram"))+ramptr; |
| 2019 | | aleste_active_page[0] = data; |
| 1969 | state->Aleste_RamBanks[0] = messram_get_ptr(space->machine->device("messram"))+ramptr; |
| 1970 | state->aleste_active_page[0] = data; |
| 2020 | 1971 | logerror("RAM: RAM location 0x%06x (page %02x) mapped to 0x0000\n",ramptr,rampage); |
| 2021 | 1972 | break; |
| 2022 | 1973 | case 1: /* 0x4000 - 0x7fff */ |
| r9648 | r9649 | |
| 2024 | 1975 | memory_set_bankptr(space->machine,"bank4",messram_get_ptr(space->machine->device("messram"))+ramptr+0x2000); |
| 2025 | 1976 | memory_set_bankptr(space->machine,"bank11",messram_get_ptr(space->machine->device("messram"))+ramptr); |
| 2026 | 1977 | memory_set_bankptr(space->machine,"bank12",messram_get_ptr(space->machine->device("messram"))+ramptr+0x2000); |
| 2027 | | Aleste_RamBanks[1] = messram_get_ptr(space->machine->device("messram"))+ramptr; |
| 2028 | | aleste_active_page[1] = data; |
| 1978 | state->Aleste_RamBanks[1] = messram_get_ptr(space->machine->device("messram"))+ramptr; |
| 1979 | state->aleste_active_page[1] = data; |
| 2029 | 1980 | logerror("RAM: RAM location 0x%06x (page %02x) mapped to 0x4000\n",ramptr,rampage); |
| 2030 | 1981 | break; |
| 2031 | 1982 | case 2: /* 0x8000 - 0xbfff */ |
| r9648 | r9649 | |
| 2033 | 1984 | memory_set_bankptr(space->machine,"bank6",messram_get_ptr(space->machine->device("messram"))+ramptr+0x2000); |
| 2034 | 1985 | memory_set_bankptr(space->machine,"bank13",messram_get_ptr(space->machine->device("messram"))+ramptr); |
| 2035 | 1986 | memory_set_bankptr(space->machine,"bank14",messram_get_ptr(space->machine->device("messram"))+ramptr+0x2000); |
| 2036 | | Aleste_RamBanks[2] = messram_get_ptr(space->machine->device("messram"))+ramptr; |
| 2037 | | aleste_active_page[2] = data; |
| 1987 | state->Aleste_RamBanks[2] = messram_get_ptr(space->machine->device("messram"))+ramptr; |
| 1988 | state->aleste_active_page[2] = data; |
| 2038 | 1989 | logerror("RAM: RAM location 0x%06x (page %02x) mapped to 0x8000\n",ramptr,rampage); |
| 2039 | 1990 | break; |
| 2040 | 1991 | case 3: /* 0xc000 - 0xffff */ |
| r9648 | r9649 | |
| 2042 | 1993 | memory_set_bankptr(space->machine,"bank8",messram_get_ptr(space->machine->device("messram"))+ramptr+0x2000); |
| 2043 | 1994 | memory_set_bankptr(space->machine,"bank15",messram_get_ptr(space->machine->device("messram"))+ramptr); |
| 2044 | 1995 | memory_set_bankptr(space->machine,"bank16",messram_get_ptr(space->machine->device("messram"))+ramptr+0x2000); |
| 2045 | | Aleste_RamBanks[3] = messram_get_ptr(space->machine->device("messram"))+ramptr; |
| 2046 | | aleste_active_page[3] = data; |
| 1996 | state->Aleste_RamBanks[3] = messram_get_ptr(space->machine->device("messram"))+ramptr; |
| 1997 | state->aleste_active_page[3] = data; |
| 2047 | 1998 | logerror("RAM: RAM location 0x%06x (page %02x) mapped to 0xc000\n",ramptr,rampage); |
| 2048 | 1999 | break; |
| 2049 | 2000 | } |
| r9648 | r9649 | |
| 2115 | 2066 | |
| 2116 | 2067 | READ8_HANDLER ( amstrad_cpc_io_r ) |
| 2117 | 2068 | { |
| 2069 | amstrad_state *state = space->machine->driver_data<amstrad_state>(); |
| 2118 | 2070 | running_device *fdc = space->machine->device("upd765"); |
| 2119 | 2071 | running_device *mc6845 = space->machine->device("mc6845" ); |
| 2120 | 2072 | |
| r9648 | r9649 | |
| 2126 | 2078 | // crtc_type = input_port_read_safe(space->machine, "crtc", 0); |
| 2127 | 2079 | // m6845_set_personality(crtc_type); |
| 2128 | 2080 | |
| 2129 | | if(aleste_mode & 0x04) |
| 2081 | if(state->aleste_mode & 0x04) |
| 2130 | 2082 | { |
| 2131 | 2083 | if ((offset & (1<<15)) == 0) // Aleste Mapper is readable? |
| 2132 | 2084 | { |
| 2133 | 2085 | page = (offset & 0x0300) >> 8; |
| 2134 | | data = aleste_active_page[page]; |
| 2086 | data = state->aleste_active_page[page]; |
| 2135 | 2087 | return data; |
| 2136 | 2088 | } |
| 2137 | 2089 | } |
| r9648 | r9649 | |
| 2196 | 2148 | If b10 is reset but none of b7-b5 are reset, user expansion peripherals are selected. |
| 2197 | 2149 | The exception is the case where none of b7-b0 are reset (i.e. port &FBFF), which causes the expansion peripherals to reset. |
| 2198 | 2150 | */ |
| 2199 | | if ( amstrad_system_type != SYSTEM_GX4000 ) |
| 2151 | if ( state->system_type != SYSTEM_GX4000 ) |
| 2200 | 2152 | { |
| 2201 | 2153 | if ( ( offset & (1<<10) ) == 0 ) |
| 2202 | 2154 | { |
| r9648 | r9649 | |
| 2223 | 2175 | |
| 2224 | 2176 | |
| 2225 | 2177 | // Handler for checking the ASIC unlocking sequence |
| 2226 | | static void amstrad_plus_seqcheck(int data) |
| 2178 | static void amstrad_plus_seqcheck(amstrad_state *state, int data) |
| 2227 | 2179 | { |
| 2228 | | static int prev_data; |
| 2229 | | |
| 2230 | | if(data == 0 && prev_data != 0) |
| 2180 | if(data == 0 && state->prev_data != 0) |
| 2231 | 2181 | { |
| 2232 | | asic.seqptr = 0; // non-zero value followed by zero will sync the locking mechanism |
| 2182 | state->asic.seqptr = 0; // non-zero value followed by zero will sync the locking mechanism |
| 2233 | 2183 | } |
| 2234 | | if(data == asic_unlock_seq[asic.seqptr]) |
| 2184 | if(data == asic_unlock_seq[state->asic.seqptr]) |
| 2235 | 2185 | { |
| 2236 | | asic.seqptr++; |
| 2237 | | if ( asic.seqptr == 14 && asic.enabled ) |
| 2186 | state->asic.seqptr++; |
| 2187 | if ( state->asic.seqptr == 14 && state->asic.enabled ) |
| 2238 | 2188 | { |
| 2239 | 2189 | logerror("SYS: ASIC locked\n"); |
| 2240 | | asic.enabled = 0; |
| 2190 | state->asic.enabled = 0; |
| 2241 | 2191 | } |
| 2242 | | if ( asic.seqptr >= 15 ) // end of sequence |
| 2192 | if ( state->asic.seqptr >= 15 ) // end of sequence |
| 2243 | 2193 | { |
| 2244 | 2194 | logerror("SYS: ASIC unlocked\n"); |
| 2245 | | asic.enabled = 1; |
| 2195 | state->asic.enabled = 1; |
| 2246 | 2196 | } |
| 2247 | 2197 | } |
| 2248 | | prev_data = data; |
| 2198 | state->prev_data = data; |
| 2249 | 2199 | } |
| 2250 | 2200 | |
| 2251 | 2201 | |
| 2252 | 2202 | /* Offset handler for write */ |
| 2253 | 2203 | WRITE8_HANDLER ( amstrad_cpc_io_w ) |
| 2254 | 2204 | { |
| 2205 | amstrad_state *state = space->machine->driver_data<amstrad_state>(); |
| 2255 | 2206 | running_device *fdc = space->machine->device("upd765"); |
| 2256 | 2207 | running_device *mc6845 = space->machine->device("mc6845"); |
| 2257 | 2208 | |
| 2258 | | static int printer_bit8_selected = FALSE; |
| 2259 | | |
| 2260 | 2209 | if ((offset & (1<<15)) == 0) |
| 2261 | 2210 | { |
| 2262 | | if(aleste_mode & 0x04) // Aleste mode |
| 2211 | if(state->aleste_mode & 0x04) // Aleste mode |
| 2263 | 2212 | { |
| 2264 | 2213 | aleste_msx_mapper(space, offset, data); |
| 2265 | 2214 | } |
| r9648 | r9649 | |
| 2282 | 2231 | { |
| 2283 | 2232 | case 0x00: /* Select internal 6845 register Write Only */ |
| 2284 | 2233 | mc6845_address_w( mc6845, 0, data ); |
| 2285 | | if ( amstrad_system_type == SYSTEM_PLUS || amstrad_system_type == SYSTEM_GX4000 ) |
| 2286 | | amstrad_plus_seqcheck(data); |
| 2234 | if ( state->system_type == SYSTEM_PLUS || state->system_type == SYSTEM_GX4000 ) |
| 2235 | amstrad_plus_seqcheck(state, data); |
| 2287 | 2236 | |
| 2288 | 2237 | /* printer port d7 */ |
| 2289 | | if (data == 0x0c && amstrad_system_type == SYSTEM_PLUS) |
| 2290 | | printer_bit8_selected = TRUE; |
| 2238 | if (data == 0x0c && state->system_type == SYSTEM_PLUS) |
| 2239 | state->printer_bit8_selected = TRUE; |
| 2291 | 2240 | |
| 2292 | | asic.addr_6845 = data; |
| 2241 | state->asic.addr_6845 = data; |
| 2293 | 2242 | break; |
| 2294 | 2243 | case 0x01: /* Write to selected internal 6845 register Write Only */ |
| 2295 | | if ( amstrad_system_type == SYSTEM_PLUS || amstrad_system_type == SYSTEM_GX4000 ) |
| 2244 | if ( state->system_type == SYSTEM_PLUS || state->system_type == SYSTEM_GX4000 ) |
| 2296 | 2245 | amstrad_plus_update_video( space->machine ); |
| 2297 | 2246 | else |
| 2298 | 2247 | amstrad_update_video( space->machine ); |
| 2299 | 2248 | mc6845_register_w( mc6845, 0, data ); |
| 2300 | 2249 | |
| 2301 | 2250 | /* printer port bit 8 */ |
| 2302 | | if (printer_bit8_selected && amstrad_system_type == SYSTEM_PLUS) |
| 2251 | if (state->printer_bit8_selected && state->system_type == SYSTEM_PLUS) |
| 2303 | 2252 | { |
| 2304 | 2253 | running_device *printer = space->machine->device("centronics"); |
| 2305 | 2254 | centronics_d7_w(printer, BIT(data, 3)); |
| 2306 | | printer_bit8_selected = FALSE; |
| 2255 | state->printer_bit8_selected = FALSE; |
| 2307 | 2256 | } |
| 2308 | 2257 | |
| 2309 | | if ( asic.addr_6845 == 0x01 ) |
| 2310 | | asic.horiz_disp = data; |
| 2258 | if ( state->asic.addr_6845 == 0x01 ) |
| 2259 | state->asic.horiz_disp = data; |
| 2311 | 2260 | |
| 2312 | 2261 | break; |
| 2313 | 2262 | default: |
| r9648 | r9649 | |
| 2319 | 2268 | /* b13 = 0 : ROM select Write Selected*/ |
| 2320 | 2269 | if ((offset & (1<<13)) == 0) |
| 2321 | 2270 | { |
| 2322 | | gate_array.upper_bank = data; |
| 2271 | state->gate_array.upper_bank = data; |
| 2323 | 2272 | amstrad_setUpperRom( space->machine ); |
| 2324 | 2273 | } |
| 2325 | 2274 | |
| 2326 | 2275 | /* b12 = 0 : Printer port Write Selected*/ |
| 2327 | | if(amstrad_system_type != SYSTEM_GX4000) |
| 2276 | if(state->system_type != SYSTEM_GX4000) |
| 2328 | 2277 | { |
| 2329 | 2278 | if ((offset & (1<<12)) == 0) |
| 2330 | 2279 | { |
| r9648 | r9649 | |
| 2370 | 2319 | If b10 is reset but none of b7-b5 are reset, user expansion peripherals are selected. |
| 2371 | 2320 | The exception is the case where none of b7-b0 are reset (i.e. port &FBFF), which causes the expansion peripherals to reset. |
| 2372 | 2321 | */ |
| 2373 | | if(amstrad_system_type != SYSTEM_GX4000) |
| 2322 | if(state->system_type != SYSTEM_GX4000) |
| 2374 | 2323 | { |
| 2375 | 2324 | if ((offset & (1<<7)) == 0) |
| 2376 | 2325 | { |
| r9648 | r9649 | |
| 2408 | 2357 | D5 - 0-AY8910 ,1-512WI1 */ |
| 2409 | 2358 | if(offset == 0xfabf) |
| 2410 | 2359 | { |
| 2411 | | aleste_mode = data; |
| 2360 | state->aleste_mode = data; |
| 2412 | 2361 | logerror("EXTEND: Port &FABF write 0x%02x\n",data); |
| 2413 | | mc6845_set_clock( mc6845, ( aleste_mode & 0x02 ) ? ( XTAL_16MHz / 8 ) : ( XTAL_16MHz / 16 ) ); |
| 2362 | mc6845_set_clock( mc6845, ( state->aleste_mode & 0x02 ) ? ( XTAL_16MHz / 8 ) : ( XTAL_16MHz / 16 ) ); |
| 2414 | 2363 | } |
| 2415 | 2364 | |
| 2416 | 2365 | multiface_io_write(space, offset, data); |
| r9648 | r9649 | |
| 2420 | 2369 | /* load CPCEMU style snapshots */ |
| 2421 | 2370 | static void amstrad_handle_snapshot(running_machine *machine, unsigned char *pSnapshot) |
| 2422 | 2371 | { |
| 2372 | amstrad_state *state = machine->driver_data<amstrad_state>(); |
| 2423 | 2373 | address_space* space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 2424 | 2374 | running_device *mc6845 = space->machine->device("mc6845" ); |
| 2425 | 2375 | running_device *ay8910 = machine->device("ay"); |
| r9648 | r9649 | |
| 2517 | 2467 | mc6845_address_w( mc6845, 0, i ); |
| 2518 | 2468 | |
| 2519 | 2469 | /* upper rom selection */ |
| 2520 | | gate_array.upper_bank = pSnapshot[0x055]; |
| 2470 | state->gate_array.upper_bank = pSnapshot[0x055]; |
| 2521 | 2471 | |
| 2522 | 2472 | /* PPI */ |
| 2523 | 2473 | i8255a_w(machine->device("ppi8255"),3,pSnapshot[0x059] & 0x0ff); |
| r9648 | r9649 | |
| 2562 | 2512 | control is passed to the default entry in rom 0*/ |
| 2563 | 2513 | static void amstrad_reset_machine(running_machine *machine) |
| 2564 | 2514 | { |
| 2515 | amstrad_state *state = machine->driver_data<amstrad_state>(); |
| 2565 | 2516 | /* enable lower rom (OS rom) */ |
| 2566 | 2517 | amstrad_GateArray_write(machine, 0x089); |
| 2567 | 2518 | |
| r9648 | r9649 | |
| 2569 | 2520 | amstrad_GateArray_write(machine, 0x0c0); |
| 2570 | 2521 | |
| 2571 | 2522 | // Get manufacturer name and TV refresh rate from PCB link (dipswitch for mess emulation) |
| 2572 | | ppi_port_inputs[amstrad_ppi_PortB] = (((input_port_read(machine, "solder_links")&MANUFACTURER_NAME)<<1) | (input_port_read(machine, "solder_links")&TV_REFRESH_RATE)); |
| 2523 | state->ppi_port_inputs[amstrad_ppi_PortB] = (((input_port_read(machine, "solder_links")&MANUFACTURER_NAME)<<1) | (input_port_read(machine, "solder_links")&TV_REFRESH_RATE)); |
| 2573 | 2524 | |
| 2574 | | if ( amstrad_system_type == SYSTEM_PLUS || amstrad_system_type == SYSTEM_GX4000 ) |
| 2575 | | memset(asic.ram,0,16384); // clear ASIC RAM |
| 2525 | if ( state->system_type == SYSTEM_PLUS || state->system_type == SYSTEM_GX4000 ) |
| 2526 | memset(state->asic.ram,0,16384); // clear ASIC RAM |
| 2576 | 2527 | |
| 2577 | | multiface_reset(); |
| 2528 | multiface_reset(state); |
| 2578 | 2529 | } |
| 2579 | 2530 | |
| 2580 | 2531 | |
| r9648 | r9649 | |
| 2583 | 2534 | ------------------*/ |
| 2584 | 2535 | static void amstrad_rethinkMemory(running_machine *machine) |
| 2585 | 2536 | { |
| 2537 | amstrad_state *state = machine->driver_data<amstrad_state>(); |
| 2586 | 2538 | /* the following is used for banked memory read/writes and for setting up |
| 2587 | 2539 | * opcode and opcode argument reads */ |
| 2588 | 2540 | |
| r9648 | r9649 | |
| 2590 | 2542 | amstrad_setLowerRom(machine); |
| 2591 | 2543 | |
| 2592 | 2544 | /* bank 1 - 0x04000..0x07fff */ |
| 2593 | | if ( amstrad_system_type == SYSTEM_CPC || amstrad_system_type == SYSTEM_ALESTE || asic.enabled == 0 ) |
| 2545 | if ( state->system_type == SYSTEM_CPC || state->system_type == SYSTEM_ALESTE || state->asic.enabled == 0 ) |
| 2594 | 2546 | { |
| 2595 | | if(aleste_mode & 0x04) |
| 2547 | if(state->aleste_mode & 0x04) |
| 2596 | 2548 | { |
| 2597 | | memory_set_bankptr(machine,"bank3", Aleste_RamBanks[1]); |
| 2598 | | memory_set_bankptr(machine,"bank4", Aleste_RamBanks[1]+0x2000); |
| 2549 | memory_set_bankptr(machine,"bank3", state->Aleste_RamBanks[1]); |
| 2550 | memory_set_bankptr(machine,"bank4", state->Aleste_RamBanks[1]+0x2000); |
| 2599 | 2551 | /* bank 2 - 0x08000..0x0bfff */ |
| 2600 | | memory_set_bankptr(machine,"bank5", Aleste_RamBanks[2]); |
| 2601 | | memory_set_bankptr(machine,"bank6", Aleste_RamBanks[2]+0x2000); |
| 2552 | memory_set_bankptr(machine,"bank5", state->Aleste_RamBanks[2]); |
| 2553 | memory_set_bankptr(machine,"bank6", state->Aleste_RamBanks[2]+0x2000); |
| 2602 | 2554 | } |
| 2603 | 2555 | else |
| 2604 | 2556 | { |
| 2605 | | memory_set_bankptr(machine,"bank3", AmstradCPC_RamBanks[1]); |
| 2606 | | memory_set_bankptr(machine,"bank4", AmstradCPC_RamBanks[1]+0x2000); |
| 2557 | memory_set_bankptr(machine,"bank3", state->AmstradCPC_RamBanks[1]); |
| 2558 | memory_set_bankptr(machine,"bank4", state->AmstradCPC_RamBanks[1]+0x2000); |
| 2607 | 2559 | /* bank 2 - 0x08000..0x0bfff */ |
| 2608 | | memory_set_bankptr(machine,"bank5", AmstradCPC_RamBanks[2]); |
| 2609 | | memory_set_bankptr(machine,"bank6", AmstradCPC_RamBanks[2]+0x2000); |
| 2560 | memory_set_bankptr(machine,"bank5", state->AmstradCPC_RamBanks[2]); |
| 2561 | memory_set_bankptr(machine,"bank6", state->AmstradCPC_RamBanks[2]+0x2000); |
| 2610 | 2562 | } |
| 2611 | 2563 | } |
| 2612 | 2564 | else |
| r9648 | r9649 | |
| 2616 | 2568 | amstrad_setUpperRom(machine); |
| 2617 | 2569 | |
| 2618 | 2570 | /* other banks */ |
| 2619 | | if(aleste_mode & 0x04) |
| 2571 | if(state->aleste_mode & 0x04) |
| 2620 | 2572 | { |
| 2621 | | memory_set_bankptr(machine,"bank9", Aleste_RamBanks[0]); |
| 2622 | | memory_set_bankptr(machine,"bank10", Aleste_RamBanks[0]+0x2000); |
| 2623 | | memory_set_bankptr(machine,"bank11", Aleste_RamBanks[1]); |
| 2624 | | memory_set_bankptr(machine,"bank12", Aleste_RamBanks[1]+0x2000); |
| 2625 | | memory_set_bankptr(machine,"bank13", Aleste_RamBanks[2]); |
| 2626 | | memory_set_bankptr(machine,"bank14", Aleste_RamBanks[2]+0x2000); |
| 2627 | | memory_set_bankptr(machine,"bank15", Aleste_RamBanks[3]); |
| 2628 | | memory_set_bankptr(machine,"bank16", Aleste_RamBanks[3]+0x2000); |
| 2573 | memory_set_bankptr(machine,"bank9", state->Aleste_RamBanks[0]); |
| 2574 | memory_set_bankptr(machine,"bank10", state->Aleste_RamBanks[0]+0x2000); |
| 2575 | memory_set_bankptr(machine,"bank11", state->Aleste_RamBanks[1]); |
| 2576 | memory_set_bankptr(machine,"bank12", state->Aleste_RamBanks[1]+0x2000); |
| 2577 | memory_set_bankptr(machine,"bank13", state->Aleste_RamBanks[2]); |
| 2578 | memory_set_bankptr(machine,"bank14", state->Aleste_RamBanks[2]+0x2000); |
| 2579 | memory_set_bankptr(machine,"bank15", state->Aleste_RamBanks[3]); |
| 2580 | memory_set_bankptr(machine,"bank16", state->Aleste_RamBanks[3]+0x2000); |
| 2629 | 2581 | } |
| 2630 | 2582 | else |
| 2631 | 2583 | { |
| 2632 | | memory_set_bankptr(machine,"bank9", AmstradCPC_RamBanks[0]); |
| 2633 | | memory_set_bankptr(machine,"bank10", AmstradCPC_RamBanks[0]+0x2000); |
| 2634 | | memory_set_bankptr(machine,"bank11", AmstradCPC_RamBanks[1]); |
| 2635 | | memory_set_bankptr(machine,"bank12", AmstradCPC_RamBanks[1]+0x2000); |
| 2636 | | memory_set_bankptr(machine,"bank13", AmstradCPC_RamBanks[2]); |
| 2637 | | memory_set_bankptr(machine,"bank14", AmstradCPC_RamBanks[2]+0x2000); |
| 2638 | | memory_set_bankptr(machine,"bank15", AmstradCPC_RamBanks[3]); |
| 2639 | | memory_set_bankptr(machine,"bank16", AmstradCPC_RamBanks[3]+0x2000); |
| 2584 | memory_set_bankptr(machine,"bank9", state->AmstradCPC_RamBanks[0]); |
| 2585 | memory_set_bankptr(machine,"bank10", state->AmstradCPC_RamBanks[0]+0x2000); |
| 2586 | memory_set_bankptr(machine,"bank11", state->AmstradCPC_RamBanks[1]); |
| 2587 | memory_set_bankptr(machine,"bank12", state->AmstradCPC_RamBanks[1]+0x2000); |
| 2588 | memory_set_bankptr(machine,"bank13", state->AmstradCPC_RamBanks[2]); |
| 2589 | memory_set_bankptr(machine,"bank14", state->AmstradCPC_RamBanks[2]+0x2000); |
| 2590 | memory_set_bankptr(machine,"bank15", state->AmstradCPC_RamBanks[3]); |
| 2591 | memory_set_bankptr(machine,"bank16", state->AmstradCPC_RamBanks[3]+0x2000); |
| 2640 | 2592 | } |
| 2641 | 2593 | |
| 2642 | 2594 | /* multiface hardware enabled? */ |
| r9648 | r9649 | |
| 2688 | 2640 | 1 1 | Select PSG register. When set, the PSG will take the data at PPI Port A and select a register |
| 2689 | 2641 | */ |
| 2690 | 2642 | /* PSG function selected */ |
| 2691 | | static unsigned char amstrad_Psg_FunctionSelected; |
| 2692 | 2643 | static void update_psg(running_machine *machine) |
| 2693 | 2644 | { |
| 2645 | amstrad_state *state = machine->driver_data<amstrad_state>(); |
| 2694 | 2646 | address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 2695 | 2647 | running_device *ay8910 = machine->device("ay"); |
| 2696 | 2648 | mc146818_device *rtc = space->machine->device<mc146818_device>("rtc"); |
| 2697 | 2649 | |
| 2698 | | if(aleste_mode & 0x20) // RTC selected |
| 2650 | if(state->aleste_mode & 0x20) // RTC selected |
| 2699 | 2651 | { |
| 2700 | | switch(aleste_rtc_function) |
| 2652 | switch(state->aleste_rtc_function) |
| 2701 | 2653 | { |
| 2702 | 2654 | case 0x02: // AS |
| 2703 | | rtc->write(*space, 0,ppi_port_outputs[amstrad_ppi_PortA]); |
| 2655 | rtc->write(*space, 0,state->ppi_port_outputs[amstrad_ppi_PortA]); |
| 2704 | 2656 | break; |
| 2705 | 2657 | case 0x04: // DS write |
| 2706 | | rtc->write(*space, 1,ppi_port_outputs[amstrad_ppi_PortA]); |
| 2658 | rtc->write(*space, 1,state->ppi_port_outputs[amstrad_ppi_PortA]); |
| 2707 | 2659 | break; |
| 2708 | 2660 | case 0x05: // DS read |
| 2709 | | ppi_port_inputs[amstrad_ppi_PortA] = rtc->read(*space, 1); |
| 2661 | state->ppi_port_inputs[amstrad_ppi_PortA] = rtc->read(*space, 1); |
| 2710 | 2662 | break; |
| 2711 | 2663 | } |
| 2712 | 2664 | return; |
| 2713 | 2665 | } |
| 2714 | | switch (amstrad_Psg_FunctionSelected) |
| 2666 | switch (state->Psg_FunctionSelected) |
| 2715 | 2667 | { |
| 2716 | 2668 | case 0: |
| 2717 | 2669 | {/* Inactive */ |
| 2718 | 2670 | } break; |
| 2719 | 2671 | case 1: |
| 2720 | 2672 | {/* b6 = 1 ? : Read from selected PSG register and make the register data available to PPI Port A */ |
| 2721 | | ppi_port_inputs[amstrad_ppi_PortA] = ay8910_r(ay8910, 0); |
| 2673 | state->ppi_port_inputs[amstrad_ppi_PortA] = ay8910_r(ay8910, 0); |
| 2722 | 2674 | } |
| 2723 | 2675 | break; |
| 2724 | 2676 | case 2: |
| 2725 | 2677 | {/* b7 = 1 ? : Write to selected PSG register and write data to PPI Port A */ |
| 2726 | | ay8910_data_w(ay8910, 0, ppi_port_outputs[amstrad_ppi_PortA]); |
| 2678 | ay8910_data_w(ay8910, 0, state->ppi_port_outputs[amstrad_ppi_PortA]); |
| 2727 | 2679 | } |
| 2728 | 2680 | break; |
| 2729 | 2681 | case 3: |
| 2730 | 2682 | {/* b6 and b7 = 1 ? : The register will now be selected and the user can read from or write to it. The register will remain selected until another is chosen.*/ |
| 2731 | | ay8910_address_w(ay8910, 0, ppi_port_outputs[amstrad_ppi_PortA]); |
| 2732 | | prev_reg = ppi_port_outputs[amstrad_ppi_PortA]; |
| 2683 | ay8910_address_w(ay8910, 0, state->ppi_port_outputs[amstrad_ppi_PortA]); |
| 2684 | state->prev_reg = state->ppi_port_outputs[amstrad_ppi_PortA]; |
| 2733 | 2685 | } |
| 2734 | 2686 | break; |
| 2735 | 2687 | default: |
| r9648 | r9649 | |
| 2742 | 2694 | /* Read/Write 8255 PPI port A (connected to AY-3-8912 databus) */ |
| 2743 | 2695 | READ8_DEVICE_HANDLER ( amstrad_ppi_porta_r ) |
| 2744 | 2696 | { |
| 2697 | amstrad_state *state = device->machine->driver_data<amstrad_state>(); |
| 2745 | 2698 | update_psg(device->machine); |
| 2746 | | return ppi_port_inputs[amstrad_ppi_PortA]; |
| 2699 | return state->ppi_port_inputs[amstrad_ppi_PortA]; |
| 2747 | 2700 | } |
| 2748 | 2701 | |
| 2749 | 2702 | |
| 2750 | 2703 | WRITE8_DEVICE_HANDLER ( amstrad_ppi_porta_w ) |
| 2751 | 2704 | { |
| 2752 | | ppi_port_outputs[amstrad_ppi_PortA] = data; |
| 2705 | amstrad_state *state = device->machine->driver_data<amstrad_state>(); |
| 2706 | state->ppi_port_outputs[amstrad_ppi_PortA] = data; |
| 2753 | 2707 | update_psg(device->machine); |
| 2754 | 2708 | } |
| 2755 | 2709 | |
| r9648 | r9649 | |
| 2782 | 2736 | |
| 2783 | 2737 | READ8_DEVICE_HANDLER (amstrad_ppi_portb_r) |
| 2784 | 2738 | { |
| 2739 | amstrad_state *state = device->machine->driver_data<amstrad_state>(); |
| 2785 | 2740 | int data = 0; |
| 2786 | 2741 | /* Set b7 with cassette tape input */ |
| 2787 | | if(amstrad_system_type != SYSTEM_GX4000) |
| 2742 | if(state->system_type != SYSTEM_GX4000) |
| 2788 | 2743 | { |
| 2789 | 2744 | if (cassette_input(device->machine->device("cassette" )) > 0.03) |
| 2790 | 2745 | { |
| r9648 | r9649 | |
| 2792 | 2747 | } |
| 2793 | 2748 | } |
| 2794 | 2749 | /* Set b6 with Parallel/Printer port ready */ |
| 2795 | | if(amstrad_system_type != SYSTEM_GX4000) |
| 2750 | if(state->system_type != SYSTEM_GX4000) |
| 2796 | 2751 | { |
| 2797 | 2752 | running_device *printer = device->machine->device("centronics"); |
| 2798 | 2753 | data |= centronics_busy_r(printer) << 6; |
| 2799 | 2754 | } |
| 2800 | 2755 | /* Set b4-b1 50Hz/60Hz state and manufacturer name defined by links on PCB */ |
| 2801 | | data |= (ppi_port_inputs[amstrad_ppi_PortB] & 0x1e); |
| 2756 | data |= (state->ppi_port_inputs[amstrad_ppi_PortB] & 0x1e); |
| 2802 | 2757 | |
| 2803 | 2758 | /* Set b0 with VSync state from the CRTC */ |
| 2804 | | data |= gate_array.vsync; |
| 2759 | data |= state->gate_array.vsync; |
| 2805 | 2760 | |
| 2806 | | if(aleste_mode & 0x04) |
| 2761 | if(state->aleste_mode & 0x04) |
| 2807 | 2762 | { |
| 2808 | | if(aleste_fdc_int == 0) |
| 2763 | if(state->aleste_fdc_int == 0) |
| 2809 | 2764 | data &= ~0x02; |
| 2810 | 2765 | else |
| 2811 | 2766 | data |= 0x02; |
| r9648 | r9649 | |
| 2831 | 2786 | 0 |*/ |
| 2832 | 2787 | |
| 2833 | 2788 | /* previous_ppi_portc_w value */ |
| 2834 | | static int previous_ppi_portc_w; |
| 2835 | 2789 | |
| 2836 | 2790 | WRITE8_DEVICE_HANDLER ( amstrad_ppi_portc_w ) |
| 2837 | 2791 | { |
| 2792 | amstrad_state *state = device->machine->driver_data<amstrad_state>(); |
| 2838 | 2793 | int changed_data; |
| 2839 | 2794 | |
| 2840 | | previous_ppi_portc_w = ppi_port_outputs[amstrad_ppi_PortC]; |
| 2795 | state->previous_ppi_portc_w = state->ppi_port_outputs[amstrad_ppi_PortC]; |
| 2841 | 2796 | /* Write the data to Port C */ |
| 2842 | | changed_data = previous_ppi_portc_w^data; |
| 2797 | changed_data = state->previous_ppi_portc_w^data; |
| 2843 | 2798 | |
| 2844 | | ppi_port_outputs[amstrad_ppi_PortC] = data; |
| 2799 | state->ppi_port_outputs[amstrad_ppi_PortC] = data; |
| 2845 | 2800 | |
| 2846 | 2801 | /* get b7 and b6 (PSG Function Selected */ |
| 2847 | | amstrad_Psg_FunctionSelected = ((data & 0xC0)>>6); |
| 2802 | state->Psg_FunctionSelected = ((data & 0xC0)>>6); |
| 2848 | 2803 | |
| 2849 | 2804 | /* MC146818 function */ |
| 2850 | | aleste_rtc_function = data & 0x07; |
| 2805 | state->aleste_rtc_function = data & 0x07; |
| 2851 | 2806 | |
| 2852 | 2807 | /* Perform PSG function */ |
| 2853 | 2808 | update_psg(device->machine); |
| 2854 | 2809 | |
| 2855 | 2810 | /* b5 Cassette Write data */ |
| 2856 | | if(amstrad_system_type != SYSTEM_GX4000) |
| 2811 | if(state->system_type != SYSTEM_GX4000) |
| 2857 | 2812 | { |
| 2858 | 2813 | if ((changed_data & 0x20) != 0) |
| 2859 | 2814 | { |
| r9648 | r9649 | |
| 2863 | 2818 | } |
| 2864 | 2819 | |
| 2865 | 2820 | /* b4 Cassette Motor Control */ |
| 2866 | | if(amstrad_system_type != SYSTEM_GX4000) |
| 2821 | if(state->system_type != SYSTEM_GX4000) |
| 2867 | 2822 | { |
| 2868 | 2823 | if ((changed_data & 0x10) != 0) |
| 2869 | 2824 | { |
| r9648 | r9649 | |
| 2885 | 2840 | /* read PSG port A */ |
| 2886 | 2841 | READ8_HANDLER ( amstrad_psg_porta_read ) |
| 2887 | 2842 | { |
| 2843 | amstrad_state *state = space->machine->driver_data<amstrad_state>(); |
| 2888 | 2844 | /* Read CPC Keyboard |
| 2889 | 2845 | If keyboard matrix line 11-14 are selected, the byte is always &ff. |
| 2890 | 2846 | After testing on a real CPC, it is found that these never change, they always return &FF. */ |
| r9648 | r9649 | |
| 2895 | 2851 | "keyboard_row_10" |
| 2896 | 2852 | }; |
| 2897 | 2853 | |
| 2898 | | if ( ( ppi_port_outputs[amstrad_ppi_PortC] & 0x0F ) > 10) |
| 2854 | if ( ( state->ppi_port_outputs[amstrad_ppi_PortC] & 0x0F ) > 10) |
| 2899 | 2855 | { |
| 2900 | 2856 | return 0xFF; |
| 2901 | 2857 | } |
| 2902 | 2858 | else |
| 2903 | 2859 | { |
| 2904 | | if(aleste_mode == 0x08 && ( ppi_port_outputs[amstrad_ppi_PortC] & 0x0F ) == 10) |
| 2860 | if(state->aleste_mode == 0x08 && ( state->ppi_port_outputs[amstrad_ppi_PortC] & 0x0F ) == 10) |
| 2905 | 2861 | return 0xff; |
| 2906 | 2862 | |
| 2907 | | return input_port_read_safe(space->machine, keynames[ppi_port_outputs[amstrad_ppi_PortC] & 0x0F], 0) & 0xFF; |
| 2863 | return input_port_read_safe(space->machine, keynames[state->ppi_port_outputs[amstrad_ppi_PortC] & 0x0F], 0) & 0xFF; |
| 2908 | 2864 | } |
| 2909 | 2865 | } |
| 2910 | 2866 | |
| r9648 | r9649 | |
| 2914 | 2870 | /* this ensures that the next interrupt is no closer than 32 lines */ |
| 2915 | 2871 | static IRQ_CALLBACK(amstrad_cpu_acknowledge_int) |
| 2916 | 2872 | { |
| 2873 | amstrad_state *state = device->machine->driver_data<amstrad_state>(); |
| 2917 | 2874 | // DMA interrupts can be automatically cleared if bit 0 of &6805 is set to 0 |
| 2918 | | if( asic.enabled && amstrad_plus_irq_cause != 0x06 && asic.dma_clear & 0x01) |
| 2875 | if( state->asic.enabled && state->plus_irq_cause != 0x06 && state->asic.dma_clear & 0x01) |
| 2919 | 2876 | { |
| 2920 | | logerror("IRQ: Not cleared, IRQ was called by DMA [%i]\n",amstrad_plus_irq_cause); |
| 2921 | | asic.ram[0x2c0f] &= ~0x80; // not a raster interrupt, so this bit is reset |
| 2922 | | return (asic.ram[0x2805] & 0xf8) | amstrad_plus_irq_cause; |
| 2877 | logerror("IRQ: Not cleared, IRQ was called by DMA [%i]\n",state->plus_irq_cause); |
| 2878 | state->asic.ram[0x2c0f] &= ~0x80; // not a raster interrupt, so this bit is reset |
| 2879 | return (state->asic.ram[0x2805] & 0xf8) | state->plus_irq_cause; |
| 2923 | 2880 | } |
| 2924 | 2881 | cputag_set_input_line(device->machine,"maincpu", 0, CLEAR_LINE); |
| 2925 | | gate_array.hsync_counter &= 0x1F; |
| 2926 | | if ( asic.enabled ) |
| 2882 | state->gate_array.hsync_counter &= 0x1F; |
| 2883 | if ( state->asic.enabled ) |
| 2927 | 2884 | { |
| 2928 | | if(amstrad_plus_irq_cause == 6) // bit 7 is set "if last interrupt acknowledge cycle was caused by a raster interrupt" |
| 2929 | | asic.ram[0x2c0f] |= 0x80; |
| 2885 | if(state->plus_irq_cause == 6) // bit 7 is set "if last interrupt acknowledge cycle was caused by a raster interrupt" |
| 2886 | state->asic.ram[0x2c0f] |= 0x80; |
| 2930 | 2887 | else |
| 2931 | 2888 | { |
| 2932 | | asic.ram[0x2c0f] &= ~0x80; |
| 2933 | | asic.ram[0x2c0f] &= (0x40 >> amstrad_plus_irq_cause/2); |
| 2889 | state->asic.ram[0x2c0f] &= ~0x80; |
| 2890 | state->asic.ram[0x2c0f] &= (0x40 >> state->plus_irq_cause/2); |
| 2934 | 2891 | } |
| 2935 | | return (asic.ram[0x2805] & 0xf8) | amstrad_plus_irq_cause; |
| 2892 | return (state->asic.ram[0x2805] & 0xf8) | state->plus_irq_cause; |
| 2936 | 2893 | } |
| 2937 | 2894 | return 0xFF; |
| 2938 | 2895 | } |
| r9648 | r9649 | |
| 3060 | 3017 | |
| 3061 | 3018 | static void amstrad_common_init(running_machine *machine) |
| 3062 | 3019 | { |
| 3020 | amstrad_state *state = machine->driver_data<amstrad_state>(); |
| 3063 | 3021 | address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 3064 | 3022 | |
| 3065 | | aleste_mode = 0; |
| 3023 | state->aleste_mode = 0; |
| 3066 | 3024 | |
| 3067 | | gate_array.mrer = 0; |
| 3068 | | gate_array.vsync = 0; |
| 3069 | | gate_array.hsync = 0; |
| 3070 | | amstrad_GateArray_RamConfiguration = 0; |
| 3071 | | gate_array.hsync_counter = 2; |
| 3025 | state->gate_array.mrer = 0; |
| 3026 | state->gate_array.vsync = 0; |
| 3027 | state->gate_array.hsync = 0; |
| 3028 | state->GateArray_RamConfiguration = 0; |
| 3029 | state->gate_array.hsync_counter = 2; |
| 3072 | 3030 | |
| 3073 | 3031 | memory_install_read_bank(space, 0x0000, 0x1fff, 0, 0, "bank1"); |
| 3074 | 3032 | memory_install_read_bank(space, 0x2000, 0x3fff, 0, 0, "bank2"); |
| r9648 | r9649 | |
| 3095 | 3053 | memory_install_write_bank(space, 0xe000, 0xffff, 0, 0, "bank16"); |
| 3096 | 3054 | |
| 3097 | 3055 | space->machine->device("maincpu")->reset(); |
| 3098 | | if ( amstrad_system_type == SYSTEM_CPC || amstrad_system_type == SYSTEM_ALESTE ) |
| 3056 | if ( state->system_type == SYSTEM_CPC || state->system_type == SYSTEM_ALESTE ) |
| 3099 | 3057 | cpu_set_input_line_vector(machine->device("maincpu"), 0, 0xff); |
| 3100 | 3058 | else |
| 3101 | 3059 | cpu_set_input_line_vector(machine->device("maincpu"), 0, 0x00); |
| r9648 | r9649 | |
| 3155 | 3113 | |
| 3156 | 3114 | MACHINE_START( amstrad ) |
| 3157 | 3115 | { |
| 3116 | amstrad_state *state = machine->driver_data<amstrad_state>(); |
| 3158 | 3117 | multiface_init(machine); |
| 3159 | | amstrad_system_type = SYSTEM_CPC; |
| 3118 | state->system_type = SYSTEM_CPC; |
| 3160 | 3119 | } |
| 3161 | 3120 | |
| 3162 | 3121 | |
| 3163 | 3122 | MACHINE_RESET( amstrad ) |
| 3164 | 3123 | { |
| 3124 | amstrad_state *state = machine->driver_data<amstrad_state>(); |
| 3165 | 3125 | int i; |
| 3166 | 3126 | UINT8 *rom = memory_region(machine, "maincpu"); |
| 3167 | 3127 | |
| 3168 | 3128 | for (i=0; i<256; i++) |
| 3169 | 3129 | { |
| 3170 | | Amstrad_ROM_Table[i] = &rom[0x014000]; |
| 3130 | state->Amstrad_ROM_Table[i] = &rom[0x014000]; |
| 3171 | 3131 | } |
| 3172 | 3132 | |
| 3173 | | Amstrad_ROM_Table[7] = &rom[0x018000]; |
| 3133 | state->Amstrad_ROM_Table[7] = &rom[0x018000]; |
| 3174 | 3134 | amstrad_common_init(machine); |
| 3175 | 3135 | amstrad_reset_machine(machine); |
| 3176 | 3136 | // amstrad_init_palette(machine); |
| 3177 | 3137 | |
| 3178 | | gate_array.de = 0; |
| 3179 | | gate_array.draw_p = NULL; |
| 3180 | | gate_array.hsync = 0; |
| 3181 | | gate_array.vsync = 0; |
| 3138 | state->gate_array.de = 0; |
| 3139 | state->gate_array.draw_p = NULL; |
| 3140 | state->gate_array.hsync = 0; |
| 3141 | state->gate_array.vsync = 0; |
| 3182 | 3142 | |
| 3183 | 3143 | timer_set( machine, attotime_zero, NULL, 0, cb_set_resolution ); |
| 3184 | 3144 | } |
| r9648 | r9649 | |
| 3186 | 3146 | |
| 3187 | 3147 | MACHINE_START( plus ) |
| 3188 | 3148 | { |
| 3189 | | asic.ram = memory_region(machine, "user1"); // 16kB RAM for ASIC, memory-mapped registers. |
| 3190 | | amstrad_system_type = SYSTEM_PLUS; |
| 3149 | amstrad_state *state = machine->driver_data<amstrad_state>(); |
| 3150 | state->asic.ram = memory_region(machine, "user1"); // 16kB RAM for ASIC, memory-mapped registers. |
| 3151 | state->system_type = SYSTEM_PLUS; |
| 3191 | 3152 | } |
| 3192 | 3153 | |
| 3193 | 3154 | |
| 3194 | 3155 | MACHINE_RESET( plus ) |
| 3195 | 3156 | { |
| 3157 | amstrad_state *state = machine->driver_data<amstrad_state>(); |
| 3196 | 3158 | int i; |
| 3197 | 3159 | UINT8 *rom = memory_region(machine, "maincpu"); |
| 3198 | 3160 | |
| 3199 | 3161 | for (i=0; i<128; i++) // fill ROM table |
| 3200 | 3162 | { |
| 3201 | | Amstrad_ROM_Table[i] = &rom[0x4000]; // BASIC in system cart |
| 3163 | state->Amstrad_ROM_Table[i] = &rom[0x4000]; // BASIC in system cart |
| 3202 | 3164 | } |
| 3203 | 3165 | for(i=128;i<160;i++) |
| 3204 | 3166 | { |
| 3205 | | Amstrad_ROM_Table[i] = &rom[(i-128)*0x4000]; |
| 3167 | state->Amstrad_ROM_Table[i] = &rom[(i-128)*0x4000]; |
| 3206 | 3168 | } |
| 3207 | | Amstrad_ROM_Table[7] = &rom[0xc000]; // AMSDOS in system cart |
| 3169 | state->Amstrad_ROM_Table[7] = &rom[0xc000]; // AMSDOS in system cart |
| 3208 | 3170 | |
| 3209 | | asic.enabled = 0; |
| 3210 | | asic.seqptr = 0; |
| 3211 | | asic.pri = 0; // disable PRI |
| 3212 | | asic.dma_status = 0; // disable all DMA channels |
| 3213 | | asic.dma_addr[0] = 0; |
| 3214 | | asic.dma_prescaler[0] = 0; |
| 3215 | | asic.dma_addr[1] = 0; |
| 3216 | | asic.dma_prescaler[1] = 0; |
| 3217 | | asic.dma_addr[2] = 0; |
| 3218 | | asic.dma_prescaler[2] = 0; |
| 3219 | | asic.dma_clear = 1; // by default, DMA interrupts must be cleared by writing to the DSCR (&6c0f) |
| 3220 | | amstrad_plus_irq_cause = 6; |
| 3171 | state->asic.enabled = 0; |
| 3172 | state->asic.seqptr = 0; |
| 3173 | state->asic.pri = 0; // disable PRI |
| 3174 | state->asic.dma_status = 0; // disable all DMA channels |
| 3175 | state->asic.dma_addr[0] = 0; |
| 3176 | state->asic.dma_prescaler[0] = 0; |
| 3177 | state->asic.dma_addr[1] = 0; |
| 3178 | state->asic.dma_prescaler[1] = 0; |
| 3179 | state->asic.dma_addr[2] = 0; |
| 3180 | state->asic.dma_prescaler[2] = 0; |
| 3181 | state->asic.dma_clear = 1; // by default, DMA interrupts must be cleared by writing to the DSCR (&6c0f) |
| 3182 | state->plus_irq_cause = 6; |
| 3221 | 3183 | |
| 3222 | 3184 | amstrad_common_init(machine); |
| 3223 | 3185 | amstrad_reset_machine(machine); |
| 3224 | | asic.ram[0x2805] = 0x01; // interrupt vector is undefined at startup, except that bit 0 is always 1. |
| 3186 | state->asic.ram[0x2805] = 0x01; // interrupt vector is undefined at startup, except that bit 0 is always 1. |
| 3225 | 3187 | AmstradCPC_GA_SetRamConfiguration(machine); |
| 3226 | 3188 | amstrad_GateArray_write(machine, 0x081); // Epyx World of Sports requires upper ROM to be enabled by default |
| 3227 | 3189 | |
| r9648 | r9649 | |
| 3231 | 3193 | |
| 3232 | 3194 | MACHINE_START( gx4000 ) |
| 3233 | 3195 | { |
| 3234 | | asic.ram = memory_region(machine, "user1"); // 16kB RAM for ASIC, memory-mapped registers. |
| 3235 | | amstrad_system_type = SYSTEM_GX4000; |
| 3196 | amstrad_state *state = machine->driver_data<amstrad_state>(); |
| 3197 | state->asic.ram = memory_region(machine, "user1"); // 16kB RAM for ASIC, memory-mapped registers. |
| 3198 | state->system_type = SYSTEM_GX4000; |
| 3236 | 3199 | } |
| 3237 | 3200 | |
| 3238 | 3201 | MACHINE_RESET( gx4000 ) |
| 3239 | 3202 | { |
| 3203 | amstrad_state *state = machine->driver_data<amstrad_state>(); |
| 3240 | 3204 | int i; |
| 3241 | 3205 | UINT8 *rom = memory_region(machine, "maincpu"); |
| 3242 | 3206 | |
| 3243 | 3207 | for (i=0; i<128; i++) // fill ROM table |
| 3244 | 3208 | { |
| 3245 | | Amstrad_ROM_Table[i] = &rom[0x4000]; |
| 3209 | state->Amstrad_ROM_Table[i] = &rom[0x4000]; |
| 3246 | 3210 | } |
| 3247 | 3211 | for(i=128;i<160;i++) |
| 3248 | 3212 | { |
| 3249 | | Amstrad_ROM_Table[i] = &rom[(i-128)*0x4000]; |
| 3213 | state->Amstrad_ROM_Table[i] = &rom[(i-128)*0x4000]; |
| 3250 | 3214 | } |
| 3251 | | Amstrad_ROM_Table[7] = &rom[0xc000]; |
| 3215 | state->Amstrad_ROM_Table[7] = &rom[0xc000]; |
| 3252 | 3216 | |
| 3253 | | asic.enabled = 0; |
| 3254 | | asic.seqptr = 0; |
| 3255 | | asic.pri = 0; // disable PRI |
| 3256 | | asic.dma_status = 0; // disable all DMA channels |
| 3257 | | asic.dma_addr[0] = 0; |
| 3258 | | asic.dma_prescaler[0] = 0; |
| 3259 | | asic.dma_addr[1] = 0; |
| 3260 | | asic.dma_prescaler[1] = 0; |
| 3261 | | asic.dma_addr[2] = 0; |
| 3262 | | asic.dma_prescaler[2] = 0; |
| 3263 | | asic.dma_clear = 1; // by default, DMA interrupts must be cleared by writing to the DSCR (&6c0f) |
| 3264 | | amstrad_plus_irq_cause = 6; |
| 3217 | state->asic.enabled = 0; |
| 3218 | state->asic.seqptr = 0; |
| 3219 | state->asic.pri = 0; // disable PRI |
| 3220 | state->asic.dma_status = 0; // disable all DMA channels |
| 3221 | state->asic.dma_addr[0] = 0; |
| 3222 | state->asic.dma_prescaler[0] = 0; |
| 3223 | state->asic.dma_addr[1] = 0; |
| 3224 | state->asic.dma_prescaler[1] = 0; |
| 3225 | state->asic.dma_addr[2] = 0; |
| 3226 | state->asic.dma_prescaler[2] = 0; |
| 3227 | state->asic.dma_clear = 1; // by default, DMA interrupts must be cleared by writing to the DSCR (&6c0f) |
| 3228 | state->plus_irq_cause = 6; |
| 3265 | 3229 | |
| 3266 | 3230 | amstrad_common_init(machine); |
| 3267 | 3231 | amstrad_reset_machine(machine); |
| 3268 | | asic.ram[0x2805] = 0x01; // interrupt vector is undefined at startup, except that bit 0 is always 1. |
| 3232 | state->asic.ram[0x2805] = 0x01; // interrupt vector is undefined at startup, except that bit 0 is always 1. |
| 3269 | 3233 | AmstradCPC_GA_SetRamConfiguration(machine); |
| 3270 | 3234 | amstrad_GateArray_write(machine, 0x081); // Epyx World of Sports requires upper ROM to be enabled by default |
| 3271 | 3235 | // multiface_init(); |
| r9648 | r9649 | |
| 3275 | 3239 | |
| 3276 | 3240 | MACHINE_START( kccomp ) |
| 3277 | 3241 | { |
| 3242 | amstrad_state *state = machine->driver_data<amstrad_state>(); |
| 3278 | 3243 | multiface_init(machine); |
| 3279 | | amstrad_system_type = SYSTEM_CPC; |
| 3244 | state->system_type = SYSTEM_CPC; |
| 3280 | 3245 | } |
| 3281 | 3246 | |
| 3282 | 3247 | |
| 3283 | 3248 | MACHINE_RESET( kccomp ) |
| 3284 | 3249 | { |
| 3250 | amstrad_state *state = machine->driver_data<amstrad_state>(); |
| 3285 | 3251 | int i; |
| 3286 | 3252 | UINT8 *rom = memory_region(machine, "maincpu"); |
| 3287 | 3253 | |
| 3288 | 3254 | for (i=0; i<256; i++) |
| 3289 | 3255 | { |
| 3290 | | Amstrad_ROM_Table[i] = &rom[0x014000]; |
| 3256 | state->Amstrad_ROM_Table[i] = &rom[0x014000]; |
| 3291 | 3257 | } |
| 3292 | 3258 | |
| 3293 | 3259 | amstrad_common_init(machine); |
| r9648 | r9649 | |
| 3299 | 3265 | When the program has been transfered, it will be executed. This |
| 3300 | 3266 | is not supported in the driver */ |
| 3301 | 3267 | /* bit 3,4 are tied to +5V, bit 2 is tied to 0V */ |
| 3302 | | ppi_port_inputs[amstrad_ppi_PortB] = (1<<4) | (1<<3) | 2; |
| 3268 | state->ppi_port_inputs[amstrad_ppi_PortB] = (1<<4) | (1<<3) | 2; |
| 3303 | 3269 | } |
| 3304 | 3270 | |
| 3305 | 3271 | |
| 3306 | 3272 | MACHINE_START( aleste ) |
| 3307 | 3273 | { |
| 3274 | amstrad_state *state = machine->driver_data<amstrad_state>(); |
| 3308 | 3275 | multiface_init(machine); |
| 3309 | | amstrad_system_type = SYSTEM_ALESTE; |
| 3276 | state->system_type = SYSTEM_ALESTE; |
| 3310 | 3277 | } |
| 3311 | 3278 | |
| 3312 | 3279 | MACHINE_RESET( aleste ) |
| 3313 | 3280 | { |
| 3281 | amstrad_state *state = machine->driver_data<amstrad_state>(); |
| 3314 | 3282 | int i; |
| 3315 | 3283 | UINT8 *rom = memory_region(machine, "maincpu"); |
| 3316 | 3284 | |
| 3317 | 3285 | for (i=0; i<256; i++) |
| 3318 | 3286 | { |
| 3319 | | Amstrad_ROM_Table[i] = &rom[0x014000]; |
| 3287 | state->Amstrad_ROM_Table[i] = &rom[0x014000]; |
| 3320 | 3288 | } |
| 3321 | 3289 | |
| 3322 | | Amstrad_ROM_Table[3] = &rom[0x01c000]; // MSX-DOS / BIOS |
| 3323 | | Amstrad_ROM_Table[7] = &rom[0x018000]; // AMSDOS |
| 3290 | state->Amstrad_ROM_Table[3] = &rom[0x01c000]; // MSX-DOS / BIOS |
| 3291 | state->Amstrad_ROM_Table[7] = &rom[0x018000]; // AMSDOS |
| 3324 | 3292 | amstrad_common_init(machine); |
| 3325 | 3293 | amstrad_reset_machine(machine); |
| 3326 | 3294 | |
src/mess/machine/apple2gs.c
| r9648 | r9649 | |
| 132 | 132 | #define IRQ_INTEN_VBL 0x40 |
| 133 | 133 | #define IRQ_DOC 0x80 |
| 134 | 134 | |
| 135 | | UINT8 *apple2gs_slowmem; |
| 136 | | UINT8 apple2gs_newvideo; |
| 137 | | UINT8 apple2gs_docram[64*1024]; |
| 138 | 135 | |
| 139 | | static UINT8 apple2gs_vgcint; |
| 140 | | static UINT8 apple2gs_langsel; |
| 141 | | static UINT8 apple2gs_sltromsel; |
| 142 | | static UINT8 apple2gs_cyareg; |
| 143 | | static UINT8 apple2gs_inten; |
| 144 | | static UINT8 apple2gs_intflag; |
| 145 | | static UINT8 apple2gs_shadow; |
| 146 | | static UINT8 apple2gs_pending_irqs; |
| 147 | | static UINT8 apple2gs_mouse_x; |
| 148 | | static UINT8 apple2gs_mouse_y; |
| 149 | | static INT8 apple2gs_mouse_dx; |
| 150 | | static INT8 apple2gs_mouse_dy; |
| 151 | | static running_device *apple2gs_cur_slot6_image; |
| 152 | | static emu_timer *apple2gs_scanline_timer; |
| 153 | | static emu_timer *apple2gs_clock_timer; |
| 154 | | static emu_timer *apple2gs_qsecond_timer; |
| 155 | 136 | |
| 156 | 137 | |
| 157 | 138 | /* ----------------------------------------------------------------------- |
| 158 | 139 | * Apple IIgs clock |
| 159 | 140 | * ----------------------------------------------------------------------- */ |
| 160 | 141 | |
| 161 | | typedef enum |
| 162 | | { |
| 163 | | CLOCKMODE_IDLE, |
| 164 | | CLOCKMODE_TIME, |
| 165 | | CLOCKMODE_INTERNALREGS, |
| 166 | | CLOCKMODE_BRAM1, |
| 167 | | CLOCKMODE_BRAM2 |
| 168 | | } apple2gs_clock_mode; |
| 169 | 142 | |
| 170 | | static UINT8 clock_data; |
| 171 | | static UINT8 clock_control; |
| 172 | | static UINT8 clock_read; |
| 173 | | static UINT8 clock_reg1; |
| 174 | | static apple2gs_clock_mode clock_mode; |
| 175 | | static UINT32 clock_curtime; /* number of seconds since 1-Jan-1904 */ |
| 176 | | static seconds_t clock_curtime_interval; /* second index at which clock_curtime is valid */ |
| 177 | | static UINT8 clock_bram[256]; |
| 178 | 143 | |
| 179 | | |
| 180 | 144 | static void process_clock(running_machine *machine) |
| 181 | 145 | { |
| 146 | apple2gs_state *state = machine->driver_data<apple2gs_state>(); |
| 182 | 147 | UINT8 operation; |
| 183 | 148 | seconds_t current_interval; |
| 184 | 149 | |
| 185 | | /* update clock_curtime */ |
| 150 | /* update state->clock_curtime */ |
| 186 | 151 | current_interval = timer_get_time(machine).seconds; |
| 187 | | clock_curtime += current_interval - clock_curtime_interval; |
| 188 | | clock_curtime_interval = current_interval; |
| 152 | state->clock_curtime += current_interval - state->clock_curtime_interval; |
| 153 | state->clock_curtime_interval = current_interval; |
| 189 | 154 | |
| 190 | | switch(clock_mode) |
| 155 | switch(state->clock_mode) |
| 191 | 156 | { |
| 192 | 157 | case CLOCKMODE_IDLE: |
| 193 | | clock_read = (clock_data >> 7); |
| 194 | | clock_reg1 = (clock_data >> 2) & 0x03; |
| 195 | | operation = (clock_data >> 4) & 0x07; |
| 158 | state->clock_read = (state->clock_data >> 7); |
| 159 | state->clock_reg1 = (state->clock_data >> 2) & 0x03; |
| 160 | operation = (state->clock_data >> 4) & 0x07; |
| 196 | 161 | |
| 197 | | if ((clock_data & 0x40) == 0x00) |
| 162 | if ((state->clock_data & 0x40) == 0x00) |
| 198 | 163 | { |
| 199 | 164 | switch(operation) |
| 200 | 165 | { |
| 201 | 166 | case 0x00: |
| 202 | 167 | /* read/write seconds register */ |
| 203 | | clock_mode = CLOCKMODE_TIME; |
| 168 | state->clock_mode = CLOCKMODE_TIME; |
| 204 | 169 | break; |
| 205 | 170 | |
| 206 | 171 | case 0x03: |
| 207 | 172 | /* internal registers */ |
| 208 | | if (clock_reg1 & 0x02) |
| 173 | if (state->clock_reg1 & 0x02) |
| 209 | 174 | { |
| 210 | | clock_mode = CLOCKMODE_BRAM2; |
| 211 | | clock_reg1 = (clock_data & 0x07) << 5; |
| 175 | state->clock_mode = CLOCKMODE_BRAM2; |
| 176 | state->clock_reg1 = (state->clock_data & 0x07) << 5; |
| 212 | 177 | } |
| 213 | 178 | else |
| 214 | 179 | { |
| 215 | | clock_mode = CLOCKMODE_INTERNALREGS; |
| 180 | state->clock_mode = CLOCKMODE_INTERNALREGS; |
| 216 | 181 | } |
| 217 | 182 | break; |
| 218 | 183 | |
| r9648 | r9649 | |
| 224 | 189 | break; |
| 225 | 190 | |
| 226 | 191 | case CLOCKMODE_BRAM1: |
| 227 | | if (clock_read) |
| 228 | | clock_data = clock_bram[clock_reg1]; |
| 192 | if (state->clock_read) |
| 193 | state->clock_data = state->clock_bram[state->clock_reg1]; |
| 229 | 194 | else |
| 230 | | clock_bram[clock_reg1] = clock_data; |
| 231 | | clock_mode = CLOCKMODE_IDLE; |
| 195 | state->clock_bram[state->clock_reg1] = state->clock_data; |
| 196 | state->clock_mode = CLOCKMODE_IDLE; |
| 232 | 197 | break; |
| 233 | 198 | |
| 234 | 199 | case CLOCKMODE_BRAM2: |
| 235 | | clock_reg1 |= (clock_data >> 2) & 0x1F; |
| 236 | | clock_mode = CLOCKMODE_BRAM1; |
| 200 | state->clock_reg1 |= (state->clock_data >> 2) & 0x1F; |
| 201 | state->clock_mode = CLOCKMODE_BRAM1; |
| 237 | 202 | break; |
| 238 | 203 | |
| 239 | 204 | case CLOCKMODE_INTERNALREGS: |
| 240 | | switch (clock_reg1) |
| 205 | switch (state->clock_reg1) |
| 241 | 206 | { |
| 242 | 207 | case 0x00: |
| 243 | 208 | /* test register */ |
| r9648 | r9649 | |
| 247 | 212 | /* write protect register */ |
| 248 | 213 | break; |
| 249 | 214 | } |
| 250 | | clock_mode = CLOCKMODE_IDLE; |
| 215 | state->clock_mode = CLOCKMODE_IDLE; |
| 251 | 216 | break; |
| 252 | 217 | |
| 253 | 218 | case CLOCKMODE_TIME: |
| 254 | | if (clock_data & 0x40) |
| 219 | if (state->clock_data & 0x40) |
| 255 | 220 | { |
| 256 | | clock_data = clock_curtime >> (clock_reg1 * 8); |
| 221 | state->clock_data = state->clock_curtime >> (state->clock_reg1 * 8); |
| 257 | 222 | } |
| 258 | 223 | else |
| 259 | 224 | { |
| 260 | | clock_curtime &= ~(0xFF << (clock_reg1 * 8)); |
| 261 | | clock_curtime |= clock_data << (clock_reg1 * 8); |
| 225 | state->clock_curtime &= ~(0xFF << (state->clock_reg1 * 8)); |
| 226 | state->clock_curtime |= state->clock_data << (state->clock_reg1 * 8); |
| 262 | 227 | } |
| 263 | | clock_mode = CLOCKMODE_IDLE; |
| 228 | state->clock_mode = CLOCKMODE_IDLE; |
| 264 | 229 | break; |
| 265 | 230 | |
| 266 | 231 | default: |
| r9648 | r9649 | |
| 273 | 238 | |
| 274 | 239 | NVRAM_HANDLER( apple2gs ) |
| 275 | 240 | { |
| 241 | apple2gs_state *state = machine->driver_data<apple2gs_state>(); |
| 276 | 242 | if (read_or_write) |
| 277 | 243 | { |
| 278 | | mame_fwrite(file, clock_bram, sizeof(clock_bram)); |
| 244 | mame_fwrite(file, state->clock_bram, sizeof(state->clock_bram)); |
| 279 | 245 | } |
| 280 | 246 | else if (file) |
| 281 | 247 | { |
| 282 | | mame_fread(file, clock_bram, sizeof(clock_bram)); |
| 248 | mame_fread(file, state->clock_bram, sizeof(state->clock_bram)); |
| 283 | 249 | } |
| 284 | 250 | else |
| 285 | 251 | { |
| 286 | | memset(clock_bram, 0x00, sizeof(clock_bram)); |
| 252 | memset(state->clock_bram, 0x00, sizeof(state->clock_bram)); |
| 287 | 253 | } |
| 288 | 254 | } |
| 289 | 255 | |
| r9648 | r9649 | |
| 311 | 277 | |
| 312 | 278 | static void apple2gs_add_irq(running_machine *machine, UINT8 irq_mask) |
| 313 | 279 | { |
| 314 | | if ((apple2gs_pending_irqs & irq_mask) == 0x00) |
| 280 | apple2gs_state *state = machine->driver_data<apple2gs_state>(); |
| 281 | if ((state->pending_irqs & irq_mask) == 0x00) |
| 315 | 282 | { |
| 316 | 283 | if (LOG_IRQ) |
| 317 | 284 | logerror("apple2gs_add_irq(): adding %s\n", apple2gs_irq_name(irq_mask)); |
| 318 | 285 | |
| 319 | | apple2gs_pending_irqs |= irq_mask; |
| 320 | | cputag_set_input_line(machine, "maincpu", G65816_LINE_IRQ, apple2gs_pending_irqs ? ASSERT_LINE : CLEAR_LINE); |
| 286 | state->pending_irqs |= irq_mask; |
| 287 | cputag_set_input_line(machine, "maincpu", G65816_LINE_IRQ, state->pending_irqs ? ASSERT_LINE : CLEAR_LINE); |
| 321 | 288 | } |
| 322 | 289 | } |
| 323 | 290 | |
| r9648 | r9649 | |
| 325 | 292 | |
| 326 | 293 | static void apple2gs_remove_irq(running_machine *machine, UINT8 irq_mask) |
| 327 | 294 | { |
| 328 | | if (apple2gs_pending_irqs & irq_mask) |
| 295 | apple2gs_state *state = machine->driver_data<apple2gs_state>(); |
| 296 | if (state->pending_irqs & irq_mask) |
| 329 | 297 | { |
| 330 | 298 | if (LOG_IRQ) |
| 331 | 299 | logerror("apple2gs_remove_irq(): removing %s\n", apple2gs_irq_name(irq_mask)); |
| 332 | 300 | |
| 333 | | apple2gs_pending_irqs &= ~irq_mask; |
| 334 | | cputag_set_input_line(machine, "maincpu", G65816_LINE_IRQ, apple2gs_pending_irqs ? ASSERT_LINE : CLEAR_LINE); |
| 301 | state->pending_irqs &= ~irq_mask; |
| 302 | cputag_set_input_line(machine, "maincpu", G65816_LINE_IRQ, state->pending_irqs ? ASSERT_LINE : CLEAR_LINE); |
| 335 | 303 | } |
| 336 | 304 | } |
| 337 | 305 | |
| r9648 | r9649 | |
| 351 | 319 | /* Clock interrupt */ |
| 352 | 320 | static TIMER_CALLBACK( apple2gs_clock_tick ) |
| 353 | 321 | { |
| 354 | | if ((apple2gs_vgcint & 0x04) && !(apple2gs_vgcint & 0x40)) |
| 322 | apple2gs_state *state = machine->driver_data<apple2gs_state>(); |
| 323 | if ((state->vgcint & 0x04) && !(state->vgcint & 0x40)) |
| 355 | 324 | { |
| 356 | | apple2gs_vgcint |= 0xc0; |
| 325 | state->vgcint |= 0xc0; |
| 357 | 326 | apple2gs_add_irq(machine, IRQ_VGC_SECOND); |
| 358 | 327 | } |
| 359 | 328 | } |
| r9648 | r9649 | |
| 362 | 331 | /* Quarter-second interrupt */ |
| 363 | 332 | static TIMER_CALLBACK( apple2gs_qsecond_tick ) |
| 364 | 333 | { |
| 365 | | if ((apple2gs_inten & 0x10) && !(apple2gs_intflag & 0x10)) |
| 334 | apple2gs_state *state = machine->driver_data<apple2gs_state>(); |
| 335 | if ((state->inten & 0x10) && !(state->intflag & 0x10)) |
| 366 | 336 | { |
| 367 | | apple2gs_intflag |= 0x10; |
| 337 | state->intflag |= 0x10; |
| 368 | 338 | apple2gs_add_irq(machine, IRQ_INTEN_QSECOND); |
| 369 | 339 | } |
| 370 | 340 | } |
| r9648 | r9649 | |
| 374 | 344 | * ADB |
| 375 | 345 | * ----------------------------------------------------------------------- */ |
| 376 | 346 | |
| 377 | | typedef enum |
| 378 | | { |
| 379 | | ADBSTATE_IDLE, |
| 380 | | ADBSTATE_INCOMMAND, |
| 381 | | ADBSTATE_INRESPONSE |
| 382 | | } adbstate_t; |
| 383 | 347 | |
| 384 | | static adbstate_t adb_state; |
| 385 | | static UINT8 adb_command; |
| 386 | | static UINT8 adb_mode; |
| 387 | | static UINT8 adb_kmstatus; |
| 388 | | static UINT8 adb_latent_result; |
| 389 | | static INT32 adb_command_length; |
| 390 | | static INT32 adb_command_pos; |
| 391 | | static UINT8 adb_command_bytes[8]; |
| 392 | | static UINT8 adb_response_bytes[8]; |
| 393 | | static UINT8 adb_response_length; |
| 394 | | static INT32 adb_response_pos; |
| 395 | | static UINT8 adb_memory[0x100]; |
| 396 | | static int adb_address_keyboard; |
| 397 | | static int adb_address_mouse; |
| 398 | 348 | |
| 399 | | |
| 400 | | static UINT8 adb_read_memory(UINT32 address) |
| 349 | static UINT8 adb_read_memory(apple2gs_state *state, UINT32 address) |
| 401 | 350 | { |
| 402 | | if (address < ARRAY_LENGTH(adb_memory)) |
| 403 | | return adb_memory[address]; |
| 351 | if (address < ARRAY_LENGTH(state->adb_memory)) |
| 352 | return state->adb_memory[address]; |
| 404 | 353 | else |
| 405 | 354 | return 0x00; |
| 406 | 355 | } |
| 407 | 356 | |
| 408 | 357 | |
| 409 | 358 | |
| 410 | | static void adb_write_memory(UINT32 address, UINT8 data) |
| 359 | static void adb_write_memory(apple2gs_state *state, UINT32 address, UINT8 data) |
| 411 | 360 | { |
| 412 | | if (address < ARRAY_LENGTH(adb_memory)) |
| 413 | | adb_memory[address] = data; |
| 361 | if (address < ARRAY_LENGTH(state->adb_memory)) |
| 362 | state->adb_memory[address] = data; |
| 414 | 363 | } |
| 415 | 364 | |
| 416 | 365 | |
| 417 | 366 | |
| 418 | | static void adb_set_mode(UINT8 mode) |
| 367 | static void adb_set_mode(apple2gs_state *state, UINT8 mode) |
| 419 | 368 | { |
| 420 | | adb_mode = mode; |
| 369 | state->adb_mode = mode; |
| 421 | 370 | } |
| 422 | 371 | |
| 423 | 372 | |
| r9648 | r9649 | |
| 429 | 378 | |
| 430 | 379 | |
| 431 | 380 | |
| 432 | | static void adb_post_response(const UINT8 *bytes, size_t length) |
| 381 | static void adb_post_response(apple2gs_state *state, const UINT8 *bytes, size_t length) |
| 433 | 382 | { |
| 434 | | assert(length < ARRAY_LENGTH(adb_response_bytes)); |
| 435 | | memcpy(adb_response_bytes, bytes, length); |
| 383 | assert(length < ARRAY_LENGTH(state->adb_response_bytes)); |
| 384 | memcpy(state->adb_response_bytes, bytes, length); |
| 436 | 385 | |
| 437 | | adb_state = ADBSTATE_INRESPONSE; |
| 438 | | adb_response_length = length; |
| 439 | | adb_response_pos = 0; |
| 386 | state->adb_state = ADBSTATE_INRESPONSE; |
| 387 | state->adb_response_length = length; |
| 388 | state->adb_response_pos = 0; |
| 440 | 389 | } |
| 441 | 390 | |
| 442 | 391 | |
| 443 | 392 | |
| 444 | | static void adb_post_response_1(UINT8 b) |
| 393 | static void adb_post_response_1(apple2gs_state *state, UINT8 b) |
| 445 | 394 | { |
| 446 | | adb_post_response(&b, 1); |
| 395 | adb_post_response(state, &b, 1); |
| 447 | 396 | } |
| 448 | 397 | |
| 449 | 398 | |
| 450 | 399 | |
| 451 | | static void adb_post_response_2(UINT8 b1, UINT8 b2) |
| 400 | static void adb_post_response_2(apple2gs_state *state, UINT8 b1, UINT8 b2) |
| 452 | 401 | { |
| 453 | 402 | UINT8 b[2]; |
| 454 | 403 | b[0] = b1; |
| 455 | 404 | b[1] = b2; |
| 456 | | adb_post_response(b, 2); |
| 405 | adb_post_response(state, b, 2); |
| 457 | 406 | } |
| 458 | 407 | |
| 459 | 408 | |
| 460 | 409 | |
| 461 | | static void adb_do_command(void) |
| 410 | static void adb_do_command(apple2gs_state *state) |
| 462 | 411 | { |
| 463 | 412 | int device; |
| 464 | 413 | UINT32 address; |
| 465 | 414 | UINT8 val; |
| 466 | 415 | |
| 467 | | adb_state = ADBSTATE_IDLE; |
| 416 | state->adb_state = ADBSTATE_IDLE; |
| 468 | 417 | if (LOG_ADB) |
| 469 | | logerror("adb_do_command(): adb_command=0x%02x\n", adb_command); |
| 418 | logerror("adb_do_command(): state->adb_command=0x%02x\n", state->adb_command); |
| 470 | 419 | |
| 471 | | switch(adb_command) |
| 420 | switch(state->adb_command) |
| 472 | 421 | { |
| 473 | 422 | case 0x00: /* ??? */ |
| 474 | 423 | break; |
| r9648 | r9649 | |
| 477 | 426 | break; |
| 478 | 427 | |
| 479 | 428 | case 0x04: /* set modes */ |
| 480 | | adb_set_mode(adb_mode | adb_command_bytes[0]); |
| 429 | adb_set_mode(state, state->adb_mode | state->adb_command_bytes[0]); |
| 481 | 430 | break; |
| 482 | 431 | |
| 483 | 432 | case 0x05: /* clear modes */ |
| 484 | | adb_set_mode(adb_mode & ~adb_command_bytes[0]); |
| 433 | adb_set_mode(state, state->adb_mode & ~state->adb_command_bytes[0]); |
| 485 | 434 | break; |
| 486 | 435 | |
| 487 | 436 | case 0x06: /* set config */ |
| 488 | | adb_set_config(adb_command_bytes[0], adb_command_bytes[1], adb_command_bytes[2]); |
| 437 | adb_set_config(state->adb_command_bytes[0], state->adb_command_bytes[1], state->adb_command_bytes[2]); |
| 489 | 438 | break; |
| 490 | 439 | |
| 491 | 440 | case 0x07: /* synchronize */ |
| 492 | | adb_set_mode(adb_command_bytes[0]); |
| 493 | | adb_set_config(adb_command_bytes[1], adb_command_bytes[2], adb_command_bytes[3]); |
| 441 | adb_set_mode(state, state->adb_command_bytes[0]); |
| 442 | adb_set_config(state->adb_command_bytes[1], state->adb_command_bytes[2], state->adb_command_bytes[3]); |
| 494 | 443 | break; |
| 495 | 444 | |
| 496 | 445 | case 0x08: /* write memory */ |
| 497 | | address = adb_command_bytes[0]; |
| 498 | | val = adb_command_bytes[1]; |
| 499 | | adb_write_memory(address, val); |
| 446 | address = state->adb_command_bytes[0]; |
| 447 | val = state->adb_command_bytes[1]; |
| 448 | adb_write_memory(state, address, val); |
| 500 | 449 | break; |
| 501 | 450 | |
| 502 | 451 | case 0x09: /* read memory */ |
| 503 | | address = (adb_command_bytes[1] << 8) | adb_command_bytes[0]; |
| 504 | | adb_post_response_1(adb_read_memory(address)); |
| 452 | address = (state->adb_command_bytes[1] << 8) | state->adb_command_bytes[0]; |
| 453 | adb_post_response_1(state, adb_read_memory(state, address)); |
| 505 | 454 | break; |
| 506 | 455 | |
| 507 | 456 | case 0x0d: /* get version */ |
| 508 | | adb_post_response_1(0x06); |
| 457 | adb_post_response_1(state, 0x06); |
| 509 | 458 | break; |
| 510 | 459 | |
| 511 | 460 | case 0x0e: /* read available charsets */ |
| 512 | | adb_post_response_2(0x01, 0x00); |
| 461 | adb_post_response_2(state, 0x01, 0x00); |
| 513 | 462 | break; |
| 514 | 463 | |
| 515 | 464 | case 0x0f: /* read available layouts */ |
| 516 | | adb_post_response_2(0x01, 0x00); |
| 465 | adb_post_response_2(state, 0x01, 0x00); |
| 517 | 466 | break; |
| 518 | 467 | |
| 519 | 468 | case 0x12: /* mystery command 0x12 */ |
| r9648 | r9649 | |
| 525 | 474 | case 0xb8: case 0xb9: case 0xba: case 0xbb: |
| 526 | 475 | case 0xbc: case 0xbd: case 0xbe: case 0xbf: |
| 527 | 476 | /* send data to device */ |
| 528 | | device = adb_command & 0x0f; |
| 529 | | if (device == adb_address_keyboard) |
| 477 | device = state->adb_command & 0x0f; |
| 478 | if (device == state->adb_address_keyboard) |
| 530 | 479 | { |
| 531 | 480 | } |
| 532 | | else if (device == adb_address_mouse) |
| 481 | else if (device == state->adb_address_mouse) |
| 533 | 482 | { |
| 534 | 483 | } |
| 535 | 484 | break; |
| 536 | 485 | |
| 537 | 486 | default: |
| 538 | | fatalerror("ADB command 0x%02x unimplemented", adb_command); |
| 487 | fatalerror("ADB command 0x%02x unimplemented", state->adb_command); |
| 539 | 488 | break; |
| 540 | 489 | } |
| 541 | | adb_kmstatus |= 0x20; |
| 490 | state->adb_kmstatus |= 0x20; |
| 542 | 491 | } |
| 543 | 492 | |
| 544 | 493 | |
| 545 | 494 | |
| 546 | | static UINT8 adb_read_datareg(void) |
| 495 | static UINT8 adb_read_datareg(apple2gs_state *state) |
| 547 | 496 | { |
| 548 | 497 | UINT8 result; |
| 549 | 498 | |
| 550 | | switch(adb_state) |
| 499 | switch(state->adb_state) |
| 551 | 500 | { |
| 552 | 501 | case ADBSTATE_INRESPONSE: |
| 553 | | result = adb_response_bytes[adb_response_pos++]; |
| 554 | | if (adb_response_pos >= adb_response_length) |
| 502 | result = state->adb_response_bytes[state->adb_response_pos++]; |
| 503 | if (state->adb_response_pos >= state->adb_response_length) |
| 555 | 504 | { |
| 556 | | adb_state = ADBSTATE_IDLE; |
| 557 | | adb_latent_result = result; |
| 558 | | adb_kmstatus &= ~0x20; |
| 505 | state->adb_state = ADBSTATE_IDLE; |
| 506 | state->adb_latent_result = result; |
| 507 | state->adb_kmstatus &= ~0x20; |
| 559 | 508 | } |
| 560 | 509 | break; |
| 561 | 510 | |
| 562 | 511 | default: |
| 563 | | result = 0; //adb_latent_result & 0x7f; |
| 512 | result = 0; //state->adb_latent_result & 0x7f; |
| 564 | 513 | break; |
| 565 | 514 | } |
| 566 | 515 | |
| r9648 | r9649 | |
| 574 | 523 | |
| 575 | 524 | static void adb_write_datareg(running_machine *machine, UINT8 data) |
| 576 | 525 | { |
| 526 | apple2gs_state *state = machine->driver_data<apple2gs_state>(); |
| 577 | 527 | if (LOG_ADB) |
| 578 | 528 | logerror("adb_write_datareg(): data=0x%02x\n", data); |
| 579 | 529 | |
| 580 | | switch(adb_state) |
| 530 | switch(state->adb_state) |
| 581 | 531 | { |
| 582 | 532 | case ADBSTATE_IDLE: |
| 583 | | adb_command = data; |
| 584 | | adb_command_length = 0; |
| 585 | | adb_command_pos = 0; |
| 533 | state->adb_command = data; |
| 534 | state->adb_command_length = 0; |
| 535 | state->adb_command_pos = 0; |
| 586 | 536 | |
| 587 | 537 | switch(data) |
| 588 | 538 | { |
| r9648 | r9649 | |
| 592 | 542 | break; |
| 593 | 543 | |
| 594 | 544 | case 0x03: /* flush keyboard buffer */ |
| 595 | | adb_command_length = 0; |
| 545 | state->adb_command_length = 0; |
| 596 | 546 | break; |
| 597 | 547 | |
| 598 | 548 | case 0x04: /* set modes */ |
| 599 | 549 | case 0x05: /* clear modes */ |
| 600 | | adb_command_length = 1; |
| 550 | state->adb_command_length = 1; |
| 601 | 551 | break; |
| 602 | 552 | |
| 603 | 553 | case 0x06: /* set config */ |
| 604 | | adb_command_length = 3; |
| 554 | state->adb_command_length = 3; |
| 605 | 555 | break; |
| 606 | 556 | |
| 607 | 557 | case 0x07: /* synchronize */ |
| 608 | 558 | if (memory_region_length(machine, "maincpu") == 0x40000) /* HACK */ |
| 609 | | adb_command_length = 8; |
| 559 | state->adb_command_length = 8; |
| 610 | 560 | else |
| 611 | | adb_command_length = 4; |
| 561 | state->adb_command_length = 4; |
| 612 | 562 | break; |
| 613 | 563 | |
| 614 | 564 | case 0x08: /* write memory */ |
| 615 | 565 | case 0x09: /* read memory */ |
| 616 | | adb_command_length = 2; |
| 566 | state->adb_command_length = 2; |
| 617 | 567 | break; |
| 618 | 568 | |
| 619 | 569 | case 0x0d: /* get version */ |
| 620 | | adb_command_length = 0; |
| 570 | state->adb_command_length = 0; |
| 621 | 571 | break; |
| 622 | 572 | |
| 623 | 573 | case 0x0e: /* read available charsets */ |
| 624 | | adb_command_length = 0; |
| 625 | | adb_state = ADBSTATE_INCOMMAND; /* HACK */ |
| 574 | state->adb_command_length = 0; |
| 575 | state->adb_state = ADBSTATE_INCOMMAND; /* HACK */ |
| 626 | 576 | break; |
| 627 | 577 | |
| 628 | 578 | case 0x0f: /* read available layouts */ |
| 629 | | adb_command_length = 0; |
| 630 | | adb_state = ADBSTATE_INCOMMAND; /* HACK */ |
| 579 | state->adb_command_length = 0; |
| 580 | state->adb_state = ADBSTATE_INCOMMAND; /* HACK */ |
| 631 | 581 | break; |
| 632 | 582 | |
| 633 | 583 | case 0x12: /* mystery command 0x12 */ |
| 634 | 584 | case 0x13: /* mystery command 0x13 */ |
| 635 | | adb_command_length = 2; |
| 585 | state->adb_command_length = 2; |
| 636 | 586 | break; |
| 637 | 587 | |
| 638 | 588 | case 0x70: /* disable SRQ device 0 */ |
| r9648 | r9649 | |
| 647 | 597 | case 0xb8: case 0xb9: case 0xba: case 0xbb: |
| 648 | 598 | case 0xbc: case 0xbd: case 0xbe: case 0xbf: |
| 649 | 599 | /* send data to device */ |
| 650 | | adb_command_length = 2; |
| 600 | state->adb_command_length = 2; |
| 651 | 601 | break; |
| 652 | 602 | |
| 653 | 603 | default: |
| r9648 | r9649 | |
| 656 | 606 | |
| 657 | 607 | } |
| 658 | 608 | |
| 659 | | if (adb_command_length > 0) |
| 609 | if (state->adb_command_length > 0) |
| 660 | 610 | { |
| 661 | | adb_state = ADBSTATE_INCOMMAND; |
| 611 | state->adb_state = ADBSTATE_INCOMMAND; |
| 662 | 612 | if (LOG_ADB) |
| 663 | | logerror("adb_write_datareg(): in command length %u\n", (unsigned) adb_command_length); |
| 613 | logerror("adb_write_datareg(): in command length %u\n", (unsigned) state->adb_command_length); |
| 664 | 614 | } |
| 665 | 615 | break; |
| 666 | 616 | |
| 667 | 617 | case ADBSTATE_INCOMMAND: |
| 668 | | assert(adb_command_pos < ARRAY_LENGTH(adb_command_bytes)); |
| 669 | | adb_command_bytes[adb_command_pos++] = data; |
| 618 | assert(state->adb_command_pos < ARRAY_LENGTH(state->adb_command_bytes)); |
| 619 | state->adb_command_bytes[state->adb_command_pos++] = data; |
| 670 | 620 | break; |
| 671 | 621 | |
| 672 | 622 | case ADBSTATE_INRESPONSE: |
| 673 | | adb_state = ADBSTATE_IDLE; |
| 623 | state->adb_state = ADBSTATE_IDLE; |
| 674 | 624 | break; |
| 675 | 625 | } |
| 676 | 626 | |
| 677 | 627 | /* do command if necessary */ |
| 678 | | if ((adb_state == ADBSTATE_INCOMMAND) && (adb_command_pos >= adb_command_length)) |
| 679 | | adb_do_command(); |
| 628 | if ((state->adb_state == ADBSTATE_INCOMMAND) && (state->adb_command_pos >= state->adb_command_length)) |
| 629 | adb_do_command(state); |
| 680 | 630 | } |
| 681 | 631 | |
| 682 | 632 | |
| 683 | 633 | // real rom 3 h/w reads 0x90 when idle, 0x98 when key pressed |
| 684 | 634 | // current MESS reads back 0xb0 when idle |
| 685 | | static UINT8 adb_read_kmstatus(void) |
| 635 | static UINT8 adb_read_kmstatus(apple2gs_state *state) |
| 686 | 636 | { |
| 687 | | return adb_kmstatus; |
| 637 | return state->adb_kmstatus; |
| 688 | 638 | } |
| 689 | 639 | |
| 690 | 640 | |
| 691 | 641 | |
| 692 | | static void adb_write_kmstatus(UINT8 data) |
| 642 | static void adb_write_kmstatus(apple2gs_state *state, UINT8 data) |
| 693 | 643 | { |
| 694 | | adb_kmstatus &= ~0x54; |
| 695 | | adb_kmstatus |= data & 0x54; |
| 644 | state->adb_kmstatus &= ~0x54; |
| 645 | state->adb_kmstatus |= data & 0x54; |
| 696 | 646 | } |
| 697 | 647 | |
| 698 | 648 | |
| 699 | 649 | |
| 700 | 650 | static UINT8 adb_read_mousedata(running_machine *machine) |
| 701 | 651 | { |
| 652 | apple2gs_state *state = machine->driver_data<apple2gs_state>(); |
| 702 | 653 | UINT8 result = 0x00; |
| 703 | 654 | UINT8 absolute; |
| 704 | 655 | INT8 delta; |
| 705 | 656 | |
| 706 | | if (adb_kmstatus & 0x80) // mouse register full |
| 657 | if (state->adb_kmstatus & 0x80) // mouse register full |
| 707 | 658 | { |
| 708 | | if (adb_kmstatus & 0x02) // H/V mouse data select |
| 659 | if (state->adb_kmstatus & 0x02) // H/V mouse data select |
| 709 | 660 | { |
| 710 | | absolute = apple2gs_mouse_y; |
| 711 | | delta = apple2gs_mouse_dy; |
| 712 | | adb_kmstatus &= ~0x82; |
| 661 | absolute = state->mouse_y; |
| 662 | delta = state->mouse_dy; |
| 663 | state->adb_kmstatus &= ~0x82; |
| 713 | 664 | apple2gs_remove_irq(machine, IRQ_ADB_MOUSE); |
| 714 | 665 | } |
| 715 | 666 | else |
| 716 | 667 | { |
| 717 | | absolute = apple2gs_mouse_x; |
| 718 | | delta = apple2gs_mouse_dx; |
| 719 | | adb_kmstatus |= 0x02; |
| 668 | absolute = state->mouse_x; |
| 669 | delta = state->mouse_dx; |
| 670 | state->adb_kmstatus |= 0x02; |
| 720 | 671 | } |
| 721 | 672 | |
| 722 | 673 | if (delta > 63) |
| r9648 | r9649 | |
| 745 | 696 | |
| 746 | 697 | static void adb_check_mouse(running_machine *machine) |
| 747 | 698 | { |
| 699 | apple2gs_state *state = machine->driver_data<apple2gs_state>(); |
| 748 | 700 | UINT8 new_mouse_x, new_mouse_y; |
| 749 | 701 | |
| 750 | 702 | /* read mouse values */ |
| 751 | | if ((adb_kmstatus & 0x80) == 0x00) |
| 703 | if ((state->adb_kmstatus & 0x80) == 0x00) |
| 752 | 704 | { |
| 753 | 705 | new_mouse_x = input_port_read(machine, "adb_mouse_x"); |
| 754 | 706 | new_mouse_y = input_port_read(machine, "adb_mouse_y"); |
| 755 | 707 | |
| 756 | | if ((apple2gs_mouse_x != new_mouse_x) || (apple2gs_mouse_y != new_mouse_y)) |
| 708 | if ((state->mouse_x != new_mouse_x) || (state->mouse_y != new_mouse_y)) |
| 757 | 709 | { |
| 758 | | apple2gs_mouse_dx = seven_bit_diff(new_mouse_x, apple2gs_mouse_x); |
| 759 | | apple2gs_mouse_dy = seven_bit_diff(new_mouse_y, apple2gs_mouse_y); |
| 760 | | apple2gs_mouse_x = new_mouse_x; |
| 761 | | apple2gs_mouse_y = new_mouse_y; |
| 710 | state->mouse_dx = seven_bit_diff(new_mouse_x, state->mouse_x); |
| 711 | state->mouse_dy = seven_bit_diff(new_mouse_y, state->mouse_y); |
| 712 | state->mouse_x = new_mouse_x; |
| 713 | state->mouse_y = new_mouse_y; |
| 762 | 714 | |
| 763 | | adb_kmstatus |= 0x80; |
| 764 | | adb_kmstatus &= ~0x02; |
| 765 | | if (adb_kmstatus & 0x40) |
| 715 | state->adb_kmstatus |= 0x80; |
| 716 | state->adb_kmstatus &= ~0x02; |
| 717 | if (state->adb_kmstatus & 0x40) |
| 766 | 718 | apple2gs_add_irq(machine, IRQ_ADB_MOUSE); |
| 767 | 719 | } |
| 768 | 720 | } |
| r9648 | r9649 | |
| 772 | 724 | |
| 773 | 725 | static void apple2gs_set_scanint(running_machine *machine, UINT8 data) |
| 774 | 726 | { |
| 727 | apple2gs_state *state = machine->driver_data<apple2gs_state>(); |
| 775 | 728 | /* second interrupt */ |
| 776 | | if ((apple2gs_vgcint & 0x40) && !(data & 0x40)) |
| 729 | if ((state->vgcint & 0x40) && !(data & 0x40)) |
| 777 | 730 | { |
| 778 | 731 | apple2gs_remove_irq(machine, IRQ_VGC_SECOND); |
| 779 | | apple2gs_vgcint &= ~0xC0; |
| 732 | state->vgcint &= ~0xC0; |
| 780 | 733 | } |
| 781 | 734 | |
| 782 | 735 | /* scanline interrupt */ |
| 783 | | if ((apple2gs_vgcint & 0x20) && !(data & 0x20)) |
| 736 | if ((state->vgcint & 0x20) && !(data & 0x20)) |
| 784 | 737 | { |
| 785 | 738 | apple2gs_remove_irq(machine, IRQ_VGC_SCANLINE); |
| 786 | | apple2gs_vgcint &= ~0xA0; |
| 739 | state->vgcint &= ~0xA0; |
| 787 | 740 | } |
| 788 | 741 | |
| 789 | | if (apple2gs_pending_irqs & (IRQ_VGC_SECOND | IRQ_VGC_SCANLINE)) |
| 790 | | apple2gs_vgcint |= 0x80; |
| 742 | if (state->pending_irqs & (IRQ_VGC_SECOND | IRQ_VGC_SCANLINE)) |
| 743 | state->vgcint |= 0x80; |
| 791 | 744 | } |
| 792 | 745 | |
| 793 | 746 | |
| 794 | 747 | static TIMER_CALLBACK(apple2gs_scanline_tick) |
| 795 | 748 | { |
| 749 | apple2gs_state *state = machine->driver_data<apple2gs_state>(); |
| 796 | 750 | int scanline; |
| 797 | 751 | |
| 798 | 752 | scanline = machine->primary_screen->vpos(); |
| 799 | 753 | machine->primary_screen->update_partial(scanline); |
| 800 | 754 | |
| 801 | 755 | /* scanline interrupt */ |
| 802 | | if ((apple2gs_newvideo & 0x80) && (apple2gs_vgcint & 0x02) && (scanline >= (BORDER_TOP-1)) && (scanline < (200+BORDER_TOP-1))) |
| 756 | if ((state->newvideo & 0x80) && (state->vgcint & 0x02) && (scanline >= (BORDER_TOP-1)) && (scanline < (200+BORDER_TOP-1))) |
| 803 | 757 | { |
| 804 | 758 | UINT8 scb; |
| 805 | 759 | |
| 806 | | scb = apple2gs_slowmem[0x19D00 + scanline - BORDER_TOP + 1]; |
| 760 | scb = state->slowmem[0x19D00 + scanline - BORDER_TOP + 1]; |
| 807 | 761 | |
| 808 | 762 | if (scb & 0x40) |
| 809 | 763 | { |
| 810 | | apple2gs_vgcint |= 0xa0; |
| 764 | state->vgcint |= 0xa0; |
| 811 | 765 | apple2gs_add_irq(machine, IRQ_VGC_SCANLINE); |
| 812 | 766 | } |
| 813 | 767 | } |
| r9648 | r9649 | |
| 815 | 769 | if (scanline == (192+BORDER_TOP)) |
| 816 | 770 | { |
| 817 | 771 | /* VBL interrupt */ |
| 818 | | if ((apple2gs_inten & 0x08) && !(apple2gs_intflag & 0x08)) |
| 772 | if ((state->inten & 0x08) && !(state->intflag & 0x08)) |
| 819 | 773 | { |
| 820 | | apple2gs_intflag |= 0x08; |
| 774 | state->intflag |= 0x08; |
| 821 | 775 | apple2gs_add_irq(machine, IRQ_INTEN_VBL); |
| 822 | 776 | } |
| 823 | 777 | } |
| r9648 | r9649 | |
| 832 | 786 | apple2_interrupt(machine->device("maincpu")); |
| 833 | 787 | } |
| 834 | 788 | |
| 835 | | timer_adjust_oneshot(apple2gs_scanline_timer, machine->primary_screen->time_until_pos((scanline+1)%262, 0), 0); |
| 789 | timer_adjust_oneshot(state->scanline_timer, machine->primary_screen->time_until_pos((scanline+1)%262, 0), 0); |
| 836 | 790 | } |
| 837 | 791 | |
| 838 | 792 | |
| r9648 | r9649 | |
| 841 | 795 | * Sound handlers |
| 842 | 796 | * ----------------------------------------------------------------------- */ |
| 843 | 797 | |
| 844 | | static UINT8 sndglu_ctrl; |
| 845 | | static int sndglu_addr, sndglu_dummy_read; |
| 846 | 798 | |
| 847 | 799 | static READ8_HANDLER( gssnd_r ) |
| 848 | 800 | { |
| 801 | apple2gs_state *state = space->machine->driver_data<apple2gs_state>(); |
| 849 | 802 | UINT8 ret = 0; |
| 850 | 803 | |
| 851 | 804 | switch (offset) |
| 852 | 805 | { |
| 853 | 806 | case 0: // control |
| 854 | | ret = sndglu_ctrl; |
| 807 | ret = state->sndglu_ctrl; |
| 855 | 808 | break; |
| 856 | 809 | case 1: // data read |
| 857 | | ret = sndglu_dummy_read; |
| 810 | ret = state->sndglu_dummy_read; |
| 858 | 811 | |
| 859 | | if (sndglu_ctrl & 0x40) // docram access |
| 812 | if (state->sndglu_ctrl & 0x40) // docram access |
| 860 | 813 | { |
| 861 | | sndglu_dummy_read = apple2gs_docram[sndglu_addr]; |
| 814 | state->sndglu_dummy_read = state->docram[state->sndglu_addr]; |
| 862 | 815 | } |
| 863 | 816 | else |
| 864 | 817 | { |
| 865 | 818 | running_device *es5503 = space->machine->device("es5503"); |
| 866 | | sndglu_dummy_read = es5503_r(es5503, sndglu_addr); |
| 819 | state->sndglu_dummy_read = es5503_r(es5503, state->sndglu_addr); |
| 867 | 820 | } |
| 868 | 821 | |
| 869 | | if (sndglu_ctrl & 0x20) // auto-increment |
| 822 | if (state->sndglu_ctrl & 0x20) // auto-increment |
| 870 | 823 | { |
| 871 | | sndglu_addr++; |
| 824 | state->sndglu_addr++; |
| 872 | 825 | } |
| 873 | 826 | break; |
| 874 | 827 | case 2: // addr l |
| 875 | | ret = sndglu_addr & 0xff; |
| 828 | ret = state->sndglu_addr & 0xff; |
| 876 | 829 | break; |
| 877 | 830 | case 3: // addr h |
| 878 | | ret = (sndglu_addr >> 8) & 0xff; |
| 831 | ret = (state->sndglu_addr >> 8) & 0xff; |
| 879 | 832 | break; |
| 880 | 833 | } |
| 881 | 834 | |
| r9648 | r9649 | |
| 886 | 839 | |
| 887 | 840 | static WRITE8_HANDLER( gssnd_w ) |
| 888 | 841 | { |
| 842 | apple2gs_state *state = space->machine->driver_data<apple2gs_state>(); |
| 889 | 843 | switch (offset) |
| 890 | 844 | { |
| 891 | 845 | case 0: // control |
| 892 | | sndglu_ctrl = data & 0x7f; // make sure DOC is never busy |
| 893 | | if (!(sndglu_ctrl & 0x40)) // clear hi byte of address pointer on DOC access |
| 846 | state->sndglu_ctrl = data & 0x7f; // make sure DOC is never busy |
| 847 | if (!(state->sndglu_ctrl & 0x40)) // clear hi byte of address pointer on DOC access |
| 894 | 848 | { |
| 895 | | sndglu_addr &= 0xff; |
| 849 | state->sndglu_addr &= 0xff; |
| 896 | 850 | } |
| 897 | 851 | break; |
| 898 | 852 | case 1: // data write |
| 899 | | if (sndglu_ctrl & 0x40) // docram access |
| 853 | if (state->sndglu_ctrl & 0x40) // docram access |
| 900 | 854 | { |
| 901 | | apple2gs_docram[sndglu_addr] = data; |
| 855 | state->docram[state->sndglu_addr] = data; |
| 902 | 856 | } |
| 903 | 857 | else |
| 904 | 858 | { |
| 905 | 859 | running_device *es5503 = space->machine->device("es5503"); |
| 906 | | es5503_w(es5503, sndglu_addr, data); |
| 860 | es5503_w(es5503, state->sndglu_addr, data); |
| 907 | 861 | } |
| 908 | 862 | |
| 909 | | if (sndglu_ctrl & 0x20) // auto-increment |
| 863 | if (state->sndglu_ctrl & 0x20) // auto-increment |
| 910 | 864 | { |
| 911 | | sndglu_addr++; |
| 865 | state->sndglu_addr++; |
| 912 | 866 | } |
| 913 | 867 | break; |
| 914 | 868 | case 2: // addr l |
| 915 | | sndglu_addr &= 0xff00; |
| 916 | | sndglu_addr |= data; |
| 869 | state->sndglu_addr &= 0xff00; |
| 870 | state->sndglu_addr |= data; |
| 917 | 871 | break; |
| 918 | 872 | case 3: // addr h |
| 919 | | sndglu_addr &= 0x00ff; |
| 920 | | sndglu_addr |= data<<8; |
| 873 | state->sndglu_addr &= 0x00ff; |
| 874 | state->sndglu_addr |= data<<8; |
| 921 | 875 | break; |
| 922 | 876 | } |
| 923 | 877 | } |
| r9648 | r9649 | |
| 955 | 909 | |
| 956 | 910 | static READ8_HANDLER( apple2gs_c0xx_r ) |
| 957 | 911 | { |
| 912 | apple2gs_state *state = space->machine->driver_data<apple2gs_state>(); |
| 958 | 913 | UINT8 result; |
| 959 | 914 | running_device *scc; |
| 960 | 915 | |
| r9648 | r9649 | |
| 972 | 927 | break; |
| 973 | 928 | |
| 974 | 929 | case 0x23: /* C023 - VGCINT */ |
| 975 | | result = apple2gs_vgcint; |
| 930 | result = state->vgcint; |
| 976 | 931 | break; |
| 977 | 932 | |
| 978 | 933 | case 0x24: /* C024 - MOUSEDATA */ |
| r9648 | r9649 | |
| 984 | 939 | break; |
| 985 | 940 | |
| 986 | 941 | case 0x26: /* C026 - DATAREG */ |
| 987 | | result = adb_read_datareg(); |
| 942 | result = adb_read_datareg(state); |
| 988 | 943 | break; |
| 989 | 944 | |
| 990 | 945 | case 0x27: /* C027 - KMSTATUS */ |
| 991 | | result = adb_read_kmstatus(); |
| 946 | result = adb_read_kmstatus(state); |
| 992 | 947 | break; |
| 993 | 948 | |
| 994 | 949 | case 0x29: /* C029 - NEWVIDEO */ |
| 995 | | result = apple2gs_newvideo; |
| 950 | result = state->newvideo; |
| 996 | 951 | break; |
| 997 | 952 | |
| 998 | 953 | case 0x2B: /* C02B - LANGSEL */ |
| 999 | | result = apple2gs_langsel; |
| 954 | result = state->langsel; |
| 1000 | 955 | break; |
| 1001 | 956 | |
| 1002 | 957 | case 0x2D: /* C02D - SLTROMSEL */ |
| 1003 | | result = apple2gs_sltromsel; |
| 958 | result = state->sltromsel; |
| 1004 | 959 | break; |
| 1005 | 960 | |
| 1006 | 961 | case 0x2E: /* C02E - VERTCNT */ |
| r9648 | r9649 | |
| 1025 | 980 | break; |
| 1026 | 981 | |
| 1027 | 982 | case 0x33: /* C033 - CLOCKDATA */ |
| 1028 | | result = clock_data; |
| 983 | result = state->clock_data; |
| 1029 | 984 | break; |
| 1030 | 985 | |
| 1031 | 986 | case 0x34: /* C034 - CLOCKCTL */ |
| 1032 | | result = clock_control; |
| 987 | result = state->clock_control; |
| 1033 | 988 | break; |
| 1034 | 989 | |
| 1035 | 990 | case 0x35: /* C035 - SHADOW */ |
| 1036 | | result = apple2gs_shadow; |
| 991 | result = state->shadow; |
| 1037 | 992 | break; |
| 1038 | 993 | |
| 1039 | 994 | case 0x36: /* C036 - CYAREG */ |
| 1040 | | result = apple2gs_cyareg; |
| 995 | result = state->cyareg; |
| 1041 | 996 | break; |
| 1042 | 997 | |
| 1043 | 998 | case 0x38: /* C038 - SCCBREG */ |
| r9648 | r9649 | |
| 1056 | 1011 | break; |
| 1057 | 1012 | |
| 1058 | 1013 | case 0x41: /* C041 - INTEN */ |
| 1059 | | result = apple2gs_inten; |
| 1014 | result = state->inten; |
| 1060 | 1015 | break; |
| 1061 | 1016 | |
| 1062 | 1017 | case 0x46: /* C046 - INTFLAG */ |
| 1063 | | result = apple2gs_intflag; |
| 1018 | result = state->intflag; |
| 1064 | 1019 | break; |
| 1065 | 1020 | |
| 1066 | 1021 | case 0x68: /* C068 - STATEREG */ |
| r9648 | r9649 | |
| 1099 | 1054 | |
| 1100 | 1055 | static WRITE8_HANDLER( apple2gs_c0xx_w ) |
| 1101 | 1056 | { |
| 1057 | apple2gs_state *state = space->machine->driver_data<apple2gs_state>(); |
| 1102 | 1058 | running_device *scc; |
| 1103 | 1059 | |
| 1104 | 1060 | offset &= 0xFF; |
| r9648 | r9649 | |
| 1114 | 1070 | break; |
| 1115 | 1071 | |
| 1116 | 1072 | case 0x23: /* C023 - VGCINT */ |
| 1117 | | apple2gs_vgcint &= ~0x0F; |
| 1118 | | apple2gs_vgcint |= data & 0x0F; |
| 1073 | state->vgcint &= ~0x0F; |
| 1074 | state->vgcint |= data & 0x0F; |
| 1119 | 1075 | break; |
| 1120 | 1076 | |
| 1121 | 1077 | case 0x24: /* C024 - MOUSEDATA */ |
| r9648 | r9649 | |
| 1132 | 1088 | break; |
| 1133 | 1089 | |
| 1134 | 1090 | case 0x27: /* C027 - KMSTATUS */ |
| 1135 | | adb_write_kmstatus(data); |
| 1091 | adb_write_kmstatus(state, data); |
| 1136 | 1092 | break; |
| 1137 | 1093 | |
| 1138 | 1094 | case 0x29: /* C029 - NEWVIDEO */ |
| 1139 | | apple2gs_newvideo = data; |
| 1095 | state->newvideo = data; |
| 1140 | 1096 | break; |
| 1141 | 1097 | |
| 1142 | 1098 | case 0x2B: /* C02B - LANGSEL */ |
| 1143 | | apple2gs_langsel = data; |
| 1099 | state->langsel = data; |
| 1144 | 1100 | break; |
| 1145 | 1101 | |
| 1146 | 1102 | case 0x2D: /* C02D - SLTROMSEL */ |
| 1147 | | apple2gs_sltromsel = data; |
| 1103 | state->sltromsel = data; |
| 1148 | 1104 | apple2_update_memory(space->machine); |
| 1149 | 1105 | break; |
| 1150 | 1106 | |
| r9648 | r9649 | |
| 1157 | 1113 | break; |
| 1158 | 1114 | |
| 1159 | 1115 | case 0x33: /* C033 - CLOCKDATA */ |
| 1160 | | clock_data = data; |
| 1116 | state->clock_data = data; |
| 1161 | 1117 | break; |
| 1162 | 1118 | |
| 1163 | 1119 | case 0x34: /* C034 - CLOCKCTL */ |
| 1164 | | clock_control = data & 0x7F; |
| 1165 | | apple2gs_bordercolor = data & 0x0F; |
| 1120 | state->clock_control = data & 0x7F; |
| 1121 | state->bordercolor = data & 0x0F; |
| 1166 | 1122 | if (data & 0x80) |
| 1167 | 1123 | process_clock(space->machine); |
| 1168 | 1124 | break; |
| 1169 | 1125 | |
| 1170 | 1126 | case 0x35: /* C035 - SHADOW */ |
| 1171 | | if (apple2gs_shadow != data) |
| 1127 | if (state->shadow != data) |
| 1172 | 1128 | { |
| 1173 | | apple2gs_shadow = data; |
| 1129 | state->shadow = data; |
| 1174 | 1130 | apple2_update_memory(space->machine); |
| 1175 | 1131 | } |
| 1176 | 1132 | break; |
| 1177 | 1133 | |
| 1178 | 1134 | case 0x36: /* C036 - CYAREG */ |
| 1179 | | apple2gs_cyareg = data & ~0x20; |
| 1135 | state->cyareg = data & ~0x20; |
| 1180 | 1136 | cputag_set_clock(space->machine, "maincpu", (data & 0x80) ? APPLE2GS_14M/5 : APPLE2GS_7M/7); |
| 1181 | 1137 | break; |
| 1182 | 1138 | |
| r9648 | r9649 | |
| 1196 | 1152 | break; |
| 1197 | 1153 | |
| 1198 | 1154 | case 0x41: /* C041 - INTEN */ |
| 1199 | | apple2gs_inten = data & 0x1F; |
| 1200 | | if ((apple2gs_inten & 0x10) == 0x00) |
| 1155 | state->inten = data & 0x1F; |
| 1156 | if ((state->inten & 0x10) == 0x00) |
| 1201 | 1157 | apple2gs_remove_irq(space->machine, IRQ_INTEN_QSECOND); |
| 1202 | | if ((apple2gs_inten & 0x08) == 0x00) |
| 1158 | if ((state->inten & 0x08) == 0x00) |
| 1203 | 1159 | apple2gs_remove_irq(space->machine, IRQ_INTEN_VBL); |
| 1204 | 1160 | break; |
| 1205 | 1161 | |
| 1206 | 1162 | case 0x47: /* C047 - CLRVBLINT */ |
| 1207 | | apple2gs_intflag &= ~0x18; |
| 1163 | state->intflag &= ~0x18; |
| 1208 | 1164 | apple2gs_remove_irq(space->machine, IRQ_INTEN_QSECOND); |
| 1209 | 1165 | apple2gs_remove_irq(space->machine, IRQ_INTEN_VBL); |
| 1210 | 1166 | break; |
| r9648 | r9649 | |
| 1235 | 1191 | |
| 1236 | 1192 | static WRITE8_HANDLER( apple2gs_main0400_w ) |
| 1237 | 1193 | { |
| 1194 | apple2gs_state *state = space->machine->driver_data<apple2gs_state>(); |
| 1238 | 1195 | offset += 0x000400; |
| 1239 | 1196 | messram_get_ptr(space->machine->device("messram"))[offset] = data; |
| 1240 | 1197 | |
| 1241 | | if (!(apple2gs_shadow & 0x01)) |
| 1198 | if (!(state->shadow & 0x01)) |
| 1242 | 1199 | { |
| 1243 | | apple2gs_slowmem[offset] = data; |
| 1200 | state->slowmem[offset] = data; |
| 1244 | 1201 | } |
| 1245 | 1202 | } |
| 1246 | 1203 | |
| 1247 | 1204 | static WRITE8_HANDLER( apple2gs_aux0400_w ) |
| 1248 | 1205 | { |
| 1206 | apple2gs_state *state = space->machine->driver_data<apple2gs_state>(); |
| 1249 | 1207 | offset += 0x010400; |
| 1250 | 1208 | messram_get_ptr(space->machine->device("messram"))[offset] = data; |
| 1251 | 1209 | |
| 1252 | | if (!(apple2gs_shadow & 0x01)) |
| 1210 | if (!(state->shadow & 0x01)) |
| 1253 | 1211 | { |
| 1254 | | apple2gs_slowmem[offset] = data; |
| 1212 | state->slowmem[offset] = data; |
| 1255 | 1213 | } |
| 1256 | 1214 | } |
| 1257 | 1215 | |
| 1258 | 1216 | static WRITE8_HANDLER( apple2gs_main2000_w ) |
| 1259 | 1217 | { |
| 1218 | apple2gs_state *state = space->machine->driver_data<apple2gs_state>(); |
| 1260 | 1219 | offset += 0x002000; |
| 1261 | 1220 | messram_get_ptr(space->machine->device("messram"))[offset] = data; |
| 1262 | 1221 | |
| 1263 | | if (!(apple2gs_shadow & 0x02)) |
| 1222 | if (!(state->shadow & 0x02)) |
| 1264 | 1223 | { |
| 1265 | | apple2gs_slowmem[offset] = data; |
| 1224 | state->slowmem[offset] = data; |
| 1266 | 1225 | } |
| 1267 | 1226 | } |
| 1268 | 1227 | |
| 1269 | 1228 | static WRITE8_HANDLER( apple2gs_aux2000_w ) |
| 1270 | 1229 | { |
| 1230 | apple2gs_state *state = space->machine->driver_data<apple2gs_state>(); |
| 1271 | 1231 | offset += 0x012000; |
| 1272 | 1232 | messram_get_ptr(space->machine->device("messram"))[offset] = data; |
| 1273 | 1233 | |
| 1274 | | if (!(apple2gs_shadow & 0x12) || !(apple2gs_shadow & 0x08)) |
| 1234 | if (!(state->shadow & 0x12) || !(state->shadow & 0x08)) |
| 1275 | 1235 | { |
| 1276 | | apple2gs_slowmem[offset] = data; |
| 1236 | state->slowmem[offset] = data; |
| 1277 | 1237 | } |
| 1278 | 1238 | } |
| 1279 | 1239 | |
| 1280 | 1240 | static WRITE8_HANDLER( apple2gs_main4000_w ) |
| 1281 | 1241 | { |
| 1242 | apple2gs_state *state = space->machine->driver_data<apple2gs_state>(); |
| 1282 | 1243 | offset += 0x004000; |
| 1283 | 1244 | messram_get_ptr(space->machine->device("messram"))[offset] = data; |
| 1284 | 1245 | |
| 1285 | 1246 | if ((offset >= 0x004000) && (offset <= 0x005FFF)) |
| 1286 | 1247 | { |
| 1287 | | if (!(apple2gs_shadow & 0x04)) |
| 1288 | | apple2gs_slowmem[offset] = data; |
| 1248 | if (!(state->shadow & 0x04)) |
| 1249 | state->slowmem[offset] = data; |
| 1289 | 1250 | } |
| 1290 | 1251 | } |
| 1291 | 1252 | |
| 1292 | 1253 | static WRITE8_HANDLER( apple2gs_aux4000_w ) |
| 1293 | 1254 | { |
| 1255 | apple2gs_state *state = space->machine->driver_data<apple2gs_state>(); |
| 1294 | 1256 | offset += 0x014000; |
| 1295 | 1257 | messram_get_ptr(space->machine->device("messram"))[offset] = data; |
| 1296 | 1258 | |
| 1297 | 1259 | if ((offset >= 0x014000) && (offset <= 0x015FFF)) |
| 1298 | 1260 | { |
| 1299 | | if (!(apple2gs_shadow & 0x14) || !(apple2gs_shadow & 0x08)) |
| 1300 | | apple2gs_slowmem[offset] = data; |
| 1261 | if (!(state->shadow & 0x14) || !(state->shadow & 0x08)) |
| 1262 | state->slowmem[offset] = data; |
| 1301 | 1263 | } |
| 1302 | 1264 | else if ((offset >= 0x016000) && (offset <= 0x019FFF)) |
| 1303 | 1265 | { |
| 1304 | | if (!(apple2gs_shadow & 0x08)) |
| 1266 | if (!(state->shadow & 0x08)) |
| 1305 | 1267 | { |
| 1306 | | apple2gs_slowmem[offset] = data; |
| 1268 | state->slowmem[offset] = data; |
| 1307 | 1269 | |
| 1308 | 1270 | if (offset >= 0x19e00) |
| 1309 | 1271 | { |
| 1310 | 1272 | int color = (offset - 0x19e00) >> 1; |
| 1311 | 1273 | |
| 1312 | 1274 | palette_set_color_rgb(space->machine, color + 16, |
| 1313 | | ((apple2gs_slowmem[0x19E00 + (color * 2) + 1] >> 0) & 0x0F) * 17, |
| 1314 | | ((apple2gs_slowmem[0x19E00 + (color * 2) + 0] >> 4) & 0x0F) * 17, |
| 1315 | | ((apple2gs_slowmem[0x19E00 + (color * 2) + 0] >> 0) & 0x0F) * 17); |
| 1275 | ((state->slowmem[0x19E00 + (color * 2) + 1] >> 0) & 0x0F) * 17, |
| 1276 | ((state->slowmem[0x19E00 + (color * 2) + 0] >> 4) & 0x0F) * 17, |
| 1277 | ((state->slowmem[0x19E00 + (color * 2) + 0] >> 0) & 0x0F) * 17); |
| 1316 | 1278 | } |
| 1317 | 1279 | } |
| 1318 | 1280 | } |
| r9648 | r9649 | |
| 1418 | 1380 | |
| 1419 | 1381 | static void apple2gs_mem_00D000(running_machine *machine,offs_t begin, offs_t end, apple2_meminfo *meminfo) |
| 1420 | 1382 | { |
| 1421 | | if (apple2gs_shadow & 0x40) |
| 1383 | apple2gs_state *state = machine->driver_data<apple2gs_state>(); |
| 1384 | if (state->shadow & 0x40) |
| 1422 | 1385 | { |
| 1423 | 1386 | meminfo->read_mem = (apple2_flags & VAR_RAMRD) ? 0x01D000 : 0x00D000; |
| 1424 | 1387 | meminfo->write_mem = (apple2_flags & VAR_RAMWRT) ? 0x01D000 : 0x00D000; |
| r9648 | r9649 | |
| 1431 | 1394 | |
| 1432 | 1395 | static void apple2gs_mem_00E000(running_machine *machine,offs_t begin, offs_t end, apple2_meminfo *meminfo) |
| 1433 | 1396 | { |
| 1434 | | if (apple2gs_shadow & 0x40) |
| 1397 | apple2gs_state *state = machine->driver_data<apple2gs_state>(); |
| 1398 | if (state->shadow & 0x40) |
| 1435 | 1399 | { |
| 1436 | 1400 | meminfo->read_mem = (apple2_flags & VAR_RAMRD) ? 0x01E000 : 0x00E000; |
| 1437 | 1401 | meminfo->write_mem = (apple2_flags & VAR_RAMWRT) ? 0x01E000 : 0x00E000; |
| r9648 | r9649 | |
| 1444 | 1408 | |
| 1445 | 1409 | static void apple2gs_mem_01D000(running_machine *machine,offs_t begin, offs_t end, apple2_meminfo *meminfo) |
| 1446 | 1410 | { |
| 1447 | | if (apple2gs_shadow & 0x40) |
| 1411 | apple2gs_state *state = machine->driver_data<apple2gs_state>(); |
| 1412 | if (state->shadow & 0x40) |
| 1448 | 1413 | { |
| 1449 | 1414 | meminfo->read_mem = 0x01D000; |
| 1450 | 1415 | meminfo->write_mem = 0x01D000; |
| r9648 | r9649 | |
| 1457 | 1422 | |
| 1458 | 1423 | static void apple2gs_mem_01E000(running_machine *machine,offs_t begin, offs_t end, apple2_meminfo *meminfo) |
| 1459 | 1424 | { |
| 1460 | | if (apple2gs_shadow & 0x40) |
| 1425 | apple2gs_state *state = machine->driver_data<apple2gs_state>(); |
| 1426 | if (state->shadow & 0x40) |
| 1461 | 1427 | { |
| 1462 | 1428 | meminfo->read_mem = 0x01E000; |
| 1463 | 1429 | meminfo->write_mem = 0x01E000; |
| r9648 | r9649 | |
| 1530 | 1496 | |
| 1531 | 1497 | static UINT8 apple2gs_xxCxxx_r(running_machine *machine, offs_t address) |
| 1532 | 1498 | { |
| 1499 | apple2gs_state *state = machine->driver_data<apple2gs_state>(); |
| 1533 | 1500 | UINT8 result; |
| 1534 | 1501 | int slot; |
| 1535 | 1502 | |
| 1536 | | if ((apple2gs_shadow & 0x40) && ((address & 0xF00000) == 0x000000)) |
| 1503 | if ((state->shadow & 0x40) && ((address & 0xF00000) == 0x000000)) |
| 1537 | 1504 | { |
| 1538 | 1505 | result = messram_get_ptr(machine->device("messram"))[address]; |
| 1539 | 1506 | } |
| r9648 | r9649 | |
| 1545 | 1512 | { |
| 1546 | 1513 | slot = (address & 0x000F00) / 0x100; |
| 1547 | 1514 | |
| 1548 | | if ((slot > 7) || ((apple2gs_sltromsel & (1 << slot)) == 0)) |
| 1515 | if ((slot > 7) || ((state->sltromsel & (1 << slot)) == 0)) |
| 1549 | 1516 | result = *apple2gs_getslotmem(machine, address); |
| 1550 | 1517 | else |
| 1551 | 1518 | result = apple2_getfloatingbusvalue(machine); |
| r9648 | r9649 | |
| 1557 | 1524 | |
| 1558 | 1525 | static void apple2gs_xxCxxx_w(running_machine *machine, offs_t address, UINT8 data) |
| 1559 | 1526 | { |
| 1527 | apple2gs_state *state = machine->driver_data<apple2gs_state>(); |
| 1560 | 1528 | int slot; |
| 1561 | 1529 | |
| 1562 | | if ((apple2gs_shadow & 0x40) && ((address & 0xF00000) == 0x000000)) |
| 1530 | if ((state->shadow & 0x40) && ((address & 0xF00000) == 0x000000)) |
| 1563 | 1531 | { |
| 1564 | 1532 | messram_get_ptr(machine->device("messram"))[address] = data; |
| 1565 | 1533 | } |
| r9648 | r9649 | |
| 1571 | 1539 | { |
| 1572 | 1540 | slot = (address & 0x000F00) / 0x100; |
| 1573 | 1541 | |
| 1574 | | if ((slot > 7) || ((apple2gs_sltromsel & (1 << slot)) == 0)) |
| 1542 | if ((slot > 7) || ((state->sltromsel & (1 << slot)) == 0)) |
| 1575 | 1543 | *apple2gs_getslotmem(machine, address) = data; |
| 1576 | 1544 | } |
| 1577 | 1545 | } |
| r9648 | r9649 | |
| 1580 | 1548 | |
| 1581 | 1549 | DIRECT_UPDATE_HANDLER( apple2gs_opbase ) |
| 1582 | 1550 | { |
| 1551 | apple2gs_state *state = machine->driver_data<apple2gs_state>(); |
| 1583 | 1552 | UINT8 *opptr = NULL; |
| 1584 | 1553 | int slot; |
| 1585 | 1554 | |
| 1586 | 1555 | if (((address & 0xFEF000) == 0x00C000) || ((address & 0xFEF000) == 0xE0C000)) |
| 1587 | 1556 | { |
| 1588 | | if ((apple2gs_shadow & 0x40) && ((address & 0xF00000) == 0x000000)) |
| 1557 | if ((state->shadow & 0x40) && ((address & 0xF00000) == 0x000000)) |
| 1589 | 1558 | { |
| 1590 | 1559 | opptr = &messram_get_ptr(machine->device("messram"))[address]; |
| 1591 | 1560 | } |
| r9648 | r9649 | |
| 1598 | 1567 | { |
| 1599 | 1568 | slot = (address & 0x000F00) / 0x100; |
| 1600 | 1569 | |
| 1601 | | if ((slot > 7) || ((apple2gs_sltromsel & (1 << slot)) == 0)) |
| 1570 | if ((slot > 7) || ((state->sltromsel & (1 << slot)) == 0)) |
| 1602 | 1571 | opptr = apple2gs_getslotmem(machine, address); |
| 1603 | 1572 | } |
| 1604 | 1573 | |
| r9648 | r9649 | |
| 1626 | 1595 | |
| 1627 | 1596 | static WRITE8_HANDLER( apple2gs_Exxxxx_w ) |
| 1628 | 1597 | { |
| 1629 | | apple2gs_slowmem[offset] = data; |
| 1598 | apple2gs_state *state = space->machine->driver_data<apple2gs_state>(); |
| 1599 | state->slowmem[offset] = data; |
| 1630 | 1600 | } |
| 1631 | 1601 | |
| 1632 | 1602 | static WRITE8_HANDLER( apple2gs_E004xx_w ) { apple2gs_Exxxxx_w(space, offset + 0x00400, data); } |
| r9648 | r9649 | |
| 1636 | 1606 | |
| 1637 | 1607 | static WRITE8_HANDLER( apple2gs_slowmem_w ) |
| 1638 | 1608 | { |
| 1639 | | apple2gs_slowmem[offset] = data; |
| 1609 | apple2gs_state *state = space->machine->driver_data<apple2gs_state>(); |
| 1610 | state->slowmem[offset] = data; |
| 1640 | 1611 | |
| 1641 | 1612 | if ((offset >= 0x19e00) && (offset < 0x19fff)) |
| 1642 | 1613 | { |
| 1643 | 1614 | int color = (offset - 0x19e00) >> 1; |
| 1644 | 1615 | |
| 1645 | 1616 | palette_set_color_rgb(space->machine, color + 16, |
| 1646 | | ((apple2gs_slowmem[0x19E00 + (color * 2) + 1] >> 0) & 0x0F) * 17, |
| 1647 | | ((apple2gs_slowmem[0x19E00 + (color * 2) + 0] >> 4) & 0x0F) * 17, |
| 1648 | | ((apple2gs_slowmem[0x19E00 + (color * 2) + 0] >> 0) & 0x0F) * 17); |
| 1617 | ((state->slowmem[0x19E00 + (color * 2) + 1] >> 0) & 0x0F) * 17, |
| 1618 | ((state->slowmem[0x19E00 + (color * 2) + 0] >> 4) & 0x0F) * 17, |
| 1619 | ((state->slowmem[0x19E00 + (color * 2) + 0] >> 0) & 0x0F) * 17); |
| 1649 | 1620 | } |
| 1650 | 1621 | } |
| 1651 | 1622 | |
| 1652 | 1623 | |
| 1653 | 1624 | static void apple2gs_setup_memory(running_machine *machine) |
| 1654 | 1625 | { |
| 1626 | apple2gs_state *state = machine->driver_data<apple2gs_state>(); |
| 1655 | 1627 | address_space* space = cputag_get_address_space(machine, "maincpu",ADDRESS_SPACE_PROGRAM); |
| 1656 | 1628 | offs_t begin, end; |
| 1657 | 1629 | apple2_memmap_config cfg; |
| 1658 | 1630 | |
| 1659 | 1631 | /* allocate memory for E00000-E1FFFF */ |
| 1660 | | apple2gs_slowmem = auto_alloc_array_clear(machine, UINT8, 128*1024); |
| 1632 | state->slowmem = auto_alloc_array_clear(machine, UINT8, 128*1024); |
| 1661 | 1633 | |
| 1662 | | state_save_register_item_array(machine, "APPLE2GS_SLOWMEM", NULL, 0, apple2gs_slowmem); |
| 1634 | state_save_register_item_array(machine, "APPLE2GS_SLOWMEM", NULL, 0, state->slowmem); |
| 1663 | 1635 | |
| 1664 | 1636 | /* install expanded memory */ |
| 1665 | 1637 | memory_install_readwrite_bank(space, 0x010000, messram_get_size(machine->device("messram")) - 1, 0, 0, "bank1"); |
| r9648 | r9649 | |
| 1672 | 1644 | memory_install_write8_handler(space, 0xe02000, 0xe03fff, 0, 0, apple2gs_E02xxx_w); |
| 1673 | 1645 | memory_install_write8_handler(space, 0xe10400, 0xe107ff, 0, 0, apple2gs_E104xx_w); |
| 1674 | 1646 | memory_install_write8_handler(space, 0xe12000, 0xe13fff, 0, 0, apple2gs_E12xxx_w); |
| 1675 | | memory_set_bankptr(machine,"bank2", apple2gs_slowmem); |
| 1647 | memory_set_bankptr(machine,"bank2", state->slowmem); |
| 1676 | 1648 | |
| 1677 | 1649 | /* install alternate ROM bank */ |
| 1678 | 1650 | begin = 0x1000000 - memory_region_length(machine, "maincpu"); |
| r9648 | r9649 | |
| 1701 | 1673 | memset(&cfg, 0, sizeof(cfg)); |
| 1702 | 1674 | cfg.first_bank = 4; |
| 1703 | 1675 | cfg.memmap = apple2gs_memmap_entries; |
| 1704 | | cfg.auxmem = apple2gs_slowmem; |
| 1676 | cfg.auxmem = state->slowmem; |
| 1705 | 1677 | cfg.auxmem_length = 0x20000; |
| 1706 | 1678 | apple2_setup_memory(machine, &cfg); |
| 1707 | 1679 | } |
| r9648 | r9649 | |
| 1725 | 1697 | |
| 1726 | 1698 | MACHINE_START( apple2gs ) |
| 1727 | 1699 | { |
| 1700 | apple2gs_state *state = machine->driver_data<apple2gs_state>(); |
| 1728 | 1701 | apple2_init_common(machine); |
| 1729 | 1702 | |
| 1730 | 1703 | /* set up Apple IIgs vectoring */ |
| 1731 | 1704 | g65816_set_read_vector_callback(machine->device("maincpu"), apple2gs_read_vector); |
| 1732 | 1705 | |
| 1733 | 1706 | /* setup globals */ |
| 1734 | | apple2gs_cur_slot6_image = NULL; |
| 1735 | | apple2gs_newvideo = 0x00; |
| 1736 | | apple2gs_vgcint = 0x00; |
| 1737 | | apple2gs_langsel = 0x00; |
| 1738 | | apple2gs_sltromsel = 0x00; |
| 1739 | | apple2gs_cyareg = 0x80; |
| 1740 | | apple2gs_inten = 0x00; |
| 1741 | | apple2gs_intflag = 0x00; |
| 1742 | | apple2gs_shadow = 0x00; |
| 1743 | | apple2gs_pending_irqs = 0x00; |
| 1744 | | apple2gs_mouse_x = 0x00; |
| 1745 | | apple2gs_mouse_y = 0x00; |
| 1746 | | apple2gs_mouse_dx = 0x00; |
| 1747 | | apple2gs_mouse_dy = 0x00; |
| 1748 | | adb_state = ADBSTATE_IDLE; |
| 1749 | | adb_kmstatus = 0x00; |
| 1750 | | adb_command = 0; |
| 1751 | | adb_mode = 0; |
| 1752 | | adb_latent_result = 0; |
| 1753 | | adb_command_length = 0; |
| 1754 | | adb_command_pos = 0; |
| 1755 | | memset(adb_command_bytes, 0, sizeof(adb_command_bytes)); |
| 1756 | | memset(adb_response_bytes, 0, sizeof(adb_response_bytes)); |
| 1757 | | adb_response_length = 0; |
| 1758 | | adb_response_pos = 0; |
| 1759 | | memset(adb_memory, 0, sizeof(adb_memory)); |
| 1760 | | adb_address_keyboard = 2; |
| 1761 | | adb_address_mouse = 3; |
| 1707 | state->cur_slot6_image = NULL; |
| 1708 | state->newvideo = 0x00; |
| 1709 | state->vgcint = 0x00; |
| 1710 | state->langsel = 0x00; |
| 1711 | state->sltromsel = 0x00; |
| 1712 | state->cyareg = 0x80; |
| 1713 | state->inten = 0x00; |
| 1714 | state->intflag = 0x00; |
| 1715 | state->shadow = 0x00; |
| 1716 | state->pending_irqs = 0x00; |
| 1717 | state->mouse_x = 0x00; |
| 1718 | state->mouse_y = 0x00; |
| 1719 | state->mouse_dx = 0x00; |
| 1720 | state->mouse_dy = 0x00; |
| 1721 | state->adb_state = ADBSTATE_IDLE; |
| 1722 | state->adb_kmstatus = 0x00; |
| 1723 | state->adb_command = 0; |
| 1724 | state->adb_mode = 0; |
| 1725 | state->adb_latent_result = 0; |
| 1726 | state->adb_command_length = 0; |
| 1727 | state->adb_command_pos = 0; |
| 1728 | memset(state->adb_command_bytes, 0, sizeof(state->adb_command_bytes)); |
| 1729 | memset(state->adb_response_bytes, 0, sizeof(state->adb_response_bytes)); |
| 1730 | state->adb_response_length = 0; |
| 1731 | state->adb_response_pos = 0; |
| 1732 | memset(state->adb_memory, 0, sizeof(state->adb_memory)); |
| 1733 | state->adb_address_keyboard = 2; |
| 1734 | state->adb_address_mouse = 3; |
| 1762 | 1735 | |
| 1763 | 1736 | /* init time */ |
| 1764 | | clock_data = 0; |
| 1765 | | clock_control =0; |
| 1766 | | clock_read = 0; |
| 1767 | | clock_reg1 = 0; |
| 1768 | | clock_mode = CLOCKMODE_IDLE; |
| 1769 | | clock_curtime = 0; |
| 1770 | | clock_curtime_interval = 0; |
| 1737 | state->clock_data = 0; |
| 1738 | state->clock_control =0; |
| 1739 | state->clock_read = 0; |
| 1740 | state->clock_reg1 = 0; |
| 1741 | state->clock_mode = CLOCKMODE_IDLE; |
| 1742 | state->clock_curtime = 0; |
| 1743 | state->clock_curtime_interval = 0; |
| 1771 | 1744 | |
| 1772 | | sndglu_ctrl = 0x00; |
| 1773 | | sndglu_addr = 0; |
| 1774 | | sndglu_dummy_read = 0; |
| 1745 | state->sndglu_ctrl = 0x00; |
| 1746 | state->sndglu_addr = 0; |
| 1747 | state->sndglu_dummy_read = 0; |
| 1775 | 1748 | |
| 1776 | 1749 | /* init the various subsystems */ |
| 1777 | 1750 | apple2gs_setup_memory(machine); |
| r9648 | r9649 | |
| 1779 | 1752 | /* save state stuff. note that the driver takes care of docram. */ |
| 1780 | 1753 | state_save_register_global_array(machine, messram_get_ptr(machine->device("messram"))); |
| 1781 | 1754 | |
| 1782 | | state_save_register_item(machine, "NEWVIDEO", NULL, 0, apple2gs_newvideo); |
| 1755 | state_save_register_item(machine, "NEWVIDEO", NULL, 0, state->newvideo); |
| 1783 | 1756 | |
| 1784 | | state_save_register_item(machine, "VGCINT", NULL,0, apple2gs_vgcint); |
| 1785 | | state_save_register_item(machine, "LANGSEL", NULL,0, apple2gs_langsel); |
| 1786 | | state_save_register_item(machine, "SLTROMSEL", NULL,0, apple2gs_sltromsel); |
| 1787 | | state_save_register_item(machine, "CYAREG", NULL,0, apple2gs_cyareg); |
| 1788 | | state_save_register_item(machine, "INTEN", NULL,0, apple2gs_inten); |
| 1789 | | state_save_register_item(machine, "INTFLAG", NULL,0, apple2gs_intflag); |
| 1790 | | state_save_register_item(machine, "SHADOW", NULL,0, apple2gs_shadow); |
| 1791 | | state_save_register_item(machine, "PENDIRQ", NULL,0, apple2gs_pending_irqs); |
| 1792 | | state_save_register_item(machine, "MX", NULL,0, apple2gs_mouse_x); |
| 1793 | | state_save_register_item(machine, "MY", NULL,0, apple2gs_mouse_y); |
| 1794 | | state_save_register_item(machine, "MDX", NULL,0, apple2gs_mouse_dx); |
| 1795 | | state_save_register_item(machine, "MDY", NULL,0, apple2gs_mouse_dy); |
| 1757 | state_save_register_item(machine, "VGCINT", NULL,0, state->vgcint); |
| 1758 | state_save_register_item(machine, "LANGSEL", NULL,0, state->langsel); |
| 1759 | state_save_register_item(machine, "SLTROMSEL", NULL,0, state->sltromsel); |
| 1760 | state_save_register_item(machine, "CYAREG", NULL,0, state->cyareg); |
| 1761 | state_save_register_item(machine, "INTEN", NULL,0, state->inten); |
| 1762 | state_save_register_item(machine, "INTFLAG", NULL,0, state->intflag); |
| 1763 | state_save_register_item(machine, "SHADOW", NULL,0, state->shadow); |
| 1764 | state_save_register_item(machine, "PENDIRQ", NULL,0, state->pending_irqs); |
| 1765 | state_save_register_item(machine, "MX", NULL,0, state->mouse_x); |
| 1766 | state_save_register_item(machine, "MY", NULL,0, state->mouse_y); |
| 1767 | state_save_register_item(machine, "MDX", NULL,0, state->mouse_dx); |
| 1768 | state_save_register_item(machine, "MDY", NULL,0, state->mouse_dy); |
| 1796 | 1769 | |
| 1797 | | state_save_register_item(machine, "CLKDATA", NULL,0, clock_data); |
| 1798 | | state_save_register_item(machine, "CLKCTRL", NULL,0, clock_control); |
| 1799 | | state_save_register_item(machine, "CLKRD", NULL,0, clock_read); |
| 1800 | | state_save_register_item(machine, "CLKREG1", NULL,0, clock_reg1); |
| 1801 | | state_save_register_item(machine, "CLKCURTIME", NULL,0, clock_curtime); |
| 1802 | | state_save_register_item(machine, "CLKCURTIMEINT", NULL,0, clock_curtime_interval); |
| 1803 | | state_save_register_item(machine, "CLKMODE", NULL,0, clock_mode); |
| 1804 | | state_save_register_global_array(machine, clock_bram); |
| 1770 | state_save_register_item(machine, "CLKDATA", NULL,0, state->clock_data); |
| 1771 | state_save_register_item(machine, "CLKCTRL", NULL,0, state->clock_control); |
| 1772 | state_save_register_item(machine, "CLKRD", NULL,0, state->clock_read); |
| 1773 | state_save_register_item(machine, "CLKREG1", NULL,0, state->clock_reg1); |
| 1774 | state_save_register_item(machine, "CLKCURTIME", NULL,0, state->clock_curtime); |
| 1775 | state_save_register_item(machine, "CLKCURTIMEINT", NULL,0, state->clock_curtime_interval); |
| 1776 | state_save_register_item(machine, "CLKMODE", NULL,0, state->clock_mode); |
| 1777 | state_save_register_global_array(machine, state->clock_bram); |
| 1805 | 1778 | |
| 1806 | | state_save_register_global_array(machine, adb_memory); |
| 1807 | | state_save_register_global_array(machine, adb_command_bytes); |
| 1808 | | state_save_register_global_array(machine, adb_response_bytes); |
| 1809 | | state_save_register_item(machine, "ADB", NULL,0, adb_state); |
| 1810 | | state_save_register_item(machine, "ADB", NULL,0, adb_command); |
| 1811 | | state_save_register_item(machine, "ADB", NULL,0, adb_mode); |
| 1812 | | state_save_register_item(machine, "ADB", NULL,0, adb_kmstatus); |
| 1813 | | state_save_register_item(machine, "ADB", NULL,0, adb_latent_result); |
| 1814 | | state_save_register_item(machine, "ADB", NULL,0, adb_command_length); |
| 1815 | | state_save_register_item(machine, "ADB", NULL,0, adb_command_pos); |
| 1816 | | state_save_register_item(machine, "ADB", NULL,0, adb_response_length); |
| 1817 | | state_save_register_item(machine, "ADB", NULL,0, adb_response_pos); |
| 1818 | | state_save_register_item(machine, "ADB", NULL,0, adb_address_keyboard); |
| 1819 | | state_save_register_item(machine, "ADB", NULL,0, adb_address_mouse); |
| 1779 | state_save_register_global_array(machine, state->adb_memory); |
| 1780 | state_save_register_global_array(machine, state->adb_command_bytes); |
| 1781 | state_save_register_global_array(machine, state->adb_response_bytes); |
| 1782 | state_save_register_item(machine, "ADB", NULL,0, state->adb_state); |
| 1783 | state_save_register_item(machine, "ADB", NULL,0, state->adb_command); |
| 1784 | state_save_register_item(machine, "ADB", NULL,0, state->adb_mode); |
| 1785 | state_save_register_item(machine, "ADB", NULL,0, state->adb_kmstatus); |
| 1786 | state_save_register_item(machine, "ADB", NULL,0, state->adb_latent_result); |
| 1787 | state_save_register_item(machine, "ADB", NULL,0, state->adb_command_length); |
| 1788 | state_save_register_item(machine, "ADB", NULL,0, state->adb_command_pos); |
| 1789 | state_save_register_item(machine, "ADB", NULL,0, state->adb_response_length); |
| 1790 | state_save_register_item(machine, "ADB", NULL,0, state->adb_response_pos); |
| 1791 | state_save_register_item(machine, "ADB", NULL,0, state->adb_address_keyboard); |
| 1792 | state_save_register_item(machine, "ADB", NULL,0, state->adb_address_mouse); |
| 1820 | 1793 | |
| 1821 | | state_save_register_item(machine, "SNDGLUCTRL", NULL,0, sndglu_ctrl); |
| 1822 | | state_save_register_item(machine, "SNDGLUADDR", NULL,0, sndglu_addr); |
| 1823 | | state_save_register_item(machine, "SNDGLUDUMMYRD", NULL,0, sndglu_dummy_read); |
| 1794 | state_save_register_item(machine, "SNDGLUCTRL", NULL,0, state->sndglu_ctrl); |
| 1795 | state_save_register_item(machine, "SNDGLUADDR", NULL,0, state->sndglu_addr); |
| 1796 | state_save_register_item(machine, "SNDGLUDUMMYRD", NULL,0, state->sndglu_dummy_read); |
| 1824 | 1797 | |
| 1825 | | apple2gs_clock_timer = timer_alloc(machine, apple2gs_clock_tick, NULL); |
| 1826 | | timer_adjust_periodic(apple2gs_clock_timer, ATTOTIME_IN_SEC(1), 0, ATTOTIME_IN_SEC(1)); |
| 1798 | state->clock_timer = timer_alloc(machine, apple2gs_clock_tick, NULL); |
| 1799 | timer_adjust_periodic(state->clock_timer, ATTOTIME_IN_SEC(1), 0, ATTOTIME_IN_SEC(1)); |
| 1827 | 1800 | |
| 1828 | | apple2gs_qsecond_timer = timer_alloc(machine, apple2gs_qsecond_tick, NULL); |
| 1829 | | timer_adjust_periodic(apple2gs_qsecond_timer, ATTOTIME_IN_USEC(266700), 0, ATTOTIME_IN_USEC(266700)); |
| 1801 | state->qsecond_timer = timer_alloc(machine, apple2gs_qsecond_tick, NULL); |
| 1802 | timer_adjust_periodic(state->qsecond_timer, ATTOTIME_IN_USEC(266700), 0, ATTOTIME_IN_USEC(266700)); |
| 1830 | 1803 | |
| 1831 | | apple2gs_scanline_timer = timer_alloc(machine, apple2gs_scanline_tick, NULL); |
| 1832 | | timer_adjust_oneshot(apple2gs_scanline_timer, attotime_never, 0); |
| 1804 | state->scanline_timer = timer_alloc(machine, apple2gs_scanline_tick, NULL); |
| 1805 | timer_adjust_oneshot(state->scanline_timer, attotime_never, 0); |
| 1833 | 1806 | |
| 1834 | 1807 | // fire on scanline zero |
| 1835 | | timer_adjust_oneshot(apple2gs_scanline_timer, machine->primary_screen->time_until_pos(0, 0), 0); |
| 1808 | timer_adjust_oneshot(state->scanline_timer, machine->primary_screen->time_until_pos(0, 0), 0); |
| 1836 | 1809 | } |
src/mess/video/a7800.c
| r9648 | r9649 | |
| 30 | 30 | |
| 31 | 31 | #define READ_MEM(x) space->read_byte(x) |
| 32 | 32 | |
| 33 | | /*static unsigned char *ROM; */ |
| 34 | | |
| 35 | 33 | /********** Maria ***********/ |
| 36 | 34 | |
| 37 | 35 | #define DPPH 0x2c |
| 38 | 36 | #define DPPL 0x30 |
| 39 | 37 | #define CTRL 0x3c |
| 40 | 38 | |
| 41 | | static int maria_palette[8][4]; |
| 42 | | static int maria_write_mode; |
| 43 | | static int maria_scanline; |
| 44 | | static unsigned int maria_dll; |
| 45 | | static unsigned int maria_dl; |
| 46 | | static int maria_holey; |
| 47 | | static int maria_offset; |
| 48 | | static int maria_vblank; |
| 49 | | static int maria_dli; |
| 50 | | static int maria_dmaon; /* dma is enabled */ |
| 51 | | static int maria_dodma; /* doing dma right now */ |
| 52 | | static int maria_wsync; |
| 53 | | static int maria_backcolor; |
| 54 | 39 | |
| 55 | | static int maria_color_kill; |
| 56 | | static int maria_cwidth; |
| 57 | | static int maria_bcntl; |
| 58 | | static int maria_kangaroo; |
| 59 | | static int maria_rm; |
| 60 | 40 | |
| 61 | | static unsigned int maria_charbase; |
| 62 | 41 | |
| 63 | 42 | // 20030621 ericball define using logical operations |
| 64 | 43 | #define inc_hpos() { hpos = (hpos + 1) & 0x1FF; } |
| r9648 | r9649 | |
| 71 | 50 | ***************************************************************************/ |
| 72 | 51 | VIDEO_START( a7800 ) |
| 73 | 52 | { |
| 53 | a7800_state *state = machine->driver_data<a7800_state>(); |
| 74 | 54 | int i; |
| 75 | 55 | |
| 76 | 56 | VIDEO_START_CALL(generic_bitmapped); |
| 77 | 57 | |
| 78 | 58 | for(i=0; i<8; i++) |
| 79 | 59 | { |
| 80 | | maria_palette[i][0]=0; |
| 81 | | maria_palette[i][1]=0; |
| 82 | | maria_palette[i][2]=0; |
| 83 | | maria_palette[i][3]=0; |
| 60 | state->maria_palette[i][0]=0; |
| 61 | state->maria_palette[i][1]=0; |
| 62 | state->maria_palette[i][2]=0; |
| 63 | state->maria_palette[i][3]=0; |
| 84 | 64 | } |
| 85 | 65 | |
| 86 | | maria_write_mode=0; |
| 87 | | maria_scanline=0; |
| 88 | | maria_dmaon=0; |
| 89 | | maria_vblank=0x80; |
| 90 | | maria_dll=0; |
| 91 | | maria_dodma=0; |
| 92 | | maria_wsync=0; |
| 66 | state->maria_write_mode=0; |
| 67 | state->maria_scanline=0; |
| 68 | state->maria_dmaon=0; |
| 69 | state->maria_vblank=0x80; |
| 70 | state->maria_dll=0; |
| 71 | state->maria_dodma=0; |
| 72 | state->maria_wsync=0; |
| 93 | 73 | |
| 94 | | maria_color_kill = 0; |
| 95 | | maria_cwidth = 0; |
| 96 | | maria_bcntl = 0; |
| 97 | | maria_kangaroo = 0; |
| 98 | | maria_rm = 0; |
| 74 | state->maria_color_kill = 0; |
| 75 | state->maria_cwidth = 0; |
| 76 | state->maria_bcntl = 0; |
| 77 | state->maria_kangaroo = 0; |
| 78 | state->maria_rm = 0; |
| 99 | 79 | } |
| 100 | 80 | |
| 101 | 81 | /*************************************************************************** |
| r9648 | r9649 | |
| 106 | 86 | |
| 107 | 87 | static void maria_draw_scanline(running_machine *machine) |
| 108 | 88 | { |
| 89 | a7800_state *state = machine->driver_data<a7800_state>(); |
| 109 | 90 | address_space* space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 110 | 91 | unsigned int graph_adr,data_addr; |
| 111 | 92 | int width,hpos,pal,mode,ind; |
| r9648 | r9649 | |
| 115 | 96 | UINT16 *scanline; |
| 116 | 97 | |
| 117 | 98 | /* set up scanline */ |
| 118 | | scanline = BITMAP_ADDR16(machine->generic.tmpbitmap, maria_scanline, 0); |
| 99 | scanline = BITMAP_ADDR16(machine->generic.tmpbitmap, state->maria_scanline, 0); |
| 119 | 100 | for (i = 0; i < 320; i++) |
| 120 | | scanline[i] = maria_backcolor; |
| 101 | scanline[i] = state->maria_backcolor; |
| 121 | 102 | |
| 122 | 103 | /* Process this DLL entry */ |
| 123 | | dl = maria_dl; |
| 104 | dl = state->maria_dl; |
| 124 | 105 | |
| 125 | 106 | /* Step through DL's */ |
| 126 | 107 | while ((READ_MEM(dl + 1) & 0x5F) != 0) |
| r9648 | r9649 | |
| 133 | 114 | width = ((READ_MEM(dl+3) ^ 0xff) & 0x1F) + 1; |
| 134 | 115 | hpos = READ_MEM(dl+4)*2; |
| 135 | 116 | pal = READ_MEM(dl+3) >> 5; |
| 136 | | maria_write_mode = (READ_MEM(dl+1) & 0x80) >> 5; |
| 117 | state->maria_write_mode = (READ_MEM(dl+1) & 0x80) >> 5; |
| 137 | 118 | ind = READ_MEM(dl+1) & 0x20; |
| 138 | 119 | dl+=5; |
| 139 | 120 | } |
| r9648 | r9649 | |
| 148 | 129 | dl+=4; |
| 149 | 130 | } |
| 150 | 131 | |
| 151 | | mode = maria_rm | maria_write_mode; |
| 132 | mode = state->maria_rm | state->maria_write_mode; |
| 152 | 133 | |
| 153 | | /*logerror("%x DL: ADR=%x width=%x hpos=%x pal=%x mode=%x ind=%x\n",maria_scanline,graph_adr,width,hpos,pal,mode,ind );*/ |
| 134 | /*logerror("%x DL: ADR=%x width=%x hpos=%x pal=%x mode=%x ind=%x\n",state->maria_scanline,graph_adr,width,hpos,pal,mode,ind );*/ |
| 154 | 135 | |
| 155 | 136 | for (x=0; x<width; x++) // 20030621 ericball get graphic data first, then switch (mode) |
| 156 | 137 | { |
| r9648 | r9649 | |
| 160 | 141 | if (ind) |
| 161 | 142 | { |
| 162 | 143 | c = READ_MEM(graph_adr + x) & 0xFF; |
| 163 | | data_addr= (maria_charbase | c) + (maria_offset << 8); |
| 164 | | if( maria_cwidth ) |
| 144 | data_addr= (state->maria_charbase | c) + (state->maria_offset << 8); |
| 145 | if( state->maria_cwidth ) |
| 165 | 146 | ind_bytes = 2; |
| 166 | 147 | } |
| 167 | 148 | else |
| 168 | 149 | { |
| 169 | | data_addr = graph_adr + x + (maria_offset << 8); |
| 150 | data_addr = graph_adr + x + (state->maria_offset << 8); |
| 170 | 151 | } |
| 171 | 152 | |
| 172 | | if ( (maria_holey & 0x02) && ((data_addr & 0x9000) == 0x9000)) |
| 153 | if ( (state->maria_holey & 0x02) && ((data_addr & 0x9000) == 0x9000)) |
| 173 | 154 | continue; |
| 174 | | if ( (maria_holey & 0x01) && ((data_addr & 0x8800) == 0x8800)) |
| 155 | if ( (state->maria_holey & 0x01) && ((data_addr & 0x8800) == 0x8800)) |
| 175 | 156 | continue; |
| 176 | 157 | |
| 177 | 158 | while (ind_bytes > 0) |
| r9648 | r9649 | |
| 184 | 165 | case 0x00: /* 160A (160x2) */ |
| 185 | 166 | case 0x01: /* 160A (160x2) */ |
| 186 | 167 | c = (d & 0xC0) >> 6; |
| 187 | | if (c || maria_kangaroo) |
| 168 | if (c || state->maria_kangaroo) |
| 188 | 169 | { |
| 189 | | scanline[hpos + 0] = maria_palette[pal][c]; |
| 190 | | scanline[hpos + 1] = maria_palette[pal][c]; |
| 170 | scanline[hpos + 0] = state->maria_palette[pal][c]; |
| 171 | scanline[hpos + 1] = state->maria_palette[pal][c]; |
| 191 | 172 | } |
| 192 | 173 | inc_hpos_by_2(); |
| 193 | 174 | |
| 194 | 175 | c = (d & 0x30) >> 4; |
| 195 | | if (c || maria_kangaroo) |
| 176 | if (c || state->maria_kangaroo) |
| 196 | 177 | { |
| 197 | | scanline[hpos + 0] = maria_palette[pal][c]; |
| 198 | | scanline[hpos + 1] = maria_palette[pal][c]; |
| 178 | scanline[hpos + 0] = state->maria_palette[pal][c]; |
| 179 | scanline[hpos + 1] = state->maria_palette[pal][c]; |
| 199 | 180 | } |
| 200 | 181 | inc_hpos_by_2(); |
| 201 | 182 | |
| 202 | 183 | c = (d & 0x0C) >> 2; |
| 203 | | if (c || maria_kangaroo) |
| 184 | if (c || state->maria_kangaroo) |
| 204 | 185 | { |
| 205 | | scanline[hpos + 0] = maria_palette[pal][c]; |
| 206 | | scanline[hpos + 1] = maria_palette[pal][c]; |
| 186 | scanline[hpos + 0] = state->maria_palette[pal][c]; |
| 187 | scanline[hpos + 1] = state->maria_palette[pal][c]; |
| 207 | 188 | } |
| 208 | 189 | inc_hpos_by_2(); |
| 209 | 190 | |
| 210 | 191 | c = (d & 0x03); |
| 211 | | if (c || maria_kangaroo) |
| 192 | if (c || state->maria_kangaroo) |
| 212 | 193 | { |
| 213 | | scanline[hpos + 0] = maria_palette[pal][c]; |
| 214 | | scanline[hpos + 1] = maria_palette[pal][c]; |
| 194 | scanline[hpos + 0] = state->maria_palette[pal][c]; |
| 195 | scanline[hpos + 1] = state->maria_palette[pal][c]; |
| 215 | 196 | } |
| 216 | 197 | inc_hpos_by_2(); |
| 217 | 198 | break; |
| 218 | 199 | |
| 219 | 200 | case 0x02: /* 320D used by Jinks! */ |
| 220 | 201 | c = pal & 0x04; |
| 221 | | if ( d & 0xC0 || pal & 0x03 || maria_kangaroo ) |
| 202 | if ( d & 0xC0 || pal & 0x03 || state->maria_kangaroo ) |
| 222 | 203 | { |
| 223 | | scanline[hpos + 0] = maria_palette[c][((d & 0x80) >> 6) | ((pal & 2) >> 1)]; |
| 224 | | scanline[hpos + 1] = maria_palette[c][((d & 0x40) >> 5) | ((pal & 1) >> 0)]; |
| 204 | scanline[hpos + 0] = state->maria_palette[c][((d & 0x80) >> 6) | ((pal & 2) >> 1)]; |
| 205 | scanline[hpos + 1] = state->maria_palette[c][((d & 0x40) >> 5) | ((pal & 1) >> 0)]; |
| 225 | 206 | } |
| 226 | 207 | inc_hpos_by_2(); |
| 227 | 208 | |
| 228 | | if ( d & 0x30 || pal & 0x03 || maria_kangaroo ) |
| 209 | if ( d & 0x30 || pal & 0x03 || state->maria_kangaroo ) |
| 229 | 210 | { |
| 230 | | scanline[hpos + 0] = maria_palette[c][((d & 0x20) >> 4) | ((pal & 2) >> 1)]; |
| 231 | | scanline[hpos + 1] = maria_palette[c][((d & 0x10) >> 3) | ((pal & 1) >> 0)]; |
| 211 | scanline[hpos + 0] = state->maria_palette[c][((d & 0x20) >> 4) | ((pal & 2) >> 1)]; |
| 212 | scanline[hpos + 1] = state->maria_palette[c][((d & 0x10) >> 3) | ((pal & 1) >> 0)]; |
| 232 | 213 | } |
| 233 | 214 | inc_hpos_by_2(); |
| 234 | 215 | |
| 235 | | if ( d & 0x0C || pal & 0x03 || maria_kangaroo ) |
| 216 | if ( d & 0x0C || pal & 0x03 || state->maria_kangaroo ) |
| 236 | 217 | { |
| 237 | | scanline[hpos + 0] = maria_palette[c][((d & 0x08) >> 2) | ((pal & 2) >> 1)]; |
| 238 | | scanline[hpos + 1] = maria_palette[c][((d & 0x04) >> 1) | ((pal & 1) >> 0)]; |
| 218 | scanline[hpos + 0] = state->maria_palette[c][((d & 0x08) >> 2) | ((pal & 2) >> 1)]; |
| 219 | scanline[hpos + 1] = state->maria_palette[c][((d & 0x04) >> 1) | ((pal & 1) >> 0)]; |
| 239 | 220 | } |
| 240 | 221 | inc_hpos_by_2(); |
| 241 | 222 | |
| 242 | | if ( d & 0x03 || pal & 0x03 || maria_kangaroo ) |
| 223 | if ( d & 0x03 || pal & 0x03 || state->maria_kangaroo ) |
| 243 | 224 | { |
| 244 | | scanline[hpos + 0] = maria_palette[c][((d & 0x02) << 0) | ((pal & 2) >> 1)]; |
| 245 | | scanline[hpos + 1] = maria_palette[c][((d & 0x01) << 1) | ((pal & 1) >> 0)]; |
| 225 | scanline[hpos + 0] = state->maria_palette[c][((d & 0x02) << 0) | ((pal & 2) >> 1)]; |
| 226 | scanline[hpos + 1] = state->maria_palette[c][((d & 0x01) << 1) | ((pal & 1) >> 0)]; |
| 246 | 227 | } |
| 247 | 228 | inc_hpos_by_2(); |
| 248 | 229 | |
| 249 | 230 | break; |
| 250 | 231 | |
| 251 | 232 | case 0x03: /* MODE 320A */ |
| 252 | | if (d & 0xC0 || maria_kangaroo) |
| 233 | if (d & 0xC0 || state->maria_kangaroo) |
| 253 | 234 | { |
| 254 | | scanline[hpos + 0] = maria_palette[pal][(d & 0x80) >> 6]; |
| 255 | | scanline[hpos + 1] = maria_palette[pal][(d & 0x40) >> 5]; |
| 235 | scanline[hpos + 0] = state->maria_palette[pal][(d & 0x80) >> 6]; |
| 236 | scanline[hpos + 1] = state->maria_palette[pal][(d & 0x40) >> 5]; |
| 256 | 237 | } |
| 257 | 238 | inc_hpos_by_2(); |
| 258 | 239 | |
| 259 | | if ( d & 0x30 || maria_kangaroo) |
| 240 | if ( d & 0x30 || state->maria_kangaroo) |
| 260 | 241 | { |
| 261 | | scanline[hpos + 0] = maria_palette[pal][(d & 0x20) >> 4]; |
| 262 | | scanline[hpos + 1] = maria_palette[pal][(d & 0x10) >> 3]; |
| 242 | scanline[hpos + 0] = state->maria_palette[pal][(d & 0x20) >> 4]; |
| 243 | scanline[hpos + 1] = state->maria_palette[pal][(d & 0x10) >> 3]; |
| 263 | 244 | } |
| 264 | 245 | inc_hpos_by_2(); |
| 265 | 246 | |
| 266 | | if (d & 0x0C || maria_kangaroo) |
| 247 | if (d & 0x0C || state->maria_kangaroo) |
| 267 | 248 | { |
| 268 | | scanline[hpos + 0] = maria_palette[pal][(d & 0x08) >> 2]; |
| 269 | | scanline[hpos + 1] = maria_palette[pal][(d & 0x04) >> 1]; |
| 249 | scanline[hpos + 0] = state->maria_palette[pal][(d & 0x08) >> 2]; |
| 250 | scanline[hpos + 1] = state->maria_palette[pal][(d & 0x04) >> 1]; |
| 270 | 251 | } |
| 271 | 252 | inc_hpos_by_2(); |
| 272 | 253 | |
| 273 | | if (d & 0x03 || maria_kangaroo) |
| 254 | if (d & 0x03 || state->maria_kangaroo) |
| 274 | 255 | { |
| 275 | | scanline[hpos + 0] = maria_palette[pal][(d & 0x02)]; |
| 276 | | scanline[hpos + 1] = maria_palette[pal][(d & 0x01) << 1]; |
| 256 | scanline[hpos + 0] = state->maria_palette[pal][(d & 0x02)]; |
| 257 | scanline[hpos + 1] = state->maria_palette[pal][(d & 0x01) << 1]; |
| 277 | 258 | } |
| 278 | 259 | inc_hpos_by_2(); |
| 279 | 260 | break; |
| r9648 | r9649 | |
| 281 | 262 | case 0x04: /* 160B (160x4) */ |
| 282 | 263 | case 0x05: /* 160B (160x4) */ |
| 283 | 264 | c = (d & 0xC0) >> 6; |
| 284 | | if (c || maria_kangaroo) |
| 265 | if (c || state->maria_kangaroo) |
| 285 | 266 | { |
| 286 | | scanline[hpos + 0] = maria_palette[(pal & 0x04) | ((d & 0x0C) >> 2)][c]; |
| 287 | | scanline[hpos + 1] = maria_palette[(pal & 0x04) | ((d & 0x0C) >> 2)][c]; |
| 267 | scanline[hpos + 0] = state->maria_palette[(pal & 0x04) | ((d & 0x0C) >> 2)][c]; |
| 268 | scanline[hpos + 1] = state->maria_palette[(pal & 0x04) | ((d & 0x0C) >> 2)][c]; |
| 288 | 269 | } |
| 289 | 270 | inc_hpos_by_2(); |
| 290 | 271 | |
| 291 | 272 | c = (d & 0x30) >> 4; |
| 292 | | if (c || maria_kangaroo) |
| 273 | if (c || state->maria_kangaroo) |
| 293 | 274 | { |
| 294 | | scanline[hpos + 0] = maria_palette[(pal & 0x04) | (d & 0x03)][c]; |
| 295 | | scanline[hpos + 1] = maria_palette[(pal & 0x04) | (d & 0x03)][c]; |
| 275 | scanline[hpos + 0] = state->maria_palette[(pal & 0x04) | (d & 0x03)][c]; |
| 276 | scanline[hpos + 1] = state->maria_palette[(pal & 0x04) | (d & 0x03)][c]; |
| 296 | 277 | } |
| 297 | 278 | inc_hpos_by_2(); |
| 298 | 279 | break; |
| 299 | 280 | |
| 300 | 281 | case 0x06: /* MODE 320B */ |
| 301 | | if (d & 0xCC || maria_kangaroo) |
| 282 | if (d & 0xCC || state->maria_kangaroo) |
| 302 | 283 | { |
| 303 | | scanline[hpos + 0] = maria_palette[pal][((d & 0x80) >> 6) | ((d & 0x08) >> 3)]; |
| 304 | | scanline[hpos + 1] = maria_palette[pal][((d & 0x40) >> 5) | ((d & 0x04) >> 2)]; |
| 284 | scanline[hpos + 0] = state->maria_palette[pal][((d & 0x80) >> 6) | ((d & 0x08) >> 3)]; |
| 285 | scanline[hpos + 1] = state->maria_palette[pal][((d & 0x40) >> 5) | ((d & 0x04) >> 2)]; |
| 305 | 286 | } |
| 306 | 287 | inc_hpos_by_2(); |
| 307 | 288 | |
| 308 | | if ( d & 0x33 || maria_kangaroo) |
| 289 | if ( d & 0x33 || state->maria_kangaroo) |
| 309 | 290 | { |
| 310 | | scanline[hpos + 0] = maria_palette[pal][((d & 0x20) >> 4) | ((d & 0x02) >> 1)]; |
| 311 | | scanline[hpos + 1] = maria_palette[pal][((d & 0x10) >> 3) | (d & 0x01)]; |
| 291 | scanline[hpos + 0] = state->maria_palette[pal][((d & 0x20) >> 4) | ((d & 0x02) >> 1)]; |
| 292 | scanline[hpos + 1] = state->maria_palette[pal][((d & 0x10) >> 3) | (d & 0x01)]; |
| 312 | 293 | } |
| 313 | 294 | inc_hpos_by_2(); |
| 314 | 295 | break; |
| 315 | 296 | |
| 316 | 297 | case 0x07: /* (320C mode) */ |
| 317 | | if (d & 0xC0 || maria_kangaroo) |
| 298 | if (d & 0xC0 || state->maria_kangaroo) |
| 318 | 299 | { |
| 319 | | scanline[hpos + 0] = maria_palette[(pal & 0x04) | ((d & 0x0C) >> 2)][(d & 0x80) >> 6]; |
| 320 | | scanline[hpos + 1] = maria_palette[(pal & 0x04) | ((d & 0x0C) >> 2)][(d & 0x40) >> 5]; |
| 300 | scanline[hpos + 0] = state->maria_palette[(pal & 0x04) | ((d & 0x0C) >> 2)][(d & 0x80) >> 6]; |
| 301 | scanline[hpos + 1] = state->maria_palette[(pal & 0x04) | ((d & 0x0C) >> 2)][(d & 0x40) >> 5]; |
| 321 | 302 | } |
| 322 | 303 | inc_hpos_by_2(); |
| 323 | 304 | |
| 324 | | if ( d & 0x30 || maria_kangaroo) |
| 305 | if ( d & 0x30 || state->maria_kangaroo) |
| 325 | 306 | { |
| 326 | | scanline[hpos + 0] = maria_palette[(pal & 0x04) | (d & 0x03)][(d & 0x20) >> 4]; |
| 327 | | scanline[hpos + 1] = maria_palette[(pal & 0x04) | (d & 0x03)][(d & 0x10) >> 3]; |
| 307 | scanline[hpos + 0] = state->maria_palette[(pal & 0x04) | (d & 0x03)][(d & 0x20) >> 4]; |
| 308 | scanline[hpos + 1] = state->maria_palette[(pal & 0x04) | (d & 0x03)][(d & 0x10) >> 3]; |
| 328 | 309 | } |
| 329 | 310 | inc_hpos_by_2(); |
| 330 | 311 | break; |
| r9648 | r9649 | |
| 338 | 319 | |
| 339 | 320 | INTERRUPT_GEN( a7800_interrupt ) |
| 340 | 321 | { |
| 322 | a7800_state *state = device->machine->driver_data<a7800_state>(); |
| 341 | 323 | int frame_scanline; |
| 342 | 324 | UINT8 *ROM = memory_region(device->machine, "maincpu"); |
| 343 | 325 | address_space* space = cputag_get_address_space(device->machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 344 | 326 | |
| 345 | | maria_scanline++; |
| 327 | state->maria_scanline++; |
| 346 | 328 | |
| 347 | 329 | /* why + 1? */ |
| 348 | | frame_scanline = maria_scanline % ( a7800_lines + 1 ); |
| 330 | frame_scanline = state->maria_scanline % ( state->lines + 1 ); |
| 349 | 331 | |
| 350 | 332 | if( frame_scanline == 1 ) |
| 351 | 333 | { |
| 352 | 334 | /*logerror( "frame beg\n" );*/ |
| 353 | 335 | } |
| 354 | 336 | |
| 355 | | if( maria_wsync ) |
| 337 | if( state->maria_wsync ) |
| 356 | 338 | { |
| 357 | 339 | cpuexec_trigger( device->machine, TRIGGER_HSYNC ); |
| 358 | | maria_wsync = 0; |
| 340 | state->maria_wsync = 0; |
| 359 | 341 | } |
| 360 | 342 | |
| 361 | 343 | if( frame_scanline == 16 ) |
| 362 | 344 | { |
| 363 | 345 | /* end of vblank */ |
| 364 | 346 | |
| 365 | | maria_vblank=0; |
| 366 | | if( maria_dmaon || maria_dodma ) |
| 347 | state->maria_vblank=0; |
| 348 | if( state->maria_dmaon || state->maria_dodma ) |
| 367 | 349 | { |
| 368 | | maria_dodma = 1; /* if dma allowed, start it */ |
| 350 | state->maria_dodma = 1; /* if dma allowed, start it */ |
| 369 | 351 | |
| 370 | | maria_dll = (ROM[DPPH] << 8) | ROM[DPPL]; |
| 371 | | maria_dl = (READ_MEM(maria_dll+1) << 8) | READ_MEM(maria_dll+2); |
| 372 | | maria_offset = READ_MEM(maria_dll) & 0x0f; |
| 373 | | maria_holey = (READ_MEM(maria_dll) & 0x60) >> 5; |
| 374 | | maria_dli = READ_MEM(maria_dll) & 0x80; |
| 375 | | /* logerror("DLL=%x\n",maria_dll); */ |
| 376 | | /* logerror("DLL: DL = %x dllctrl = %x\n",maria_dl,ROM[maria_dll]); */ |
| 352 | state->maria_dll = (ROM[DPPH] << 8) | ROM[DPPL]; |
| 353 | state->maria_dl = (READ_MEM(state->maria_dll+1) << 8) | READ_MEM(state->maria_dll+2); |
| 354 | state->maria_offset = READ_MEM(state->maria_dll) & 0x0f; |
| 355 | state->maria_holey = (READ_MEM(state->maria_dll) & 0x60) >> 5; |
| 356 | state->maria_dli = READ_MEM(state->maria_dll) & 0x80; |
| 357 | /* logerror("DLL=%x\n",state->maria_dll); */ |
| 358 | /* logerror("DLL: DL = %x dllctrl = %x\n",state->maria_dl,ROM[state->maria_dll]); */ |
| 377 | 359 | } |
| 378 | 360 | |
| 379 | 361 | /*logerror( "vblank end on line %d\n", frame_scanline );*/ |
| r9648 | r9649 | |
| 383 | 365 | this fix made PR Baseball happy |
| 384 | 366 | Kung-Fu Master looks worse |
| 385 | 367 | don't know about others yet */ |
| 386 | | if( frame_scanline == ( a7800_lines - 4 ) ) |
| 368 | if( frame_scanline == ( state->lines - 4 ) ) |
| 387 | 369 | { |
| 388 | 370 | /* vblank starts 4 scanlines before end of screen */ |
| 389 | 371 | |
| 390 | | maria_vblank = 0x80; |
| 372 | state->maria_vblank = 0x80; |
| 391 | 373 | |
| 392 | 374 | /* fixed 2002/05/14 kubecj |
| 393 | 375 | when going vblank, dma must be stopped |
| r9648 | r9649 | |
| 404 | 386 | Jinks |
| 405 | 387 | */ |
| 406 | 388 | |
| 407 | | maria_dodma = 0; |
| 389 | state->maria_dodma = 0; |
| 408 | 390 | /*logerror( "vblank on line %d\n\n", frame_scanline );*/ |
| 409 | 391 | } |
| 410 | 392 | |
| 411 | 393 | |
| 412 | | if( ( frame_scanline > 15 ) && maria_dodma ) |
| 394 | if( ( frame_scanline > 15 ) && state->maria_dodma ) |
| 413 | 395 | { |
| 414 | | if (maria_scanline < ( a7800_lines - 4 ) ) |
| 396 | if (state->maria_scanline < ( state->lines - 4 ) ) |
| 415 | 397 | maria_draw_scanline(device->machine); |
| 416 | 398 | |
| 417 | | if( maria_offset == 0 ) |
| 399 | if( state->maria_offset == 0 ) |
| 418 | 400 | { |
| 419 | | maria_dll+=3; |
| 420 | | maria_dl = (READ_MEM(maria_dll+1) << 8) | READ_MEM(maria_dll+2); |
| 421 | | maria_offset = READ_MEM(maria_dll) & 0x0f; |
| 422 | | maria_holey = (READ_MEM(maria_dll) & 0x60) >> 5; |
| 423 | | maria_dli = READ_MEM(maria_dll) & 0x80; |
| 401 | state->maria_dll+=3; |
| 402 | state->maria_dl = (READ_MEM(state->maria_dll+1) << 8) | READ_MEM(state->maria_dll+2); |
| 403 | state->maria_offset = READ_MEM(state->maria_dll) & 0x0f; |
| 404 | state->maria_holey = (READ_MEM(state->maria_dll) & 0x60) >> 5; |
| 405 | state->maria_dli = READ_MEM(state->maria_dll) & 0x80; |
| 424 | 406 | } |
| 425 | 407 | else |
| 426 | 408 | { |
| 427 | | maria_offset--; |
| 409 | state->maria_offset--; |
| 428 | 410 | } |
| 429 | 411 | } |
| 430 | 412 | |
| 431 | | if( maria_dli ) |
| 413 | if( state->maria_dli ) |
| 432 | 414 | { |
| 433 | 415 | /*logerror( "dli on line %d [%02X] [%02X] [%02X]\n", frame_scanline, ROM[0x7E], ROM[0x7C], ROM[0x7D] );*/ |
| 434 | 416 | } |
| 435 | 417 | |
| 436 | | if( maria_dli ) |
| 418 | if( state->maria_dli ) |
| 437 | 419 | { |
| 438 | | maria_dli = 0; |
| 420 | state->maria_dli = 0; |
| 439 | 421 | cpu_set_input_line(device, INPUT_LINE_NMI, PULSE_LINE); |
| 440 | 422 | } |
| 441 | 423 | |
| r9648 | r9649 | |
| 449 | 431 | /* This routine is called at the start of vblank to refresh the screen */ |
| 450 | 432 | VIDEO_UPDATE( a7800 ) |
| 451 | 433 | { |
| 452 | | maria_scanline = 0; |
| 434 | a7800_state *state = screen->machine->driver_data<a7800_state>(); |
| 435 | state->maria_scanline = 0; |
| 453 | 436 | VIDEO_UPDATE_CALL(generic_bitmapped); |
| 454 | 437 | return 0; |
| 455 | 438 | } |
| r9648 | r9649 | |
| 459 | 442 | |
| 460 | 443 | READ8_HANDLER( a7800_MARIA_r ) |
| 461 | 444 | { |
| 445 | a7800_state *state = space->machine->driver_data<a7800_state>(); |
| 462 | 446 | UINT8 *ROM = memory_region(space->machine, "maincpu"); |
| 463 | 447 | switch (offset) |
| 464 | 448 | { |
| 465 | 449 | case 0x08: |
| 466 | | return maria_vblank; |
| 450 | return state->maria_vblank; |
| 467 | 451 | |
| 468 | 452 | default: |
| 469 | 453 | logerror("undefined MARIA read %x\n",offset); |
| r9648 | r9649 | |
| 473 | 457 | |
| 474 | 458 | WRITE8_HANDLER( a7800_MARIA_w ) |
| 475 | 459 | { |
| 460 | a7800_state *state = space->machine->driver_data<a7800_state>(); |
| 476 | 461 | UINT8 *ROM = memory_region(space->machine, "maincpu"); |
| 477 | 462 | switch (offset) |
| 478 | 463 | { |
| 479 | 464 | case 0x00: |
| 480 | | maria_backcolor = data; |
| 481 | | // 20030621 ericball added maria_palette[pal][0] to make kanagroo mode easier |
| 482 | | maria_palette[0][0]=maria_backcolor; |
| 483 | | maria_palette[1][0]=maria_backcolor; |
| 484 | | maria_palette[2][0]=maria_backcolor; |
| 485 | | maria_palette[3][0]=maria_backcolor; |
| 486 | | maria_palette[4][0]=maria_backcolor; |
| 487 | | maria_palette[5][0]=maria_backcolor; |
| 488 | | maria_palette[6][0]=maria_backcolor; |
| 489 | | maria_palette[7][0]=maria_backcolor; |
| 465 | state->maria_backcolor = data; |
| 466 | // 20030621 ericball added state->maria_palette[pal][0] to make kanagroo mode easier |
| 467 | state->maria_palette[0][0]=state->maria_backcolor; |
| 468 | state->maria_palette[1][0]=state->maria_backcolor; |
| 469 | state->maria_palette[2][0]=state->maria_backcolor; |
| 470 | state->maria_palette[3][0]=state->maria_backcolor; |
| 471 | state->maria_palette[4][0]=state->maria_backcolor; |
| 472 | state->maria_palette[5][0]=state->maria_backcolor; |
| 473 | state->maria_palette[6][0]=state->maria_backcolor; |
| 474 | state->maria_palette[7][0]=state->maria_backcolor; |
| 490 | 475 | break; |
| 491 | 476 | case 0x01: |
| 492 | | maria_palette[0][1] = data; |
| 477 | state->maria_palette[0][1] = data; |
| 493 | 478 | break; |
| 494 | 479 | case 0x02: |
| 495 | | maria_palette[0][2] = data; |
| 480 | state->maria_palette[0][2] = data; |
| 496 | 481 | break; |
| 497 | 482 | case 0x03: |
| 498 | | maria_palette[0][3] = data; |
| 483 | state->maria_palette[0][3] = data; |
| 499 | 484 | break; |
| 500 | 485 | case 0x04: |
| 501 | 486 | cpu_spinuntil_trigger(space->machine->device("maincpu"), TRIGGER_HSYNC); |
| 502 | | maria_wsync=1; |
| 487 | state->maria_wsync=1; |
| 503 | 488 | break; |
| 504 | 489 | |
| 505 | 490 | case 0x05: |
| 506 | | maria_palette[1][1] = data; |
| 491 | state->maria_palette[1][1] = data; |
| 507 | 492 | break; |
| 508 | 493 | case 0x06: |
| 509 | | maria_palette[1][2] = data; |
| 494 | state->maria_palette[1][2] = data; |
| 510 | 495 | break; |
| 511 | 496 | case 0x07: |
| 512 | | maria_palette[1][3] = data; |
| 497 | state->maria_palette[1][3] = data; |
| 513 | 498 | break; |
| 514 | 499 | |
| 515 | 500 | case 0x09: |
| 516 | | maria_palette[2][1] = data; |
| 501 | state->maria_palette[2][1] = data; |
| 517 | 502 | break; |
| 518 | 503 | case 0x0A: |
| 519 | | maria_palette[2][2] = data; |
| 504 | state->maria_palette[2][2] = data; |
| 520 | 505 | break; |
| 521 | 506 | case 0x0B: |
| 522 | | maria_palette[2][3] = data; |
| 507 | state->maria_palette[2][3] = data; |
| 523 | 508 | break; |
| 524 | 509 | |
| 525 | 510 | case 0x0D: |
| 526 | | maria_palette[3][1] = data; |
| 511 | state->maria_palette[3][1] = data; |
| 527 | 512 | break; |
| 528 | 513 | case 0x0E: |
| 529 | | maria_palette[3][2] = data; |
| 514 | state->maria_palette[3][2] = data; |
| 530 | 515 | break; |
| 531 | 516 | case 0x0F: |
| 532 | | maria_palette[3][3] = data; |
| 517 | state->maria_palette[3][3] = data; |
| 533 | 518 | break; |
| 534 | 519 | |
| 535 | 520 | case 0x11: |
| 536 | | maria_palette[4][1] = data; |
| 521 | state->maria_palette[4][1] = data; |
| 537 | 522 | break; |
| 538 | 523 | case 0x12: |
| 539 | | maria_palette[4][2] = data; |
| 524 | state->maria_palette[4][2] = data; |
| 540 | 525 | break; |
| 541 | 526 | case 0x13: |
| 542 | | maria_palette[4][3] = data; |
| 527 | state->maria_palette[4][3] = data; |
| 543 | 528 | break; |
| 544 | 529 | case 0x14: |
| 545 | | maria_charbase = (data << 8); |
| 530 | state->maria_charbase = (data << 8); |
| 546 | 531 | break; |
| 547 | 532 | case 0x15: |
| 548 | | maria_palette[5][1] = data; |
| 533 | state->maria_palette[5][1] = data; |
| 549 | 534 | break; |
| 550 | 535 | case 0x16: |
| 551 | | maria_palette[5][2] = data; |
| 536 | state->maria_palette[5][2] = data; |
| 552 | 537 | break; |
| 553 | 538 | case 0x17: |
| 554 | | maria_palette[5][3] = data; |
| 539 | state->maria_palette[5][3] = data; |
| 555 | 540 | break; |
| 556 | 541 | |
| 557 | 542 | case 0x19: |
| 558 | | maria_palette[6][1] = data; |
| 543 | state->maria_palette[6][1] = data; |
| 559 | 544 | break; |
| 560 | 545 | case 0x1A: |
| 561 | | maria_palette[6][2] = data; |
| 546 | state->maria_palette[6][2] = data; |
| 562 | 547 | break; |
| 563 | 548 | case 0x1B: |
| 564 | | maria_palette[6][3] = data; |
| 549 | state->maria_palette[6][3] = data; |
| 565 | 550 | break; |
| 566 | 551 | |
| 567 | 552 | case 0x1C: |
| 568 | 553 | /*logerror("MARIA CTRL=%x\n",data);*/ |
| 569 | | maria_color_kill = data & 0x80; |
| 554 | state->maria_color_kill = data & 0x80; |
| 570 | 555 | if ((data & 0x60) == 0x40) |
| 571 | | maria_dmaon = 1; |
| 556 | state->maria_dmaon = 1; |
| 572 | 557 | else |
| 573 | | maria_dmaon = maria_dodma = 0; |
| 558 | state->maria_dmaon = state->maria_dodma = 0; |
| 574 | 559 | |
| 575 | | maria_cwidth = data & 0x10; |
| 576 | | maria_bcntl = data & 0x08; |
| 577 | | maria_kangaroo = data & 0x04; |
| 578 | | maria_rm = data & 0x03; |
| 560 | state->maria_cwidth = data & 0x10; |
| 561 | state->maria_bcntl = data & 0x08; |
| 562 | state->maria_kangaroo = data & 0x04; |
| 563 | state->maria_rm = data & 0x03; |
| 579 | 564 | |
| 580 | 565 | /*logerror( "MARIA CTRL: CK:%d DMA:%d CW:%d BC:%d KM:%d RM:%d\n", |
| 581 | | maria_color_kill ? 1 : 0, |
| 566 | state->maria_color_kill ? 1 : 0, |
| 582 | 567 | ( data & 0x60 ) >> 5, |
| 583 | | maria_cwidth ? 1 : 0, |
| 584 | | maria_bcntl ? 1 : 0, |
| 585 | | maria_kangaroo ? 1 : 0, |
| 586 | | maria_rm );*/ |
| 568 | state->maria_cwidth ? 1 : 0, |
| 569 | state->maria_bcntl ? 1 : 0, |
| 570 | state->maria_kangaroo ? 1 : 0, |
| 571 | state->maria_rm );*/ |
| 587 | 572 | |
| 588 | 573 | break; |
| 589 | 574 | case 0x1D: |
| 590 | | maria_palette[7][1] = data; |
| 575 | state->maria_palette[7][1] = data; |
| 591 | 576 | break; |
| 592 | 577 | case 0x1E: |
| 593 | | maria_palette[7][2] = data; |
| 578 | state->maria_palette[7][2] = data; |
| 594 | 579 | break; |
| 595 | 580 | case 0x1F: |
| 596 | | maria_palette[7][3] = data; |
| 581 | state->maria_palette[7][3] = data; |
| 597 | 582 | break; |
| 598 | 583 | } |
| 599 | 584 | ROM[ 0x20 + offset ] = data; |
src/mess/drivers/avigo.c
| r9648 | r9649 | |
| 41 | 41 | #include "emu.h" |
| 42 | 42 | #include "cpu/z80/z80.h" |
| 43 | 43 | #include "includes/avigo.h" |
| 44 | | #include "machine/intelfsh.h" |
| 45 | 44 | #include "machine/tc8521.h" |
| 46 | 45 | #include "machine/ins8250.h" |
| 47 | 46 | #include "sound/speaker.h" |
| 48 | 47 | #include "devices/messram.h" |
| 49 | 48 | |
| 50 | | static UINT8 avigo_key_line; |
| 51 | 49 | /* |
| 52 | 50 | bit 7: ?? high priority. When it occurs, clear this bit. |
| 53 | 51 | bit 6: pen int |
| r9648 | r9649 | |
| 68 | 66 | |
| 69 | 67 | */ |
| 70 | 68 | |
| 71 | | static UINT8 avigo_irq; |
| 72 | 69 | |
| 73 | 70 | /* bit 3 = speaker state */ |
| 74 | | static UINT8 avigo_speaker_data; |
| 75 | 71 | |
| 76 | 72 | /* bits 0-5 define bank index */ |
| 77 | | static unsigned long avigo_ram_bank_l; |
| 78 | | static unsigned long avigo_ram_bank_h; |
| 79 | 73 | /* bits 0-5 define bank index */ |
| 80 | | static unsigned long avigo_rom_bank_l; |
| 81 | | static unsigned long avigo_rom_bank_h; |
| 82 | | static unsigned long avigo_ad_control_status; |
| 83 | | static intelfsh8_device *avigo_flashes[3]; |
| 84 | | static int avigo_flash_at_0x4000; |
| 85 | | static int avigo_flash_at_0x8000; |
| 86 | | static void *avigo_banked_opbase[4]; |
| 87 | 74 | |
| 88 | 75 | static void avigo_setbank(running_machine *machine, int bank, void *address, read8_space_func rh, write8_space_func wh) |
| 89 | 76 | { |
| 77 | avigo_state *state = machine->driver_data<avigo_state>(); |
| 90 | 78 | address_space* space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 91 | 79 | char bank_1[10]; |
| 92 | 80 | char bank_5[10]; |
| r9648 | r9649 | |
| 97 | 85 | { |
| 98 | 86 | memory_set_bankptr(machine, bank_1, address); |
| 99 | 87 | memory_set_bankptr(machine, bank_5, address); |
| 100 | | avigo_banked_opbase[bank] = ((UINT8 *) address) - (bank * 0x4000); |
| 88 | state->banked_opbase[bank] = ((UINT8 *) address) - (bank * 0x4000); |
| 101 | 89 | } |
| 102 | 90 | if (rh) |
| 103 | 91 | { |
| r9648 | r9649 | |
| 116 | 104 | /* memory 0x0000-0x03fff */ |
| 117 | 105 | static READ8_HANDLER(avigo_flash_0x0000_read_handler) |
| 118 | 106 | { |
| 119 | | return avigo_flashes[0]->read(offset); |
| 107 | avigo_state *state = space->machine->driver_data<avigo_state>(); |
| 108 | return state->flashes[0]->read(offset); |
| 120 | 109 | } |
| 121 | 110 | |
| 122 | 111 | /* memory 0x04000-0x07fff */ |
| 123 | 112 | static READ8_HANDLER(avigo_flash_0x4000_read_handler) |
| 124 | 113 | { |
| 125 | | return avigo_flashes[avigo_flash_at_0x4000]->read((avigo_rom_bank_l<<14) | offset); |
| 114 | avigo_state *state = space->machine->driver_data<avigo_state>(); |
| 115 | return state->flashes[state->flash_at_0x4000]->read((state->rom_bank_l<<14) | offset); |
| 126 | 116 | } |
| 127 | 117 | |
| 128 | 118 | /* memory 0x0000-0x03fff */ |
| 129 | 119 | static WRITE8_HANDLER(avigo_flash_0x0000_write_handler) |
| 130 | 120 | { |
| 131 | | avigo_flashes[0]->write(offset, data); |
| 121 | avigo_state *state = space->machine->driver_data<avigo_state>(); |
| 122 | state->flashes[0]->write(offset, data); |
| 132 | 123 | } |
| 133 | 124 | |
| 134 | 125 | /* memory 0x04000-0x07fff */ |
| 135 | 126 | static WRITE8_HANDLER(avigo_flash_0x4000_write_handler) |
| 136 | 127 | { |
| 137 | | avigo_flashes[avigo_flash_at_0x4000]->write((avigo_rom_bank_l<<14) | offset, data); |
| 128 | avigo_state *state = space->machine->driver_data<avigo_state>(); |
| 129 | state->flashes[state->flash_at_0x4000]->write((state->rom_bank_l<<14) | offset, data); |
| 138 | 130 | } |
| 139 | 131 | |
| 140 | 132 | /* memory 0x08000-0x0bfff */ |
| 141 | 133 | static READ8_HANDLER(avigo_flash_0x8000_read_handler) |
| 142 | 134 | { |
| 143 | | return avigo_flashes[avigo_flash_at_0x8000]->read((avigo_ram_bank_l<<14) | offset); |
| 135 | avigo_state *state = space->machine->driver_data<avigo_state>(); |
| 136 | return state->flashes[state->flash_at_0x8000]->read((state->ram_bank_l<<14) | offset); |
| 144 | 137 | } |
| 145 | 138 | |
| 146 | 139 | #ifdef UNUSED_FUNCTION |
| 147 | 140 | /* memory 0x08000-0x0bfff */ |
| 148 | 141 | static WRITE8_HANDLER(avigo_flash_0x8000_write_handler) |
| 149 | 142 | { |
| 150 | | avigo_flashes[avigo_flash_at_0x8000]->write((avigo_rom_bank_l<<14) | offset, data); |
| 143 | avigo_state *state = space->machine->driver_data<avigo_state>(); |
| 144 | state->flashes[state->flash_at_0x8000]->write((state->rom_bank_l<<14) | offset, data); |
| 151 | 145 | } |
| 152 | 146 | #endif |
| 153 | 147 | |
| 154 | 148 | static void avigo_refresh_ints(running_machine *machine) |
| 155 | 149 | { |
| 156 | | if (avigo_irq!=0) |
| 150 | avigo_state *state = machine->driver_data<avigo_state>(); |
| 151 | if (state->irq!=0) |
| 157 | 152 | cputag_set_input_line(machine, "maincpu", 0, HOLD_LINE); |
| 158 | 153 | else |
| 159 | 154 | cputag_set_input_line(machine, "maincpu", 0, CLEAR_LINE); |
| r9648 | r9649 | |
| 161 | 156 | |
| 162 | 157 | |
| 163 | 158 | /* previous input port data */ |
| 164 | | static int previous_input_port_data[4]; |
| 165 | | static int stylus_marker_x; |
| 166 | | static int stylus_marker_y; |
| 167 | | static int stylus_press_x; |
| 168 | | static int stylus_press_y; |
| 169 | 159 | |
| 170 | 160 | /* this is not a real interrupt. This timer updates the stylus position from mouse |
| 171 | 161 | movements, and checks if the mouse button is pressed to emulate a press of the stylus to the screen. |
| 172 | 162 | */ |
| 173 | 163 | static TIMER_CALLBACK(avigo_dummy_timer_callback) |
| 174 | 164 | { |
| 165 | avigo_state *state = machine->driver_data<avigo_state>(); |
| 175 | 166 | int i; |
| 176 | 167 | int current_input_port_data[4]; |
| 177 | 168 | int changed; |
| 178 | | static int ox = 0, oy = 0; |
| 179 | 169 | int nx,ny; |
| 180 | 170 | int dx, dy; |
| 181 | 171 | static const char *const linenames[] = { "LINE0", "LINE1", "LINE2", "LINE3" }; |
| r9648 | r9649 | |
| 185 | 175 | current_input_port_data[i] = input_port_read(machine, linenames[i]); |
| 186 | 176 | } |
| 187 | 177 | |
| 188 | | changed = current_input_port_data[3]^previous_input_port_data[3]; |
| 178 | changed = current_input_port_data[3]^state->previous_input_port_data[3]; |
| 189 | 179 | |
| 190 | 180 | if ((changed & 0x01)!=0) |
| 191 | 181 | { |
| r9648 | r9649 | |
| 194 | 184 | /* pen pressed to screen */ |
| 195 | 185 | |
| 196 | 186 | logerror("pen pressed interrupt\n"); |
| 197 | | stylus_press_x = stylus_marker_x; |
| 198 | | stylus_press_y = stylus_marker_y; |
| 187 | state->stylus_press_x = state->stylus_marker_x; |
| 188 | state->stylus_press_y = state->stylus_marker_y; |
| 199 | 189 | /* set pen interrupt */ |
| 200 | | avigo_irq |= (1<<6); |
| 190 | state->irq |= (1<<6); |
| 201 | 191 | } |
| 202 | 192 | else |
| 203 | 193 | { |
| 204 | | stylus_press_x = 0; |
| 205 | | stylus_press_y = 0; |
| 194 | state->stylus_press_x = 0; |
| 195 | state->stylus_press_y = 0; |
| 206 | 196 | } |
| 207 | 197 | } |
| 208 | 198 | |
| r9648 | r9649 | |
| 217 | 207 | |
| 218 | 208 | for (i=0; i<4; i++) |
| 219 | 209 | { |
| 220 | | previous_input_port_data[i] = current_input_port_data[i]; |
| 210 | state->previous_input_port_data[i] = current_input_port_data[i]; |
| 221 | 211 | } |
| 222 | 212 | |
| 223 | 213 | nx = input_port_read(machine, "POSX"); |
| 224 | 214 | if (nx>=0x800) nx-=0x1000; |
| 225 | 215 | else if (nx<=-0x800) nx+=0x1000; |
| 226 | 216 | |
| 227 | | dx = nx - ox; |
| 228 | | ox = nx; |
| 217 | dx = nx - state->ox; |
| 218 | state->ox = nx; |
| 229 | 219 | |
| 230 | 220 | ny = input_port_read(machine, "POSY"); |
| 231 | 221 | if (ny>=0x800) ny-=0x1000; |
| 232 | 222 | else if (ny<=-0x800) ny+=0x1000; |
| 233 | 223 | |
| 234 | | dy = ny - oy; |
| 235 | | oy = ny; |
| 224 | dy = ny - state->oy; |
| 225 | state->oy = ny; |
| 236 | 226 | |
| 237 | | stylus_marker_x +=dx; |
| 238 | | stylus_marker_y +=dy; |
| 227 | state->stylus_marker_x +=dx; |
| 228 | state->stylus_marker_y +=dy; |
| 239 | 229 | |
| 240 | | avigo_vh_set_stylus_marker_position(stylus_marker_x, stylus_marker_y); |
| 230 | avigo_vh_set_stylus_marker_position(machine, state->stylus_marker_x, state->stylus_marker_y); |
| 241 | 231 | #if 0 |
| 242 | 232 | /* not sure if keyboard generates an interrupt, or if something |
| 243 | 233 | is plugged in for synchronisation! */ |
| r9648 | r9649 | |
| 248 | 238 | int current; |
| 249 | 239 | current = ~current_input_port_data[i]; |
| 250 | 240 | |
| 251 | | changed = ((current^(~previous_input_port_data[i])) & 0x07); |
| 241 | changed = ((current^(~state->previous_input_port_data[i])) & 0x07); |
| 252 | 242 | |
| 253 | 243 | if (changed!=0) |
| 254 | 244 | { |
| r9648 | r9649 | |
| 256 | 246 | that has changed, the old state was off and new state is on */ |
| 257 | 247 | if (current & changed) |
| 258 | 248 | { |
| 259 | | avigo_irq |= (1<<2); |
| 249 | state->irq |= (1<<2); |
| 260 | 250 | break; |
| 261 | 251 | } |
| 262 | 252 | } |
| 263 | 253 | } |
| 264 | 254 | #endif |
| 265 | 255 | /* copy current to previous */ |
| 266 | | memcpy(previous_input_port_data, current_input_port_data, sizeof(int)*4); |
| 256 | memcpy(state->previous_input_port_data, current_input_port_data, sizeof(int)*4); |
| 267 | 257 | |
| 268 | 258 | /* refresh status of interrupts */ |
| 269 | 259 | avigo_refresh_ints(machine); |
| r9648 | r9649 | |
| 272 | 262 | /* does not do anything yet */ |
| 273 | 263 | static void avigo_tc8521_alarm_int(running_device *device, int state) |
| 274 | 264 | { |
| 265 | avigo_state *drvstate = device->machine->driver_data<avigo_state>(); |
| 275 | 266 | //#if 0 |
| 276 | | avigo_irq &=~(1<<5); |
| 267 | drvstate->irq &=~(1<<5); |
| 277 | 268 | |
| 278 | 269 | if (state) |
| 279 | 270 | { |
| 280 | | avigo_irq |= (1<<5); |
| 271 | drvstate->irq |= (1<<5); |
| 281 | 272 | } |
| 282 | 273 | |
| 283 | 274 | avigo_refresh_ints(device->machine); |
| r9648 | r9649 | |
| 292 | 283 | |
| 293 | 284 | static void avigo_refresh_memory(running_machine *machine) |
| 294 | 285 | { |
| 286 | avigo_state *state = machine->driver_data<avigo_state>(); |
| 295 | 287 | unsigned char *addr; |
| 296 | 288 | address_space* space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 297 | 289 | |
| 298 | | switch (avigo_rom_bank_h) |
| 290 | switch (state->rom_bank_h) |
| 299 | 291 | { |
| 300 | 292 | /* 011 */ |
| 301 | 293 | case 0x03: |
| 302 | 294 | { |
| 303 | | avigo_flash_at_0x4000 = 1; |
| 295 | state->flash_at_0x4000 = 1; |
| 304 | 296 | } |
| 305 | 297 | break; |
| 306 | 298 | |
| 307 | 299 | /* 101 */ |
| 308 | 300 | case 0x05: |
| 309 | 301 | { |
| 310 | | avigo_flash_at_0x4000 = 2; |
| 302 | state->flash_at_0x4000 = 2; |
| 311 | 303 | } |
| 312 | 304 | break; |
| 313 | 305 | |
| 314 | 306 | default: |
| 315 | | avigo_flash_at_0x4000 = 0; |
| 307 | state->flash_at_0x4000 = 0; |
| 316 | 308 | break; |
| 317 | 309 | } |
| 318 | 310 | |
| 319 | | addr = (unsigned char *)avigo_flashes[avigo_flash_at_0x4000]->space()->get_read_ptr(0); |
| 320 | | addr = addr + (avigo_rom_bank_l<<14); |
| 311 | addr = (unsigned char *)state->flashes[state->flash_at_0x4000]->space()->get_read_ptr(0); |
| 312 | addr = addr + (state->rom_bank_l<<14); |
| 321 | 313 | avigo_setbank(machine, 1, addr, avigo_flash_0x4000_read_handler, avigo_flash_0x4000_write_handler); |
| 322 | 314 | |
| 323 | | switch (avigo_ram_bank_h) |
| 315 | switch (state->ram_bank_h) |
| 324 | 316 | { |
| 325 | 317 | /* %101 */ |
| 326 | 318 | /* screen */ |
| r9648 | r9649 | |
| 331 | 323 | /* %001 */ |
| 332 | 324 | /* ram */ |
| 333 | 325 | case 0x01: |
| 334 | | addr = messram_get_ptr(machine->device("messram")) + ((avigo_ram_bank_l & 0x07)<<14); |
| 326 | addr = messram_get_ptr(machine->device("messram")) + ((state->ram_bank_l & 0x07)<<14); |
| 335 | 327 | memory_set_bankptr(machine, "bank3", addr); |
| 336 | 328 | memory_set_bankptr(machine, "bank7", addr); |
| 337 | | avigo_banked_opbase[2] = ((UINT8 *) addr) - (2 * 0x4000); |
| 329 | state->banked_opbase[2] = ((UINT8 *) addr) - (2 * 0x4000); |
| 338 | 330 | memory_install_read_bank (space, (2 * 0x4000),(2 * 0x4000) + 0x3FFF, 0, 0, "bank3"); |
| 339 | 331 | memory_install_write_bank(space, (2 * 0x4000),(2 * 0x4000) + 0x3FFF, 0, 0, "bank7"); |
| 340 | 332 | break; |
| 341 | 333 | |
| 342 | 334 | /* %111 */ |
| 343 | 335 | case 0x03: |
| 344 | | avigo_flash_at_0x8000 = 1; |
| 336 | state->flash_at_0x8000 = 1; |
| 345 | 337 | |
| 346 | 338 | |
| 347 | | addr = (unsigned char *)avigo_flashes[avigo_flash_at_0x8000]->space()->get_read_ptr(0); |
| 348 | | addr = addr + (avigo_ram_bank_l<<14); |
| 339 | addr = (unsigned char *)state->flashes[state->flash_at_0x8000]->space()->get_read_ptr(0); |
| 340 | addr = addr + (state->ram_bank_l<<14); |
| 349 | 341 | avigo_setbank(machine, 2, addr, avigo_flash_0x8000_read_handler, NULL /* avigo_flash_0x8000_write_handler */); |
| 350 | 342 | break; |
| 351 | 343 | |
| 352 | 344 | case 0x07: |
| 353 | | avigo_flash_at_0x8000 = 0; |
| 345 | state->flash_at_0x8000 = 0; |
| 354 | 346 | |
| 355 | | addr = (unsigned char *)avigo_flashes[avigo_flash_at_0x8000]->space()->get_read_ptr(0); |
| 356 | | addr = addr + (avigo_ram_bank_l<<14); |
| 347 | addr = (unsigned char *)state->flashes[state->flash_at_0x8000]->space()->get_read_ptr(0); |
| 348 | addr = addr + (state->ram_bank_l<<14); |
| 357 | 349 | avigo_setbank(machine, 2, addr, avigo_flash_0x8000_read_handler, NULL /* avigo_flash_0x8000_write_handler */); |
| 358 | 350 | break; |
| 359 | 351 | } |
| r9648 | r9649 | |
| 363 | 355 | |
| 364 | 356 | static INS8250_INTERRUPT( avigo_com_interrupt ) |
| 365 | 357 | { |
| 358 | avigo_state *drvstate = device->machine->driver_data<avigo_state>(); |
| 366 | 359 | logerror("com int\r\n"); |
| 367 | 360 | |
| 368 | | avigo_irq &= ~(1<<3); |
| 361 | drvstate->irq &= ~(1<<3); |
| 369 | 362 | |
| 370 | 363 | if (state) |
| 371 | 364 | { |
| 372 | | avigo_irq |= (1<<3); |
| 365 | drvstate->irq |= (1<<3); |
| 373 | 366 | } |
| 374 | 367 | |
| 375 | 368 | avigo_refresh_ints(device->machine); |
| r9648 | r9649 | |
| 389 | 382 | /* this is needed because this driver uses handlers in memory that gets executed */ |
| 390 | 383 | DIRECT_UPDATE_HANDLER( avigo_opbase_handler ) |
| 391 | 384 | { |
| 385 | avigo_state *state = machine->driver_data<avigo_state>(); |
| 392 | 386 | void *opbase_ptr; |
| 393 | 387 | |
| 394 | | opbase_ptr = avigo_banked_opbase[address / 0x4000]; |
| 388 | opbase_ptr = state->banked_opbase[address / 0x4000]; |
| 395 | 389 | if (opbase_ptr != NULL) |
| 396 | 390 | { |
| 397 | 391 | direct.explicit_configure(0x0000, 0xffff, 0xffff, (UINT8*)opbase_ptr); |
| r9648 | r9649 | |
| 402 | 396 | |
| 403 | 397 | static MACHINE_RESET( avigo ) |
| 404 | 398 | { |
| 399 | avigo_state *state = machine->driver_data<avigo_state>(); |
| 405 | 400 | int i; |
| 406 | 401 | unsigned char *addr; |
| 407 | 402 | static const char *const linenames[] = { "LINE0", "LINE1", "LINE2", "LINE3" }; |
| 408 | 403 | |
| 409 | | memset(avigo_banked_opbase, 0, sizeof(avigo_banked_opbase)); |
| 404 | memset(state->banked_opbase, 0, sizeof(state->banked_opbase)); |
| 410 | 405 | |
| 411 | 406 | /* keep machine pointers to flash devices */ |
| 412 | | avigo_flashes[0] = machine->device<intelfsh8_device>("flash0"); |
| 413 | | avigo_flashes[1] = machine->device<intelfsh8_device>("flash1"); |
| 414 | | avigo_flashes[2] = machine->device<intelfsh8_device>("flash2"); |
| 407 | state->flashes[0] = machine->device<intelfsh8_device>("flash0"); |
| 408 | state->flashes[1] = machine->device<intelfsh8_device>("flash1"); |
| 409 | state->flashes[2] = machine->device<intelfsh8_device>("flash2"); |
| 415 | 410 | |
| 416 | 411 | /* initialize flash contents */ |
| 417 | | memcpy(memory_region(machine, "maincpu")+0x10000, avigo_flashes[0]->space()->get_read_ptr(0), 0x100000); |
| 418 | | memcpy(memory_region(machine, "maincpu")+0x110000, avigo_flashes[1]->space()->get_read_ptr(0), 0x100000); |
| 412 | memcpy(memory_region(machine, "maincpu")+0x10000, state->flashes[0]->space()->get_read_ptr(0), 0x100000); |
| 413 | memcpy(memory_region(machine, "maincpu")+0x110000, state->flashes[1]->space()->get_read_ptr(0), 0x100000); |
| 419 | 414 | |
| 420 | | stylus_marker_x = AVIGO_SCREEN_WIDTH>>1; |
| 421 | | stylus_marker_y = AVIGO_SCREEN_HEIGHT>>1; |
| 422 | | stylus_press_x = 0; |
| 423 | | stylus_press_y = 0; |
| 424 | | avigo_vh_set_stylus_marker_position(stylus_marker_x, stylus_marker_y); |
| 415 | state->stylus_marker_x = AVIGO_SCREEN_WIDTH>>1; |
| 416 | state->stylus_marker_y = AVIGO_SCREEN_HEIGHT>>1; |
| 417 | state->stylus_press_x = 0; |
| 418 | state->stylus_press_y = 0; |
| 419 | avigo_vh_set_stylus_marker_position(machine, state->stylus_marker_x, state->stylus_marker_y); |
| 425 | 420 | |
| 426 | 421 | /* initialise settings for port data */ |
| 427 | 422 | for (i = 0; i < 4; i++) |
| 428 | 423 | { |
| 429 | | previous_input_port_data[i] = input_port_read(machine, linenames[i]); |
| 424 | state->previous_input_port_data[i] = input_port_read(machine, linenames[i]); |
| 430 | 425 | } |
| 431 | 426 | |
| 432 | | avigo_irq = 0; |
| 433 | | avigo_rom_bank_l = 0; |
| 434 | | avigo_rom_bank_h = 0; |
| 435 | | avigo_ram_bank_l = 0; |
| 436 | | avigo_ram_bank_h = 0; |
| 437 | | avigo_flash_at_0x4000 = 0; |
| 438 | | avigo_flash_at_0x8000 = 0; |
| 427 | state->irq = 0; |
| 428 | state->rom_bank_l = 0; |
| 429 | state->rom_bank_h = 0; |
| 430 | state->ram_bank_l = 0; |
| 431 | state->ram_bank_h = 0; |
| 432 | state->flash_at_0x4000 = 0; |
| 433 | state->flash_at_0x8000 = 0; |
| 439 | 434 | |
| 440 | 435 | /* clear */ |
| 441 | 436 | memset(messram_get_ptr(machine->device("messram")), 0, 128*1024); |
| 442 | 437 | |
| 443 | 438 | cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM)->set_direct_update_handler(direct_update_delegate_create_static(avigo_opbase_handler, *machine)); |
| 444 | 439 | |
| 445 | | addr = (unsigned char *)avigo_flashes[0]->space()->get_read_ptr(0); |
| 440 | addr = (unsigned char *)state->flashes[0]->space()->get_read_ptr(0); |
| 446 | 441 | avigo_setbank(machine, 0, addr, avigo_flash_0x0000_read_handler, avigo_flash_0x0000_write_handler); |
| 447 | 442 | |
| 448 | 443 | avigo_setbank(machine, 3, messram_get_ptr(machine->device("messram")), NULL, NULL); |
| r9648 | r9649 | |
| 469 | 464 | |
| 470 | 465 | static READ8_HANDLER(avigo_key_data_read_r) |
| 471 | 466 | { |
| 467 | avigo_state *state = space->machine->driver_data<avigo_state>(); |
| 472 | 468 | UINT8 data; |
| 473 | 469 | |
| 474 | 470 | data = 0x007; |
| 475 | 471 | |
| 476 | | if (avigo_key_line & 0x01) |
| 472 | if (state->key_line & 0x01) |
| 477 | 473 | { |
| 478 | 474 | data &= input_port_read(space->machine, "LINE0"); |
| 479 | 475 | } |
| 480 | 476 | |
| 481 | | if (avigo_key_line & 0x02) |
| 477 | if (state->key_line & 0x02) |
| 482 | 478 | { |
| 483 | 479 | data &= input_port_read(space->machine, "LINE1"); |
| 484 | 480 | } |
| 485 | 481 | |
| 486 | | if (avigo_key_line & 0x04) |
| 482 | if (state->key_line & 0x04) |
| 487 | 483 | { |
| 488 | 484 | data &= input_port_read(space->machine, "LINE2"); |
| 489 | 485 | |
| r9648 | r9649 | |
| 501 | 497 | /* bit 0 set for line 0, bit 1 set for line 1, bit 2 set for line 2 */ |
| 502 | 498 | static WRITE8_HANDLER(avigo_set_key_line_w) |
| 503 | 499 | { |
| 500 | avigo_state *state = space->machine->driver_data<avigo_state>(); |
| 504 | 501 | /* 5, 101, read back 3 */ |
| 505 | | avigo_key_line = data; |
| 502 | state->key_line = data; |
| 506 | 503 | } |
| 507 | 504 | |
| 508 | 505 | static READ8_HANDLER(avigo_irq_r) |
| 509 | 506 | { |
| 510 | | return avigo_irq; |
| 507 | avigo_state *state = space->machine->driver_data<avigo_state>(); |
| 508 | return state->irq; |
| 511 | 509 | } |
| 512 | 510 | |
| 513 | 511 | static WRITE8_HANDLER(avigo_irq_w) |
| 514 | 512 | { |
| 515 | | avigo_irq &= ~data; |
| 513 | avigo_state *state = space->machine->driver_data<avigo_state>(); |
| 514 | state->irq &= ~data; |
| 516 | 515 | |
| 517 | 516 | avigo_refresh_ints(space->machine); |
| 518 | 517 | } |
| 519 | 518 | |
| 520 | 519 | static READ8_HANDLER(avigo_rom_bank_l_r) |
| 521 | 520 | { |
| 522 | | return avigo_rom_bank_l; |
| 521 | avigo_state *state = space->machine->driver_data<avigo_state>(); |
| 522 | return state->rom_bank_l; |
| 523 | 523 | } |
| 524 | 524 | |
| 525 | 525 | static READ8_HANDLER(avigo_rom_bank_h_r) |
| 526 | 526 | { |
| 527 | | return avigo_rom_bank_h; |
| 527 | avigo_state *state = space->machine->driver_data<avigo_state>(); |
| 528 | return state->rom_bank_h; |
| 528 | 529 | } |
| 529 | 530 | |
| 530 | 531 | static READ8_HANDLER(avigo_ram_bank_l_r) |
| 531 | 532 | { |
| 532 | | return avigo_ram_bank_l; |
| 533 | avigo_state *state = space->machine->driver_data<avigo_state>(); |
| 534 | return state->ram_bank_l; |
| 533 | 535 | } |
| 534 | 536 | |
| 535 | 537 | static READ8_HANDLER(avigo_ram_bank_h_r) |
| 536 | 538 | { |
| 537 | | return avigo_ram_bank_h; |
| 539 | avigo_state *state = space->machine->driver_data<avigo_state>(); |
| 540 | return state->ram_bank_h; |
| 538 | 541 | } |
| 539 | 542 | |
| 540 | 543 | |
| 541 | 544 | |
| 542 | 545 | static WRITE8_HANDLER(avigo_rom_bank_l_w) |
| 543 | 546 | { |
| 547 | avigo_state *state = space->machine->driver_data<avigo_state>(); |
| 544 | 548 | logerror("rom bank l w: %04x\n", data); |
| 545 | 549 | |
| 546 | | avigo_rom_bank_l = data & 0x03f; |
| 550 | state->rom_bank_l = data & 0x03f; |
| 547 | 551 | |
| 548 | 552 | avigo_refresh_memory(space->machine); |
| 549 | 553 | } |
| 550 | 554 | |
| 551 | 555 | static WRITE8_HANDLER(avigo_rom_bank_h_w) |
| 552 | 556 | { |
| 557 | avigo_state *state = space->machine->driver_data<avigo_state>(); |
| 553 | 558 | logerror("rom bank h w: %04x\n", data); |
| 554 | 559 | |
| 555 | 560 | |
| r9648 | r9649 | |
| 562 | 567 | |
| 563 | 568 | |
| 564 | 569 | */ |
| 565 | | avigo_rom_bank_h = data; |
| 570 | state->rom_bank_h = data; |
| 566 | 571 | |
| 567 | 572 | |
| 568 | 573 | avigo_refresh_memory(space->machine); |
| r9648 | r9649 | |
| 570 | 575 | |
| 571 | 576 | static WRITE8_HANDLER(avigo_ram_bank_l_w) |
| 572 | 577 | { |
| 578 | avigo_state *state = space->machine->driver_data<avigo_state>(); |
| 573 | 579 | logerror("ram bank l w: %04x\n", data); |
| 574 | 580 | |
| 575 | | avigo_ram_bank_l = data & 0x03f; |
| 581 | state->ram_bank_l = data & 0x03f; |
| 576 | 582 | |
| 577 | 583 | avigo_refresh_memory(space->machine); |
| 578 | 584 | } |
| 579 | 585 | |
| 580 | 586 | static WRITE8_HANDLER(avigo_ram_bank_h_w) |
| 581 | 587 | { |
| 588 | avigo_state *state = space->machine->driver_data<avigo_state>(); |
| 582 | 589 | logerror("ram bank h w: %04x\n", data); |
| 583 | 590 | |
| 584 | | avigo_ram_bank_h = data; |
| 591 | state->ram_bank_h = data; |
| 585 | 592 | |
| 586 | 593 | avigo_refresh_memory(space->machine); |
| 587 | 594 | } |
| 588 | 595 | |
| 589 | 596 | static READ8_HANDLER(avigo_ad_control_status_r) |
| 590 | 597 | { |
| 591 | | logerror("avigo ad control read %02x\n", (int) avigo_ad_control_status); |
| 592 | | return avigo_ad_control_status; |
| 598 | avigo_state *state = space->machine->driver_data<avigo_state>(); |
| 599 | logerror("avigo ad control read %02x\n", (int) state->ad_control_status); |
| 600 | return state->ad_control_status; |
| 593 | 601 | } |
| 594 | 602 | |
| 595 | | static unsigned int avigo_ad_value; |
| 596 | 603 | |
| 597 | 604 | static WRITE8_HANDLER(avigo_ad_control_status_w) |
| 598 | 605 | { |
| 606 | avigo_state *state = space->machine->driver_data<avigo_state>(); |
| 599 | 607 | logerror("avigo ad control w %02x\n",data); |
| 600 | 608 | |
| 601 | 609 | if ((data & 0x070)==0x070) |
| r9648 | r9649 | |
| 605 | 613 | if ((data & 0x08)!=0) |
| 606 | 614 | { |
| 607 | 615 | logerror("a/d select x coordinate\n"); |
| 608 | | logerror("x coord: %d\n",stylus_press_x); |
| 616 | logerror("x coord: %d\n",state->stylus_press_x); |
| 609 | 617 | |
| 610 | 618 | /* on screen range 0x060->0x03a0 */ |
| 611 | 619 | /* 832 is on-screen range */ |
| 612 | 620 | /* 5.2 a/d units per pixel */ |
| 613 | 621 | |
| 614 | | if (stylus_press_x!=0) |
| 622 | if (state->stylus_press_x!=0) |
| 615 | 623 | { |
| 616 | 624 | /* this might not be totally accurate because hitable screen |
| 617 | 625 | area may include the border around the screen! */ |
| 618 | | avigo_ad_value = ((int)(stylus_press_x * 5.2f))+0x060; |
| 619 | | avigo_ad_value &= 0x03fc; |
| 626 | state->ad_value = ((int)(state->stylus_press_x * 5.2f))+0x060; |
| 627 | state->ad_value &= 0x03fc; |
| 620 | 628 | } |
| 621 | 629 | else |
| 622 | 630 | { |
| 623 | | avigo_ad_value = 0; |
| 631 | state->ad_value = 0; |
| 624 | 632 | } |
| 625 | 633 | |
| 626 | | logerror("ad value: %d\n",avigo_ad_value); |
| 627 | | stylus_press_x = 0; |
| 634 | logerror("ad value: %d\n",state->ad_value); |
| 635 | state->stylus_press_x = 0; |
| 628 | 636 | |
| 629 | 637 | } |
| 630 | 638 | else |
| r9648 | r9649 | |
| 645 | 653 | /* 3.25 * 1024.00 = 315.07 */ |
| 646 | 654 | |
| 647 | 655 | logerror("a/d select y coordinate\n"); |
| 648 | | logerror("y coord: %d\n",stylus_press_y); |
| 656 | logerror("y coord: %d\n",state->stylus_press_y); |
| 649 | 657 | |
| 650 | | if (stylus_press_y!=0) |
| 658 | if (state->stylus_press_y!=0) |
| 651 | 659 | { |
| 652 | | avigo_ad_value = 1024 - (((stylus_press_y)*3.25f) + 0x040); |
| 660 | state->ad_value = 1024 - (((state->stylus_press_y)*3.25f) + 0x040); |
| 653 | 661 | } |
| 654 | 662 | else |
| 655 | 663 | { |
| 656 | | avigo_ad_value = 0; |
| 664 | state->ad_value = 0; |
| 657 | 665 | } |
| 658 | 666 | |
| 659 | | logerror("ad value: %d\n",avigo_ad_value); |
| 660 | | stylus_press_y = 0; |
| 667 | logerror("ad value: %d\n",state->ad_value); |
| 668 | state->stylus_press_y = 0; |
| 661 | 669 | } |
| 662 | 670 | } |
| 663 | 671 | |
| 664 | 672 | /* bit 0: 1 if a/d complete, 0 if a/d not complete */ |
| 665 | | avigo_ad_control_status = data | 1; |
| 673 | state->ad_control_status = data | 1; |
| 666 | 674 | } |
| 667 | 675 | |
| 668 | 676 | static READ8_HANDLER(avigo_ad_data_r) |
| 669 | 677 | { |
| 678 | avigo_state *state = space->machine->driver_data<avigo_state>(); |
| 670 | 679 | unsigned char data; |
| 671 | 680 | |
| 672 | 681 | data = 0; |
| r9648 | r9649 | |
| 676 | 685 | /* status AND 11110111 */ |
| 677 | 686 | /* status OR 01110000 -> C20F */ |
| 678 | 687 | |
| 679 | | switch (avigo_ad_control_status & 0x078) |
| 688 | switch (state->ad_control_status & 0x078) |
| 680 | 689 | { |
| 681 | 690 | /* x1110xxx */ |
| 682 | 691 | /* read upper 4 bits of 10 bit A/D number */ |
| r9648 | r9649 | |
| 688 | 697 | /* bit 3 must be 1. bit 2 can have any value */ |
| 689 | 698 | |
| 690 | 699 | logerror("a/d read upper 4 bits\n"); |
| 691 | | data = ((avigo_ad_value>>6) & 0x0f)<<4; |
| 700 | data = ((state->ad_value>>6) & 0x0f)<<4; |
| 692 | 701 | data |= 8; |
| 693 | 702 | } |
| 694 | 703 | break; |
| r9648 | r9649 | |
| 700 | 709 | /* bit 0 must be 1, bit 1 must be 0 */ |
| 701 | 710 | |
| 702 | 711 | logerror("a/d lower 6-bits\n"); |
| 703 | | data = ((avigo_ad_value & 0x03f)<<2); |
| 712 | data = ((state->ad_value & 0x03f)<<2); |
| 704 | 713 | data |= 1; |
| 705 | 714 | } |
| 706 | 715 | break; |
| r9648 | r9649 | |
| 769 | 778 | |
| 770 | 779 | static WRITE8_HANDLER(avigo_speaker_w) |
| 771 | 780 | { |
| 781 | avigo_state *state = space->machine->driver_data<avigo_state>(); |
| 772 | 782 | running_device *speaker = space->machine->device("speaker"); |
| 773 | 783 | UINT8 previous_speaker; |
| 774 | 784 | |
| 775 | | previous_speaker = avigo_speaker_data; |
| 776 | | avigo_speaker_data = data; |
| 785 | previous_speaker = state->speaker_data; |
| 786 | state->speaker_data = data; |
| 777 | 787 | |
| 778 | 788 | /* changed state? */ |
| 779 | | if (((data^avigo_speaker_data) & (1<<3))!=0) |
| 789 | if (((data^state->speaker_data) & (1<<3))!=0) |
| 780 | 790 | { |
| 781 | 791 | /* DAC output state */ |
| 782 | 792 | speaker_level_w(speaker,(data>>3) & 0x01); |
| r9648 | r9649 | |
| 949 | 959 | GFXDECODE_END |
| 950 | 960 | |
| 951 | 961 | |
| 952 | | static MACHINE_CONFIG_START( avigo, driver_device ) |
| 962 | static MACHINE_CONFIG_START( avigo, avigo_state ) |
| 953 | 963 | /* basic machine hardware */ |
| 954 | 964 | MDRV_CPU_ADD("maincpu", Z80, 4000000) |
| 955 | 965 | MDRV_CPU_PROGRAM_MAP(avigo_mem) |
| r9648 | r9649 | |
| 961 | 971 | |
| 962 | 972 | MDRV_NS16550_ADD( "ns16550", avigo_com_interface ) |
| 963 | 973 | |
| 964 | | /* video hardware */ |
| 974 | /* video hardware */ |
| 965 | 975 | MDRV_SCREEN_ADD("screen", LCD) |
| 966 | 976 | MDRV_SCREEN_REFRESH_RATE(50) |
| 967 | 977 | MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) /* not accurate */ |