trunk/src/emu/bus/nes_ctrl/suborkey.c
| r243230 | r243231 | |
| 22 | 22 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_G) PORT_CHAR('G') |
| 23 | 23 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F) PORT_CHAR('F') |
| 24 | 24 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_C) PORT_CHAR('C') |
| 25 | | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F2) PORT_CHAR(UCHAR_MAMEKEY(F2)) |
| 25 | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F2) PORT_CHAR(UCHAR_MAMEKEY(F2)) |
| 26 | 26 | PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_E) PORT_CHAR('E') |
| 27 | 27 | PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_5) PORT_CHAR('5') |
| 28 | 28 | PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_V) PORT_CHAR('V') |
| r243230 | r243231 | |
| 32 | 32 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_D) PORT_CHAR('D') |
| 33 | 33 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_S) PORT_CHAR('S') |
| 34 | 34 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_END) PORT_CHAR(UCHAR_MAMEKEY(END)) |
| 35 | | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F1) PORT_CHAR(UCHAR_MAMEKEY(F1)) |
| 35 | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F1) PORT_CHAR(UCHAR_MAMEKEY(F1)) |
| 36 | 36 | PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_W) PORT_CHAR('W') |
| 37 | 37 | PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_3) PORT_CHAR('3') |
| 38 | 38 | PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_X) PORT_CHAR('X') |
| 39 | 39 | |
| 40 | 40 | PORT_START("SUBOR.2") |
| 41 | | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_INSERT) PORT_CHAR(UCHAR_MAMEKEY(INSERT)) |
| 42 | | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_BACKSPACE) PORT_CHAR(8) |
| 43 | | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("NEXT") |
| 41 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_INSERT) PORT_CHAR(UCHAR_MAMEKEY(INSERT)) |
| 42 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_BACKSPACE) PORT_CHAR(8) |
| 43 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("NEXT") |
| 44 | 44 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_RIGHT) PORT_CHAR(UCHAR_MAMEKEY(RIGHT)) |
| 45 | | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F8) PORT_CHAR(UCHAR_MAMEKEY(F8)) |
| 46 | | PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("PRIOR") |
| 45 | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F8) PORT_CHAR(UCHAR_MAMEKEY(F8)) |
| 46 | PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("PRIOR") |
| 47 | 47 | PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_DEL) PORT_CHAR(UCHAR_MAMEKEY(DEL)) |
| 48 | | PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_HOME) PORT_CHAR(UCHAR_MAMEKEY(HOME)) |
| 48 | PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_HOME) PORT_CHAR(UCHAR_MAMEKEY(HOME)) |
| 49 | 49 | |
| 50 | 50 | PORT_START("SUBOR.3") |
| 51 | 51 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_9) PORT_CHAR('9') |
| 52 | 52 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_I) PORT_CHAR('I') |
| 53 | 53 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_L) PORT_CHAR('L') |
| 54 | | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_COMMA) PORT_CHAR(',') |
| 55 | | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F5) PORT_CHAR(UCHAR_MAMEKEY(F5)) |
| 54 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_COMMA) PORT_CHAR(',') |
| 55 | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F5) PORT_CHAR(UCHAR_MAMEKEY(F5)) |
| 56 | 56 | PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_O) PORT_CHAR('O') |
| 57 | 57 | PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_0) PORT_CHAR('0') |
| 58 | 58 | PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_STOP) PORT_CHAR('.') |
| 59 | 59 | |
| 60 | 60 | PORT_START("SUBOR.4") |
| 61 | | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_CLOSEBRACE) PORT_CHAR(']') |
| 62 | | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_ENTER) PORT_CHAR(13) |
| 63 | | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_UP) PORT_CHAR(UCHAR_MAMEKEY(UP)) |
| 64 | | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_LEFT) PORT_CHAR(UCHAR_MAMEKEY(LEFT)) |
| 65 | | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F7) PORT_CHAR(UCHAR_MAMEKEY(F7)) |
| 66 | | PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_OPENBRACE) PORT_CHAR('[') |
| 67 | | PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_BACKSLASH) PORT_CHAR('\\') |
| 68 | | PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_DOWN) PORT_CHAR(UCHAR_MAMEKEY(DOWN)) |
| 61 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_CLOSEBRACE) PORT_CHAR(']') |
| 62 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_ENTER) PORT_CHAR(13) |
| 63 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_UP) PORT_CHAR(UCHAR_MAMEKEY(UP)) |
| 64 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_LEFT) PORT_CHAR(UCHAR_MAMEKEY(LEFT)) |
| 65 | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F7) PORT_CHAR(UCHAR_MAMEKEY(F7)) |
| 66 | PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_OPENBRACE) PORT_CHAR('[') |
| 67 | PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_BACKSLASH) PORT_CHAR('\\') |
| 68 | PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_DOWN) PORT_CHAR(UCHAR_MAMEKEY(DOWN)) |
| 69 | 69 | |
| 70 | 70 | PORT_START("SUBOR.5") |
| 71 | 71 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_Q) PORT_CHAR('Q') |
| 72 | | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_CAPSLOCK) PORT_CHAR(UCHAR_MAMEKEY(CAPSLOCK)) |
| 72 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_CAPSLOCK) PORT_CHAR(UCHAR_MAMEKEY(CAPSLOCK)) |
| 73 | 73 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_Z) PORT_CHAR('Z') |
| 74 | 74 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_TAB) PORT_CHAR('\t') |
| 75 | | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_ESC) PORT_CHAR(UCHAR_MAMEKEY(ESC)) |
| 75 | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_ESC) PORT_CHAR(UCHAR_MAMEKEY(ESC)) |
| 76 | 76 | PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_A) PORT_CHAR('A') |
| 77 | 77 | PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_1) PORT_CHAR('1') |
| 78 | | PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_LCONTROL) PORT_CHAR(UCHAR_SHIFT_2) |
| 78 | PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_LCONTROL) PORT_CHAR(UCHAR_SHIFT_2) |
| 79 | 79 | |
| 80 | 80 | PORT_START("SUBOR.6") |
| 81 | 81 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_7) PORT_CHAR('7') |
| 82 | 82 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_Y) PORT_CHAR('Y') |
| 83 | 83 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_K) PORT_CHAR('K') |
| 84 | 84 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_M) PORT_CHAR('M') |
| 85 | | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F4) PORT_CHAR(UCHAR_MAMEKEY(F4)) |
| 85 | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F4) PORT_CHAR(UCHAR_MAMEKEY(F4)) |
| 86 | 86 | PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_U) PORT_CHAR('U') |
| 87 | 87 | PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_8) PORT_CHAR('8') |
| 88 | 88 | PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_J) PORT_CHAR('J') |
| r243230 | r243231 | |
| 92 | 92 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_COLON) PORT_CHAR(':') |
| 93 | 93 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_QUOTE) PORT_CHAR('\'') |
| 94 | 94 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_SLASH) PORT_CHAR('/') |
| 95 | | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F6) PORT_CHAR(UCHAR_MAMEKEY(F6)) |
| 95 | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F6) PORT_CHAR(UCHAR_MAMEKEY(F6)) |
| 96 | 96 | PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_P) PORT_CHAR('P') |
| 97 | 97 | PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_EQUALS) PORT_CHAR('=') |
| 98 | | PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_LSHIFT) PORT_CHAR(UCHAR_SHIFT_1) |
| 98 | PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_LSHIFT) PORT_CHAR(UCHAR_SHIFT_1) |
| 99 | 99 | |
| 100 | 100 | PORT_START("SUBOR.8") |
| 101 | 101 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_T) PORT_CHAR('T') |
| 102 | 102 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_H) PORT_CHAR('H') |
| 103 | 103 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_N) PORT_CHAR('N') |
| 104 | 104 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_SPACE) PORT_CHAR(' ') |
| 105 | | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F3) PORT_CHAR(UCHAR_MAMEKEY(F3)) |
| 105 | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F3) PORT_CHAR(UCHAR_MAMEKEY(F3)) |
| 106 | 106 | PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_R) PORT_CHAR('R') |
| 107 | 107 | PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_6) PORT_CHAR('6') |
| 108 | 108 | PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_B) PORT_CHAR('B') |
| r243230 | r243231 | |
| 111 | 111 | PORT_BIT( 0xff, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| 112 | 112 | |
| 113 | 113 | PORT_START("SUBOR.10") |
| 114 | | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("LMENU") |
| 114 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("LMENU") |
| 115 | 115 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_4_PAD) PORT_CHAR(UCHAR_MAMEKEY(4_PAD)) |
| 116 | 116 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_7_PAD) PORT_CHAR(UCHAR_MAMEKEY(7_PAD)) |
| 117 | | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F11) PORT_CHAR(UCHAR_MAMEKEY(F11)) |
| 118 | | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F12) PORT_CHAR(UCHAR_MAMEKEY(F12)) |
| 117 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F11) PORT_CHAR(UCHAR_MAMEKEY(F11)) |
| 118 | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F12) PORT_CHAR(UCHAR_MAMEKEY(F12)) |
| 119 | 119 | PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_1_PAD) PORT_CHAR(UCHAR_MAMEKEY(1_PAD)) |
| 120 | 120 | PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_2_PAD) PORT_CHAR(UCHAR_MAMEKEY(2_PAD)) |
| 121 | 121 | PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_8_PAD) PORT_CHAR(UCHAR_MAMEKEY(8_PAD)) |
| r243230 | r243231 | |
| 124 | 124 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_MINUS_PAD)PORT_CHAR(UCHAR_MAMEKEY(MINUS_PAD)) |
| 125 | 125 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_PLUS_PAD) PORT_CHAR(UCHAR_MAMEKEY(PLUS_PAD)) |
| 126 | 126 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_ASTERISK) PORT_CHAR(UCHAR_MAMEKEY(ASTERISK)) |
| 127 | | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_9_PAD) PORT_CHAR(UCHAR_MAMEKEY(9_PAD)) |
| 128 | | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F10) PORT_CHAR(UCHAR_MAMEKEY(F10)) |
| 129 | | PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_5_PAD) PORT_CHAR(UCHAR_MAMEKEY(5_PAD)) |
| 127 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_9_PAD) PORT_CHAR(UCHAR_MAMEKEY(9_PAD)) |
| 128 | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F10) PORT_CHAR(UCHAR_MAMEKEY(F10)) |
| 129 | PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_5_PAD) PORT_CHAR(UCHAR_MAMEKEY(5_PAD)) |
| 130 | 130 | PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_SLASH_PAD)PORT_CHAR(UCHAR_MAMEKEY(SLASH_PAD)) |
| 131 | | PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_NUMLOCK) PORT_CHAR(UCHAR_MAMEKEY(NUMLOCK)) |
| 131 | PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_NUMLOCK) PORT_CHAR(UCHAR_MAMEKEY(NUMLOCK)) |
| 132 | 132 | |
| 133 | 133 | PORT_START("SUBOR.12") |
| 134 | | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_TILDE) PORT_CHAR('`') |
| 134 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_TILDE) PORT_CHAR('`') |
| 135 | 135 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_6_PAD) PORT_CHAR(UCHAR_MAMEKEY(6_PAD)) |
| 136 | | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("PAUSE") |
| 137 | | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("SPACE2") |
| 138 | | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F9) PORT_CHAR(UCHAR_MAMEKEY(F9)) |
| 136 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("PAUSE") |
| 137 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("SPACE2") |
| 138 | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F9) PORT_CHAR(UCHAR_MAMEKEY(F9)) |
| 139 | 139 | PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_3_PAD) PORT_CHAR(UCHAR_MAMEKEY(3_PAD)) |
| 140 | | PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Keypad .") PORT_CODE(KEYCODE_DEL_PAD) |
| 140 | PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Keypad .") PORT_CODE(KEYCODE_DEL_PAD) |
| 141 | 141 | PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_0_PAD) PORT_CHAR(UCHAR_MAMEKEY(0_PAD)) |
| 142 | 142 | INPUT_PORTS_END |
| 143 | 143 | |
| r243230 | r243231 | |
| 198 | 198 | UINT8 nes_suborkey_device::read_exp(offs_t offset) |
| 199 | 199 | { |
| 200 | 200 | UINT8 ret = 0; |
| 201 | | if (offset == 1) //$4017 |
| 201 | if (offset == 1) //$4017 |
| 202 | 202 | { |
| 203 | 203 | // Subor Keyboard: rows of the keyboard matrix are read 4-bits at time and returned as bit1->bit4 |
| 204 | 204 | if (m_fck_scan < 13) |
| r243230 | r243231 | |
| 206 | 206 | else |
| 207 | 207 | ret |= 0x1e; |
| 208 | 208 | } |
| 209 | | |
| 209 | |
| 210 | 210 | return ret; |
| 211 | 211 | } |
| 212 | 212 | |
| r243230 | r243231 | |
| 218 | 218 | { |
| 219 | 219 | if (BIT(data, 2)) // keyboard active |
| 220 | 220 | { |
| 221 | | UINT8 out = BIT(data, 1); // scan |
| 221 | UINT8 out = BIT(data, 1); // scan |
| 222 | 222 | if (m_fck_mode && !out && ++m_fck_scan > 12) |
| 223 | 223 | m_fck_scan = 0; |
| 224 | | |
| 224 | |
| 225 | 225 | m_fck_mode = out; // access lower or upper 4 bits |
| 226 | | |
| 226 | |
| 227 | 227 | if (BIT(data, 0)) // reset |
| 228 | 228 | m_fck_scan = 0; |
| 229 | 229 | } |
trunk/src/mame/audio/mario.c
| r243230 | r243231 | |
| 46 | 46 | /* ---------------------------------------------------------------------- */ |
| 47 | 47 | static NETLIST_START(nl_mario_snd0) |
| 48 | 48 | |
| 49 | | RES(R17, RES_K(27)) /* 20 according to parts list */ |
| 50 | | /* 27 verified, 30K in schematics */ |
| 51 | | CAP(C14, CAP_U(4.7)) /* verified */ |
| 49 | RES(R17, RES_K(27)) /* 20 according to parts list */ |
| 50 | /* 27 verified, 30K in schematics */ |
| 51 | CAP(C14, CAP_U(4.7)) /* verified */ |
| 52 | 52 | |
| 53 | | TTL_74123(2H_A) |
| 54 | | NET_C(2H_A.VCC, V5) |
| 55 | | NET_C(2H_A.GND, GND) |
| 56 | | NET_C(SOUND0.Q, 2H_A.B) |
| 57 | | NET_C(GND, 2H_A.A) |
| 58 | | NET_C(2H_A.CLRQ, ttlhigh) /* NOT IN SCHEMATICS */ |
| 59 | | DIODE(D1, "1N4148") /* FIXME: try to identify */ |
| 60 | | TTL_7404_INVERT(1H_A, 2H_A.QQ) |
| 61 | | NET_C(R17.1, V5) |
| 62 | | NET_C(R17.2, D1.A, C14.1) |
| 63 | | NET_C(D1.K, 2H_A.RC) |
| 64 | | NET_C(C14.2, 2H_A.C) |
| 53 | TTL_74123(2H_A) |
| 54 | NET_C(2H_A.VCC, V5) |
| 55 | NET_C(2H_A.GND, GND) |
| 56 | NET_C(SOUND0.Q, 2H_A.B) |
| 57 | NET_C(GND, 2H_A.A) |
| 58 | NET_C(2H_A.CLRQ, ttlhigh) /* NOT IN SCHEMATICS */ |
| 59 | DIODE(D1, "1N4148") /* FIXME: try to identify */ |
| 60 | TTL_7404_INVERT(1H_A, 2H_A.QQ) |
| 61 | NET_C(R17.1, V5) |
| 62 | NET_C(R17.2, D1.A, C14.1) |
| 63 | NET_C(D1.K, 2H_A.RC) |
| 64 | NET_C(C14.2, 2H_A.C) |
| 65 | 65 | |
| 66 | | RES(R6, RES_K(4.7)) /* verified */ |
| 67 | | CAP(C3, CAP_U(10)) /* verified */ |
| 66 | RES(R6, RES_K(4.7)) /* verified */ |
| 67 | CAP(C3, CAP_U(10)) /* verified */ |
| 68 | 68 | |
| 69 | | NET_C(1H_A.Q, R6.1) |
| 70 | | NET_C(R6.2, C3.1, 1J_A.FC) |
| 71 | | NET_C(R6.2, 2J_A.FC) |
| 72 | | NET_C(C3.2, GND) |
| 69 | NET_C(1H_A.Q, R6.1) |
| 70 | NET_C(R6.2, C3.1, 1J_A.FC) |
| 71 | NET_C(R6.2, 2J_A.FC) |
| 72 | NET_C(C3.2, GND) |
| 73 | 73 | |
| 74 | | //#define MR_C6 CAP_N(3.9) /* verified */ |
| 74 | //#define MR_C6 CAP_N(3.9) /* verified */ |
| 75 | 75 | |
| 76 | | SN74LS629(1J_A, CAP_N(3.9)) |
| 77 | | NET_C(1J_A.RNG, V5) |
| 78 | | NET_C(1J_A.ENQ, ttllow) |
| 79 | | NET_C(GND, 1J_A.GND) |
| 76 | SN74LS629(1J_A, CAP_N(3.9)) |
| 77 | NET_C(1J_A.RNG, V5) |
| 78 | NET_C(1J_A.ENQ, ttllow) |
| 79 | NET_C(GND, 1J_A.GND) |
| 80 | 80 | |
| 81 | | //#define MR_C17 CAP_N(22) /* verified */ |
| 81 | //#define MR_C17 CAP_N(22) /* verified */ |
| 82 | 82 | |
| 83 | | SN74LS629(2J_A, CAP_N(22)) |
| 84 | | NET_C(2J_A.RNG, V5) |
| 85 | | NET_C(2J_A.ENQ, ttllow) |
| 86 | | NET_C(GND, 2J_A.GND) |
| 83 | SN74LS629(2J_A, CAP_N(22)) |
| 84 | NET_C(2J_A.RNG, V5) |
| 85 | NET_C(2J_A.ENQ, ttllow) |
| 86 | NET_C(GND, 2J_A.GND) |
| 87 | 87 | |
| 88 | | TTL_7486_XOR(1K_A, 1J_A.Y, 2J_A.Y) |
| 89 | | TTL_7408_AND(2K_A, 2H_A.Q, 1K_A) |
| 88 | TTL_7486_XOR(1K_A, 1J_A.Y, 2J_A.Y) |
| 89 | TTL_7408_AND(2K_A, 2H_A.Q, 1K_A) |
| 90 | 90 | NETLIST_END() |
| 91 | 91 | |
| 92 | 92 | /* ---------------------------------------------------------------------- */ |
| r243230 | r243231 | |
| 96 | 96 | // FIXME: Diodes are 1S953 |
| 97 | 97 | static NETLIST_START(nl_mario_snd7) |
| 98 | 98 | |
| 99 | | RES(R61, RES_K(47)) |
| 100 | | CAP(C41, CAP_U(4.7)) /* verified */ |
| 99 | RES(R61, RES_K(47)) |
| 100 | CAP(C41, CAP_U(4.7)) /* verified */ |
| 101 | 101 | |
| 102 | | TTL_74123(4L_A) |
| 103 | | NET_C(4L_A.VCC, V5) |
| 104 | | NET_C(4L_A.GND, GND) |
| 105 | | NET_C(SOUND7.Q, 4L_A.B) |
| 106 | | NET_C(GND, 4L_A.A) |
| 107 | | NET_C(4L_A.CLRQ, ttlhigh) /* NOT IN SCHEMATICS */ |
| 108 | | DIODE(D10, "1N4148") /* FIXME: try to identify */ |
| 109 | | TTL_7404_INVERT(4J_A, 4L_A.Q) |
| 110 | | NET_C(R61.1, V5) |
| 111 | | NET_C(R61.2, D10.A, C41.1) |
| 112 | | NET_C(D10.K, 4L_A.RC) |
| 113 | | NET_C(C41.2, 4L_A.C) |
| 102 | TTL_74123(4L_A) |
| 103 | NET_C(4L_A.VCC, V5) |
| 104 | NET_C(4L_A.GND, GND) |
| 105 | NET_C(SOUND7.Q, 4L_A.B) |
| 106 | NET_C(GND, 4L_A.A) |
| 107 | NET_C(4L_A.CLRQ, ttlhigh) /* NOT IN SCHEMATICS */ |
| 108 | DIODE(D10, "1N4148") /* FIXME: try to identify */ |
| 109 | TTL_7404_INVERT(4J_A, 4L_A.Q) |
| 110 | NET_C(R61.1, V5) |
| 111 | NET_C(R61.2, D10.A, C41.1) |
| 112 | NET_C(D10.K, 4L_A.RC) |
| 113 | NET_C(C41.2, 4L_A.C) |
| 114 | 114 | |
| 115 | | RES(R65, RES_K(10)) |
| 116 | | CAP(C44, CAP_U(3.3)) /* verified */ |
| 115 | RES(R65, RES_K(10)) |
| 116 | CAP(C44, CAP_U(3.3)) /* verified */ |
| 117 | 117 | |
| 118 | | SN74LS629(4K_A, CAP_U(0.022)) |
| 119 | | NET_C(4K_A.RNG, V5) |
| 120 | | NET_C(4K_A.ENQ, ttllow) |
| 121 | | NET_C(GND, 4K_A.GND) |
| 122 | | NET_C(R65.1, 4J_A.Q) |
| 123 | | NET_C(R65.2, 4K_A.FC, C44.1) |
| 124 | | NET_C(C44.2, GND) |
| 118 | SN74LS629(4K_A, CAP_U(0.022)) |
| 119 | NET_C(4K_A.RNG, V5) |
| 120 | NET_C(4K_A.ENQ, ttllow) |
| 121 | NET_C(GND, 4K_A.GND) |
| 122 | NET_C(R65.1, 4J_A.Q) |
| 123 | NET_C(R65.2, 4K_A.FC, C44.1) |
| 124 | NET_C(C44.2, GND) |
| 125 | 125 | |
| 126 | | CD_4020(3H, 4K_B.Y, ttllow, V5, GND) |
| 127 | | TTL_7404_INVERT(4J_B, 3H.Q12) |
| 126 | CD_4020(3H, 4K_B.Y, ttllow, V5, GND) |
| 127 | TTL_7404_INVERT(4J_B, 3H.Q12) |
| 128 | 128 | |
| 129 | | RES(R64, RES_K(20)) |
| 130 | | CAP(C43, CAP_U(3.3)) /* verified */ |
| 129 | RES(R64, RES_K(20)) |
| 130 | CAP(C43, CAP_U(3.3)) /* verified */ |
| 131 | 131 | |
| 132 | | SN74LS629(4K_B, CAP_U(0.0047)) |
| 133 | | NET_C(4K_B.RNG, V5) |
| 134 | | NET_C(4K_B.ENQ, ttllow) |
| 135 | | NET_C(GND, 4K_B.GND) |
| 136 | | NET_C(R64.1, 4J_B.Q) |
| 137 | | NET_C(R64.2, 4K_B.FC, C43.1) |
| 138 | | NET_C(C43.2, GND) |
| 132 | SN74LS629(4K_B, CAP_U(0.0047)) |
| 133 | NET_C(4K_B.RNG, V5) |
| 134 | NET_C(4K_B.ENQ, ttllow) |
| 135 | NET_C(GND, 4K_B.GND) |
| 136 | NET_C(R64.1, 4J_B.Q) |
| 137 | NET_C(R64.2, 4K_B.FC, C43.1) |
| 138 | NET_C(C43.2, GND) |
| 139 | 139 | |
| 140 | | TTL_7486_XOR(1K_C, 3H.Q4, 4K_A.Y) |
| 141 | | TTL_7408_AND(2K_C, 4L_A.Q, 1K_C) |
| 140 | TTL_7486_XOR(1K_C, 3H.Q4, 4K_A.Y) |
| 141 | TTL_7408_AND(2K_C, 4L_A.Q, 1K_C) |
| 142 | 142 | |
| 143 | 143 | NETLIST_END() |
| 144 | 144 | |
| r243230 | r243231 | |
| 146 | 146 | /* DAC sound */ |
| 147 | 147 | /* ---------------------------------------------------------------------- */ |
| 148 | 148 | static NETLIST_START(nl_mario_dac) |
| 149 | | RES(R34, RES_M(2)) |
| 150 | | RES(R35, RES_M(1)) |
| 151 | | RES(R36, RES_M(1.8)) |
| 152 | | LM3900(3M_1) |
| 153 | | NET_C(3M_1.VM, GND) |
| 154 | | NET_C(3M_1.VP, V5) |
| 149 | RES(R34, RES_M(2)) |
| 150 | RES(R35, RES_M(1)) |
| 151 | RES(R36, RES_M(1.8)) |
| 152 | LM3900(3M_1) |
| 153 | NET_C(3M_1.VM, GND) |
| 154 | NET_C(3M_1.VP, V5) |
| 155 | 155 | |
| 156 | | NET_C(DAC.VOUT, R34.1) |
| 157 | | NET_C(3M_1.MINUS, R34.2, R35.2) |
| 158 | | NET_C(3M_1.OUT, R35.1) |
| 159 | | NET_C(3M_1.PLUS, R36.1) |
| 160 | | NET_C(R36.2, GND) |
| 156 | NET_C(DAC.VOUT, R34.1) |
| 157 | NET_C(3M_1.MINUS, R34.2, R35.2) |
| 158 | NET_C(3M_1.OUT, R35.1) |
| 159 | NET_C(3M_1.PLUS, R36.1) |
| 160 | NET_C(R36.2, GND) |
| 161 | 161 | |
| 162 | | RES(R21, RES_M(1.8)) |
| 163 | | RES(R23, RES_K(10)) |
| 164 | | RES(R25, RES_K(10)) |
| 165 | | RES(R37, RES_K(750)) |
| 166 | | RES(R38, RES_K(360)) |
| 167 | | RES(R39, RES_K(750)) |
| 162 | RES(R21, RES_M(1.8)) |
| 163 | RES(R23, RES_K(10)) |
| 164 | RES(R25, RES_K(10)) |
| 165 | RES(R37, RES_K(750)) |
| 166 | RES(R38, RES_K(360)) |
| 167 | RES(R39, RES_K(750)) |
| 168 | 168 | |
| 169 | | CAP(C18, CAP_P(100)) |
| 170 | | CAP(C19, CAP_U(10)) |
| 171 | | CAP(C20, CAP_U(1)) |
| 172 | | CAP(C30, CAP_P(100)) |
| 169 | CAP(C18, CAP_P(100)) |
| 170 | CAP(C19, CAP_U(10)) |
| 171 | CAP(C20, CAP_U(1)) |
| 172 | CAP(C30, CAP_P(100)) |
| 173 | 173 | |
| 174 | | LM3900(3M_2) |
| 175 | | NET_C(3M_2.VM, GND) |
| 176 | | NET_C(3M_2.VP, V5) |
| 174 | LM3900(3M_2) |
| 175 | NET_C(3M_2.VM, GND) |
| 176 | NET_C(3M_2.VP, V5) |
| 177 | 177 | |
| 178 | | NET_C(R35.1, C20.1) |
| 179 | | NET_C(C20.2, R37.1) |
| 180 | | NET_C(R37.2, R38.2, C18.1, R39.2) |
| 178 | NET_C(R35.1, C20.1) |
| 179 | NET_C(C20.2, R37.1) |
| 180 | NET_C(R37.2, R38.2, C18.1, R39.2) |
| 181 | 181 | |
| 182 | | NET_C(C18.2, GND) |
| 183 | | NET_C(R38.1, C30.2, 3M_2.MINUS) |
| 184 | | NET_C(3M_2.OUT, R39.1, C30.1) |
| 182 | NET_C(C18.2, GND) |
| 183 | NET_C(R38.1, C30.2, 3M_2.MINUS) |
| 184 | NET_C(3M_2.OUT, R39.1, C30.1) |
| 185 | 185 | |
| 186 | | NET_C(R21.1, 3M_2.PLUS) |
| 187 | | NET_C(R21.2, C19.1, R25.2, R23.1) |
| 188 | | NET_C(C19.2, R23.2, GND) |
| 189 | | NET_C(R25.1, V5) |
| 186 | NET_C(R21.1, 3M_2.PLUS) |
| 187 | NET_C(R21.2, C19.1, R25.2, R23.1) |
| 188 | NET_C(C19.2, R23.2, GND) |
| 189 | NET_C(R25.1, V5) |
| 190 | 190 | NETLIST_END() |
| 191 | 191 | |
| 192 | 192 | static NETLIST_START(nl_mario) |
| 193 | 193 | |
| 194 | | /* Standard stuff */ |
| 194 | /* Standard stuff */ |
| 195 | 195 | |
| 196 | | SOLVER(Solver, 48000) |
| 197 | | PARAM(Solver.ACCURACY, 1e-8) |
| 198 | | PARAM(Solver.SOR_FACTOR, 1.0) |
| 199 | | PARAM(Solver.GS_THRESHOLD, 5) |
| 200 | | PARAM(Solver.GS_LOOPS, 4) |
| 201 | | //PARAM(Solver.LTE, 5e-2) // Default is not enough for paddle control |
| 202 | | PARAM(Solver.DYNAMIC_TS, 0) |
| 203 | | ANALOG_INPUT(V5, 5) |
| 196 | SOLVER(Solver, 48000) |
| 197 | PARAM(Solver.ACCURACY, 1e-8) |
| 198 | PARAM(Solver.SOR_FACTOR, 1.0) |
| 199 | PARAM(Solver.GS_THRESHOLD, 5) |
| 200 | PARAM(Solver.GS_LOOPS, 4) |
| 201 | //PARAM(Solver.LTE, 5e-2) // Default is not enough for paddle control |
| 202 | PARAM(Solver.DYNAMIC_TS, 0) |
| 203 | ANALOG_INPUT(V5, 5) |
| 204 | 204 | |
| 205 | | TTL_INPUT(SOUND0, 1) |
| 206 | | INCLUDE(nl_mario_snd0) |
| 205 | TTL_INPUT(SOUND0, 1) |
| 206 | INCLUDE(nl_mario_snd0) |
| 207 | 207 | |
| 208 | | TTL_INPUT(SOUND7, 1) |
| 209 | | INCLUDE(nl_mario_snd7) |
| 208 | TTL_INPUT(SOUND7, 1) |
| 209 | INCLUDE(nl_mario_snd7) |
| 210 | 210 | |
| 211 | | R2R_DAC(DAC, 3.4, 10000.0, 8) |
| 212 | | NET_C(DAC.VGND, GND) |
| 211 | R2R_DAC(DAC, 3.4, 10000.0, 8) |
| 212 | NET_C(DAC.VGND, GND) |
| 213 | 213 | |
| 214 | | INCLUDE(nl_mario_dac) |
| 214 | INCLUDE(nl_mario_dac) |
| 215 | 215 | |
| 216 | | /* ---------------------------------------------------------------------- */ |
| 217 | | /* mixing */ |
| 218 | | /* ---------------------------------------------------------------------- */ |
| 216 | /* ---------------------------------------------------------------------- */ |
| 217 | /* mixing */ |
| 218 | /* ---------------------------------------------------------------------- */ |
| 219 | 219 | |
| 220 | | RES(R20, RES_K(22)) /* verified */ |
| 221 | | RES(R19, RES_K(22)) /* verified */ |
| 222 | | RES(R40, RES_K(22)) /* verified */ |
| 223 | | RES(R41, RES_K(100)) /* verified */ |
| 224 | | CAP(C31, CAP_U(0.022)) /* */ |
| 220 | RES(R20, RES_K(22)) /* verified */ |
| 221 | RES(R19, RES_K(22)) /* verified */ |
| 222 | RES(R40, RES_K(22)) /* verified */ |
| 223 | RES(R41, RES_K(100)) /* verified */ |
| 224 | CAP(C31, CAP_U(0.022)) /* */ |
| 225 | 225 | |
| 226 | | NET_C(2K_A.Q, R20.1) |
| 227 | | NET_C(GND, R19.1) //FIXME |
| 228 | | NET_C(2K_C.Q, R41.1) |
| 226 | NET_C(2K_A.Q, R20.1) |
| 227 | NET_C(GND, R19.1) //FIXME |
| 228 | NET_C(2K_C.Q, R41.1) |
| 229 | 229 | |
| 230 | 230 | #if 1 |
| 231 | | RES(DUM, RES_K(22)) |
| 232 | | NET_C(R39.1, DUM.1) |
| 233 | | NET_C(DUM.2, GND) |
| 234 | | FRONTIER(front1, R39.1, R40.1) |
| 231 | RES(DUM, RES_K(22)) |
| 232 | NET_C(R39.1, DUM.1) |
| 233 | NET_C(DUM.2, GND) |
| 234 | FRONTIER(front1, R39.1, R40.1) |
| 235 | 235 | #else |
| 236 | | NET_C(R39.1, R40.1) |
| 236 | NET_C(R39.1, R40.1) |
| 237 | 237 | #endif |
| 238 | 238 | |
| 239 | | NET_C(R20.2, R19.2, R40.2, R41.2, C31.1) |
| 240 | | NET_C(C31.2, GND) |
| 239 | NET_C(R20.2, R19.2, R40.2, R41.2, C31.1) |
| 240 | NET_C(C31.2, GND) |
| 241 | 241 | |
| 242 | | CAP(C32, CAP_U(1)) /* verified */ |
| 243 | | RES(R42, RES_K(43)) /* verified */ |
| 244 | | RES(R43, RES_K(100)) /* verified */ |
| 242 | CAP(C32, CAP_U(1)) /* verified */ |
| 243 | RES(R42, RES_K(43)) /* verified */ |
| 244 | RES(R43, RES_K(100)) /* verified */ |
| 245 | 245 | |
| 246 | | NET_C(C31.1, C32.1) |
| 247 | | NET_C(C32.2, R42.1, R43.2, Q10.B) |
| 248 | | //NET_C(C32.2, R42.1, R43.2) |
| 249 | | NET_C(R43.1, V5) |
| 250 | | NET_C(R42.2, GND) |
| 246 | NET_C(C31.1, C32.1) |
| 247 | NET_C(C32.2, R42.1, R43.2, Q10.B) |
| 248 | //NET_C(C32.2, R42.1, R43.2) |
| 249 | NET_C(R43.1, V5) |
| 250 | NET_C(R42.2, GND) |
| 251 | 251 | #if 1 |
| 252 | | RES(R63, RES_K(1)) /* */ |
| 253 | | RES(R62, 150) /* */ |
| 252 | RES(R63, RES_K(1)) /* */ |
| 253 | RES(R62, 150) /* */ |
| 254 | 254 | |
| 255 | | QBJT_EB(Q10, "2SC1815") |
| 255 | QBJT_EB(Q10, "2SC1815") |
| 256 | 256 | |
| 257 | | NET_C(R62.2, GND) |
| 258 | | NET_C(R62.1, Q10.E) |
| 257 | NET_C(R62.2, GND) |
| 258 | NET_C(R62.1, Q10.E) |
| 259 | 259 | |
| 260 | | NET_C(R63.1, V5) |
| 261 | | NET_C(R63.2, Q10.C) |
| 260 | NET_C(R63.1, V5) |
| 261 | NET_C(R63.2, Q10.C) |
| 262 | 262 | |
| 263 | | CAP(C42, CAP_U(0.1)) |
| 264 | | CAP(C47, CAP_U(4.7)) |
| 265 | | RES(VR1, RES_K(10)) |
| 263 | CAP(C42, CAP_U(0.1)) |
| 264 | CAP(C47, CAP_U(4.7)) |
| 265 | RES(VR1, RES_K(10)) |
| 266 | 266 | |
| 267 | | NET_C(C42.1, C47.1, R62.1) |
| 268 | | NET_C(C42.2, GND) |
| 269 | | NET_C(C47.2, VR1.1) |
| 270 | | NET_C(VR1.2, GND) |
| 267 | NET_C(C42.1, C47.1, R62.1) |
| 268 | NET_C(C42.2, GND) |
| 269 | NET_C(C47.2, VR1.1) |
| 270 | NET_C(VR1.2, GND) |
| 271 | 271 | #endif |
| 272 | | /* ---------------------------------------------------------------------- */ |
| 273 | | /* Output */ |
| 274 | | /* ---------------------------------------------------------------------- */ |
| 272 | /* ---------------------------------------------------------------------- */ |
| 273 | /* Output */ |
| 274 | /* ---------------------------------------------------------------------- */ |
| 275 | 275 | |
| 276 | | RES(ROUT, 1000000) |
| 276 | RES(ROUT, 1000000) |
| 277 | 277 | |
| 278 | | //NET_C(Q10.C, ROUT.1) |
| 279 | | //NET_C(R43.2, ROUT.1) |
| 280 | | NET_C(VR1.1, ROUT.1) |
| 278 | //NET_C(Q10.C, ROUT.1) |
| 279 | //NET_C(R43.2, ROUT.1) |
| 280 | NET_C(VR1.1, ROUT.1) |
| 281 | 281 | |
| 282 | | NET_C(GND, ROUT.2) |
| 282 | NET_C(GND, ROUT.2) |
| 283 | 283 | |
| 284 | 284 | NETLIST_END() |
| 285 | 285 | |
| r243230 | r243231 | |
| 790 | 790 | #if OLD_SOUND |
| 791 | 791 | m_discrete->write(space, DS_SOUND0_INP, 0); |
| 792 | 792 | #else |
| 793 | | m_audio_snd0->write(data); |
| 793 | m_audio_snd0->write(data); |
| 794 | 794 | #endif |
| 795 | 795 | } |
| 796 | 796 | |
| r243230 | r243231 | |
| 835 | 835 | #if OLD_SOUND |
| 836 | 836 | machine().device<discrete_device>("discrete")->write(space, DS_SOUND7_INP, data & 1); |
| 837 | 837 | #else |
| 838 | | m_audio_snd7->write((data & 1) ^ 1); |
| 838 | m_audio_snd7->write((data & 1) ^ 1); |
| 839 | 839 | #endif |
| 840 | 840 | break; |
| 841 | 841 | } |
| r243230 | r243231 | |
| 891 | 891 | MCFG_DISCRETE_INTF(mario) |
| 892 | 892 | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1) |
| 893 | 893 | #else |
| 894 | | MCFG_SOUND_ADD("snd_nl", NETLIST_SOUND, 48000) |
| 895 | | MCFG_NETLIST_SETUP(nl_mario) |
| 896 | | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) |
| 894 | MCFG_SOUND_ADD("snd_nl", NETLIST_SOUND, 48000) |
| 895 | MCFG_NETLIST_SETUP(nl_mario) |
| 896 | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) |
| 897 | 897 | |
| 898 | | MCFG_NETLIST_LOGIC_INPUT("snd_nl", "snd0", "SOUND0.IN", 0, 1) |
| 899 | | MCFG_NETLIST_LOGIC_INPUT("snd_nl", "snd7", "SOUND7.IN", 0, 1) |
| 900 | | MCFG_NETLIST_LOGIC_INPUT("snd_nl", "dac", "DAC.VAL", 0, 255) |
| 898 | MCFG_NETLIST_LOGIC_INPUT("snd_nl", "snd0", "SOUND0.IN", 0, 1) |
| 899 | MCFG_NETLIST_LOGIC_INPUT("snd_nl", "snd7", "SOUND7.IN", 0, 1) |
| 900 | MCFG_NETLIST_LOGIC_INPUT("snd_nl", "dac", "DAC.VAL", 0, 255) |
| 901 | 901 | |
| 902 | | MCFG_NETLIST_STREAM_OUTPUT("snd_nl", 0, "ROUT.1") |
| 903 | | MCFG_NETLIST_ANALOG_MULT_OFFSET(150000.0, 0.0) |
| 902 | MCFG_NETLIST_STREAM_OUTPUT("snd_nl", 0, "ROUT.1") |
| 903 | MCFG_NETLIST_ANALOG_MULT_OFFSET(150000.0, 0.0) |
| 904 | 904 | #endif |
| 905 | 905 | |
| 906 | 906 | MACHINE_CONFIG_END |
trunk/src/mame/drivers/model3.c
| r243230 | r243231 | |
| 1696 | 1696 | { |
| 1697 | 1697 | UINT8* base; |
| 1698 | 1698 | retvalue = m_cryptdevice->do_decrypt(base); |
| 1699 | | // retvalue = ((retvalue & 0xff00) >> 8) | ((retvalue & 0x00ff) << 8); // don't endian swap the return value on this hardware |
| 1699 | // retvalue = ((retvalue & 0xff00) >> 8) | ((retvalue & 0x00ff) << 8); // don't endian swap the return value on this hardware |
| 1700 | 1700 | retvalue <<= 16; |
| 1701 | 1701 | } |
| 1702 | 1702 | |
| 1703 | | // printf("model3_5881prot_r offset %08x : %08x%08x (%08x%08x)\n", offset * 8, (UINT32)(retvalue >> 32), (UINT32)(retvalue & 0xffffffff), (UINT32)(mem_mask >> 32), (UINT32)(mem_mask & 0xffffffff)); |
| 1703 | // printf("model3_5881prot_r offset %08x : %08x%08x (%08x%08x)\n", offset * 8, (UINT32)(retvalue >> 32), (UINT32)(retvalue & 0xffffffff), (UINT32)(mem_mask >> 32), (UINT32)(mem_mask & 0xffffffff)); |
| 1704 | 1704 | } |
| 1705 | 1705 | else |
| 1706 | 1706 | { |
| r243230 | r243231 | |
| 3336 | 3336 | ROM_FILL( 0x000000, 0x80000, 0 ) |
| 3337 | 3337 | |
| 3338 | 3338 | // ???? 317-0237-COM Model 3 |
| 3339 | | ROM_PARAMETER( ":315_5881:key", "29234e96" ) |
| 3339 | ROM_PARAMETER( ":315_5881:key", "09234e96" ) |
| 3340 | 3340 | ROM_END |
| 3341 | 3341 | |
| 3342 | 3342 | ROM_START( vs29815 ) /* Step 1.5, ROM board ID# 834-13495 VS2 VER98 STEP 1.5 */ |
| r243230 | r243231 | |
| 3489 | 3489 | ROM_FILL( 0x000000, 0x80000, 0 ) |
| 3490 | 3490 | |
| 3491 | 3491 | // ???? 317-0245-COM Model 3 |
| 3492 | | ROM_PARAMETER( ":315_5881:key", "29222ac8" ) |
| 3492 | ROM_PARAMETER( ":315_5881:key", "09222ac8" ) |
| 3493 | 3493 | ROM_END |
| 3494 | 3494 | |
| 3495 | 3495 | ROM_START( vs299b ) /* Step 2.0 */ |
| r243230 | r243231 | |
| 3567 | 3567 | ROM_FILL( 0x000000, 0x80000, 0 ) |
| 3568 | 3568 | |
| 3569 | 3569 | // ???? 317-0245-COM Model 3 |
| 3570 | | ROM_PARAMETER( ":315_5881:key", "29222ac8" ) |
| 3570 | ROM_PARAMETER( ":315_5881:key", "09222ac8" ) |
| 3571 | 3571 | ROM_END |
| 3572 | 3572 | |
| 3573 | 3573 | ROM_START( vs299a ) /* Step 2.0 */ |
| r243230 | r243231 | |
| 3723 | 3723 | ROM_FILL( 0x000000, 0x80000, 0 ) |
| 3724 | 3724 | |
| 3725 | 3725 | // ???? 317-0245-COM Model 3 |
| 3726 | | ROM_PARAMETER( ":315_5881:key", "29222ac8" ) |
| 3726 | ROM_PARAMETER( ":315_5881:key", "09222ac8" ) |
| 3727 | 3727 | ROM_END |
| 3728 | 3728 | |
| 3729 | 3729 | ROM_START( von2 ) /* Step 2.0 */ |
| r243230 | r243231 | |
| 3802 | 3802 | ROM_FILL( 0x000000, 0x80000, 0 ) |
| 3803 | 3803 | |
| 3804 | 3804 | // ???? 317-0234-COM Model 3 |
| 3805 | | ROM_PARAMETER( ":315_5881:key", "292a0e97" ) |
| 3805 | ROM_PARAMETER( ":315_5881:key", "092a0e97" ) |
| 3806 | 3806 | ROM_END |
| 3807 | 3807 | |
| 3808 | 3808 | ROM_START( von254g ) /* Step 2.0, Sega game ID# is 833-13789 */ |
| r243230 | r243231 | |
| 3881 | 3881 | ROM_FILL( 0x000000, 0x80000, 0 ) |
| 3882 | 3882 | |
| 3883 | 3883 | // ???? 317-0234-COM Model 3 |
| 3884 | | ROM_PARAMETER( ":315_5881:key", "292a0e97" ) |
| 3884 | ROM_PARAMETER( ":315_5881:key", "092a0e97" ) |
| 3885 | 3885 | ROM_END |
| 3886 | 3886 | |
| 3887 | 3887 | ROM_START( skichamp ) /* Step 2.0 */ |
| r243230 | r243231 | |
| 4028 | 4028 | ROM_LOAD( "epr21119.ic8", 0x00000, 0x10000, CRC(65082b14) SHA1(6c3c192dd6ef3780c6202dd63fc6086328928818) ) |
| 4029 | 4029 | |
| 4030 | 4030 | // ???? 317-0241-COM Model 3 |
| 4031 | | ROM_PARAMETER( ":315_5881:key", "31272a01" ) |
| 4031 | ROM_PARAMETER( ":315_5881:key", "11272a01" ) |
| 4032 | 4032 | ROM_END |
| 4033 | 4033 | |
| 4034 | 4034 | ROM_START( swtrilgya ) /* Step 2.1, Sega game ID# is 833-13586, ROM board ID# 834-13587 STAR WARS TRILOGY, Security board ID# 837-13588-COM */ |
| r243230 | r243231 | |
| 4100 | 4100 | ROM_FILL( 0x000000, 0x80000, 0 ) |
| 4101 | 4101 | |
| 4102 | 4102 | // ???? 317-0241-COM Model 3 |
| 4103 | | ROM_PARAMETER( ":315_5881:key", "31272a01" ) |
| 4103 | ROM_PARAMETER( ":315_5881:key", "11272a01" ) |
| 4104 | 4104 | ROM_END |
| 4105 | 4105 | |
| 4106 | 4106 | ROM_START( dirtdvls ) /* Step 2.1, Sega game ID# is 833-13427, ROM board ID# 834-13528 DRT */ |
| r243230 | r243231 | |
| 4164 | 4164 | ROM_FILL( 0x000000, 0x80000, 0 ) |
| 4165 | 4165 | |
| 4166 | 4166 | // ???? 317-0238-COM Model 3 |
| 4167 | | ROM_PARAMETER( ":315_5881:key", "29290f17" ) |
| 4167 | ROM_PARAMETER( ":315_5881:key", "09290f17" ) |
| 4168 | 4168 | ROM_END |
| 4169 | 4169 | |
| 4170 | 4170 | ROM_START( dirtdvlsa ) /* Step 2.1 */ |
| r243230 | r243231 | |
| 4311 | 4311 | ROM_LOAD( "epr-20985.bin", 0x000000, 0x010000, CRC(b139481d) SHA1(05fca7db7c8b084c53bd157ba3e8296f1a961a99) ) |
| 4312 | 4312 | |
| 4313 | 4313 | // ???? 317-0239-COM Model 3 |
| 4314 | | ROM_PARAMETER( ":315_5881:key", "29250e16" ) |
| 4314 | ROM_PARAMETER( ":315_5881:key", "09250e16" ) |
| 4315 | 4315 | ROM_END |
| 4316 | 4316 | |
| 4317 | 4317 | ROM_START( dayto2pe ) /* Step 2.1, Sega game ID# is 833-13610 DAYTONA USA2 SP, ROM board ID# 834-13609 DAYTONA USA2 SP, Security board ID# 837-13645-COM */ |
| r243230 | r243231 | |
| 4394 | 4394 | ROM_LOAD( "epr-20985.bin", 0x000000, 0x010000, CRC(b139481d) SHA1(05fca7db7c8b084c53bd157ba3e8296f1a961a99) ) |
| 4395 | 4395 | |
| 4396 | 4396 | // ???? 317-5045-COM Model 3 |
| 4397 | | ROM_PARAMETER( ":315_5881:key", "29222cc4" ) |
| 4397 | ROM_PARAMETER( ":315_5881:key", "0" ) // unknown |
| 4398 | 4398 | ROM_END |
| 4399 | 4399 | |
| 4400 | 4400 | ROM_START( srally2 ) /* Step 2.0, Sega game ID# is 833-13373, ROM board ID# 834-13374 SRT TWIN */ |
| r243230 | r243231 | |
| 4749 | 4749 | ROM_FILL( 0x000000, 0x80000, 0 ) |
| 4750 | 4750 | |
| 4751 | 4751 | // ???? 317-0235-COM Model 3 |
| 4752 | | ROM_PARAMETER( ":315_5881:key", "29260e96" ) |
| 4752 | ROM_PARAMETER( ":315_5881:key", "09260e96" ) |
| 4753 | 4753 | ROM_END |
| 4754 | 4754 | |
| 4755 | 4755 | ROM_START( spikeout ) /* Step 2.1 */ |
| r243230 | r243231 | |
| 4829 | 4829 | ROM_FILL( 0x000000, 0x80000, 0 ) |
| 4830 | 4830 | |
| 4831 | 4831 | // ???? 317-0240-COM Model 3 |
| 4832 | | ROM_PARAMETER( ":315_5881:key", "292f2b04" ) |
| 4832 | ROM_PARAMETER( ":315_5881:key", "092f2b04" ) |
| 4833 | 4833 | ROM_END |
| 4834 | 4834 | |
| 4835 | 4835 | ROM_START( spikeofe ) /* Step 2.1, Sega game ID# is 833-13746, ROM board ID# 834-13747 SPK F/E, Security board ID# 837-13726-COM */ |
| r243230 | r243231 | |
| 4909 | 4909 | ROM_FILL( 0x000000, 0x80000, 0 ) |
| 4910 | 4910 | |
| 4911 | 4911 | // ???? 317-0247-COM Model 3 |
| 4912 | | ROM_PARAMETER( ":315_5881:key", "29236fc8" ) |
| 4912 | ROM_PARAMETER( ":315_5881:key", "09236fc8" ) |
| 4913 | 4913 | ROM_END |
| 4914 | 4914 | |
| 4915 | 4915 | ROM_START( eca ) /* Step 2.1, ROM board ID# 834-13946-01 ECA */ |
| r243230 | r243231 | |
| 4980 | 4980 | ROM_FILL( 0x000000, 0x80000, 0 ) |
| 4981 | 4981 | |
| 4982 | 4982 | // ???? 317-0265-COM Model 3 |
| 4983 | | ROM_PARAMETER( ":315_5881:key", "2923aa91" ) |
| 4983 | ROM_PARAMETER( ":315_5881:key", "0923aa91" ) |
| 4984 | 4984 | ROM_END |
| 4985 | 4985 | |
| 4986 | 4986 | ROM_START( ecax ) /* Step 2.1 */ |
| r243230 | r243231 | |
| 5051 | 5051 | ROM_FILL( 0x000000, 0x80000, 0 ) |
| 5052 | 5052 | |
| 5053 | 5053 | // ???? 317-0265-COM Model 3 |
| 5054 | | ROM_PARAMETER( ":315_5881:key", "2923aa91" ) |
| 5054 | ROM_PARAMETER( ":315_5881:key", "0923aa91" ) |
| 5055 | 5055 | ROM_END |
| 5056 | 5056 | |
| 5057 | 5057 | ROM_START( ecap ) /* Step 2.1 - Proto or Location test - No security dongle */ |
| r243230 | r243231 | |
| 5125 | 5125 | ROM_FILL( 0x000000, 0x80000, 0 ) |
| 5126 | 5126 | |
| 5127 | 5127 | // ???? 317-0265-COM Model 3 |
| 5128 | | ROM_PARAMETER( ":315_5881:key", "2923aa91" ) |
| 5128 | ROM_PARAMETER( ":315_5881:key", "0923aa91" ) |
| 5129 | 5129 | ROM_END |
| 5130 | 5130 | |
| 5131 | 5131 | ROM_START( magtruck ) /* Step 2.1, Sega game ID# is 833-13601-01 (Export), ROM board ID# 834-13600-01 RCS EXP (Export), Security board ID# 837-13599-COM */ |
| r243230 | r243231 | |
| 5184 | 5184 | ROM_FILL( 0x000000, 0x80000, 0 ) |
| 5185 | 5185 | |
| 5186 | 5186 | // ???? 317-0243-COM Model 3 |
| 5187 | | ROM_PARAMETER( ":315_5881:key", "29266e45" ) |
| 5187 | ROM_PARAMETER( ":315_5881:key", "09266e45" ) |
| 5188 | 5188 | ROM_END |
| 5189 | 5189 | |
| 5190 | 5190 | ROM_START( oceanhun ) /* Step 2.0, Sega game ID# is 833-13571, ROM board ID# 834-13572 THE OCEAN HUNTER, 317-0242-COM security chip (837-13576-COM security board) */ |
| r243230 | r243231 | |
| 5255 | 5255 | ROM_FILL( 0x000000, 0x80000, 0 ) |
| 5256 | 5256 | |
| 5257 | 5257 | // ???? 317-0242-COM Model 3 |
| 5258 | | ROM_PARAMETER( ":315_5881:key", "292b6a01" ) |
| 5258 | ROM_PARAMETER( ":315_5881:key", "092b6a01" ) |
| 5259 | 5259 | ROM_END |
| 5260 | 5260 | |
| 5261 | 5261 | ROM_START( lamachin ) /* Step 2.0, Sega game ID# is 833-13664, ROM board ID# 834-13665 L.A.MACHINEGUNS, 317-0244-COM security chip (837-13666-COM security board) */ |
| r243230 | r243231 | |
| 5327 | 5327 | ROM_FILL( 0x000000, 0x80000, 0 ) |
| 5328 | 5328 | |
| 5329 | 5329 | // ???? 317-0244-COM Model 3 |
| 5330 | | ROM_PARAMETER( ":315_5881:key", "292a2bc5" ) |
| 5330 | ROM_PARAMETER( ":315_5881:key", "092a2bc5" ) |
| 5331 | 5331 | ROM_END |
| 5332 | 5332 | |
| 5333 | 5333 | /* Model 3 sound board emulation */ |
| r243230 | r243231 | |
| 5584 | 5584 | dat = m_maincpu->space().read_word((0xf0180000 + 4 * addr)); // every other word is unused in this RAM, probably 32-bit ram on 64-bit bus? |
| 5585 | 5585 | } |
| 5586 | 5586 | |
| 5587 | | // dat = ((dat & 0xff00) >> 8) | ((dat & 0x00ff) << 8); |
| 5588 | | // printf("reading %04x\n", dat); |
| 5587 | // dat = ((dat & 0xff00) >> 8) | ((dat & 0x00ff) << 8); |
| 5588 | // printf("reading %04x\n", dat); |
| 5589 | 5589 | |
| 5590 | 5590 | return dat; |
| 5591 | 5591 | } |
| r243230 | r243231 | |
| 5629 | 5629 | |
| 5630 | 5630 | DRIVER_INIT_MEMBER(model3_state, genprot) |
| 5631 | 5631 | { |
| 5632 | | // astring key = parameter(":315_5881:key"); |
| 5632 | // astring key = parameter(":315_5881:key"); |
| 5633 | 5633 | |
| 5634 | 5634 | m_maincpu->space(AS_PROGRAM).install_ram(0xf0180000, 0xf019ffff, 0, 0x0e000000); |
| 5635 | 5635 | |
| 5636 | | m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0xf01a0000, 0xf01a003f, 0, 0x0e000000, read64_delegate(FUNC(model3_state::model3_5881prot_r), this), write64_delegate(FUNC(model3_state::model3_5881prot_w), this) ); |
| 5636 | m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0xf01a0000, 0xf01a003f, 0, 0x0e000000, read64_delegate(FUNC(model3_state::model3_5881prot_r), this), write64_delegate(FUNC(model3_state::model3_5881prot_w), this) ); |
| 5637 | 5637 | |
| 5638 | 5638 | } |
| 5639 | 5639 | |
| r243230 | r243231 | |
| 5846 | 5846 | |
| 5847 | 5847 | DRIVER_INIT_MEMBER(model3_state,swtrilgy) |
| 5848 | 5848 | { |
| 5849 | |
| 5849 | 5850 | UINT32 *rom = (UINT32*)memregion("user1")->base(); |
| 5850 | 5851 | DRIVER_INIT_CALL(model3_20); |
| 5851 | 5852 | |
| r243230 | r243231 | |
| 5889 | 5890 | |
| 5890 | 5891 | DRIVER_INIT_MEMBER(model3_state,daytona2) |
| 5891 | 5892 | { |
| 5892 | | // UINT32 *rom = (UINT32*)memregion("user1")->base(); |
| 5893 | // UINT32 *rom = (UINT32*)memregion("user1")->base(); |
| 5893 | 5894 | DRIVER_INIT_CALL(model3_20); |
| 5894 | 5895 | |
| 5895 | 5896 | m_maincpu->space(AS_PROGRAM).install_write_handler(0xc3800000, 0xc3800007, write64_delegate(FUNC(model3_state::daytona2_rombank_w),this)); |
| r243230 | r243231 | |
| 5905 | 5906 | |
| 5906 | 5907 | DRIVER_INIT_MEMBER(model3_state,dayto2pe) |
| 5907 | 5908 | { |
| 5908 | | // UINT32 *rom = (UINT32*)memregion("user1")->base(); |
| 5909 | // UINT32 *rom = (UINT32*)memregion("user1")->base(); |
| 5909 | 5910 | DRIVER_INIT_CALL(model3_20); |
| 5910 | 5911 | |
| 5911 | 5912 | m_maincpu->space(AS_PROGRAM).install_write_handler(0xc3800000, 0xc3800007, write64_delegate(FUNC(model3_state::daytona2_rombank_w),this)); |
| 5912 | 5913 | m_maincpu->space(AS_PROGRAM).install_read_bank(0xc3000000, 0xc37fffff, "bank2" ); |
| 5913 | 5914 | |
| 5914 | | // rom[(0x606784^4)/4] = 0x60000000; |
| 5915 | | // rom[(0x69a3fc^4)/4] = 0x60000000; // jump to encrypted code |
| 5916 | | // rom[(0x618b28^4)/4] = 0x60000000; // jump to encrypted code |
| 5915 | // rom[(0x606784^4)/4] = 0x60000000; |
| 5916 | // rom[(0x69a3fc^4)/4] = 0x60000000; // jump to encrypted code |
| 5917 | // rom[(0x618b28^4)/4] = 0x60000000; // jump to encrypted code |
| 5917 | 5918 | |
| 5918 | | // rom[(0x64ca34^4)/4] = 0x60000000; // dec |
| 5919 | // rom[(0x64ca34^4)/4] = 0x60000000; // dec |
| 5919 | 5920 | |
| 5920 | 5921 | DRIVER_INIT_CALL(genprot); |
| 5921 | 5922 | } |
trunk/src/mame/drivers/naomi.c
| r243230 | r243231 | |
| 3221 | 3221 | ROM_LOAD("mpr-23427.ic8", 0x4000000, 0x0800000, CRC(5851d525) SHA1(1cb1073542d75a3bcc0d363ed31d49bcaf1fd494) ) |
| 3222 | 3222 | |
| 3223 | 3223 | // 840-0044 2000 317-0289-COM Naomi |
| 3224 | | ROM_PARAMETER( ":rom_board:segam2crypt:key", "28103347" ) |
| 3224 | ROM_PARAMETER( ":rom_board:segam2crypt:key", "08103347" ) |
| 3225 | 3225 | ROM_END |
| 3226 | 3226 | |
| 3227 | 3227 | ROM_START( csmasho ) |
| r243230 | r243231 | |
| 3240 | 3240 | ROM_LOAD("mpr-23427.ic8", 0x4000000, 0x0800000, CRC(5851d525) SHA1(1cb1073542d75a3bcc0d363ed31d49bcaf1fd494) ) |
| 3241 | 3241 | |
| 3242 | 3242 | // 840-0044 2000 317-0289-COM Naomi |
| 3243 | | ROM_PARAMETER( ":rom_board:segam2crypt:key", "28103347" ) |
| 3243 | ROM_PARAMETER( ":rom_board:segam2crypt:key", "08103347" ) |
| 3244 | 3244 | ROM_END |
| 3245 | 3245 | |
| 3246 | 3246 | /* |
| r243230 | r243231 | |
| 3465 | 3465 | ROM_LOAD("mpr-22098.ic14s", 0x7000000, 0x0800000, CRC(f9824d2e) SHA1(f20f8cc2b1bef9077ede1cb874da8f2a335d39de) ) |
| 3466 | 3466 | |
| 3467 | 3467 | // 840-0016 1999 317-0262-JPN Naomi |
| 3468 | | ROM_PARAMETER( ":rom_board:segam2crypt:key", "280fee35" ) |
| 3468 | ROM_PARAMETER( ":rom_board:segam2crypt:key", "080fee35" ) |
| 3469 | 3469 | ROM_END |
| 3470 | 3470 | |
| 3471 | 3471 | ROM_START( derbyocw ) |
| r243230 | r243231 | |
| 3607 | 3607 | ROM_LOAD("mpr-21574.ic21s", 0xa800000, 0x0800000, CRC(d794a42c) SHA1(a79c7818c6ec993e718494b1d5407eb270a29abe) ) |
| 3608 | 3608 | |
| 3609 | 3609 | // 840-0001 1998 317-0246-JPN Naomi |
| 3610 | | ROM_PARAMETER( ":rom_board:segam2crypt:key", "280e6ae1" ) |
| 3610 | ROM_PARAMETER( ":rom_board:segam2crypt:key", "080e6ae1" ) |
| 3611 | 3611 | ROM_END |
| 3612 | 3612 | |
| 3613 | 3613 | /* |
| r243230 | r243231 | |
| 3671 | 3671 | ROM_LOAD("mpr-22140.ic19s", 0x9800000, 0x0800000, CRC(4cb54893) SHA1(a99b39cc3c82c3cf90f794bb8c8ba60638a6f921) ) |
| 3672 | 3672 | |
| 3673 | 3673 | // 840-0019 1999 317-0269-JPN Naomi |
| 3674 | | ROM_PARAMETER( ":rom_board:segam2crypt:key", "2804ae71" ) |
| 3674 | ROM_PARAMETER( ":rom_board:segam2crypt:key", "0804ae71" ) |
| 3675 | 3675 | ROM_END |
| 3676 | 3676 | |
| 3677 | 3677 | ROM_START( smlg99 ) |
| r243230 | r243231 | |
| 3704 | 3704 | ROM_LOAD( "mpr-22058.ic21s", 0xa800000, 0x800000, CRC(f16edaa0) SHA1(e093f5594df43c592a9acd45002ecc65035c2435) ) |
| 3705 | 3705 | |
| 3706 | 3706 | // 840-0012 1999 317-0259-COM Naomi |
| 3707 | | ROM_PARAMETER( ":rom_board:segam2crypt:key", "28048a01" ) |
| 3707 | ROM_PARAMETER( ":rom_board:segam2crypt:key", "08048a01" ) |
| 3708 | 3708 | ROM_END |
| 3709 | 3709 | |
| 3710 | 3710 | /* |
| r243230 | r243231 | |
| 3746 | 3746 | ROM_LOAD("mpr-21901.ic21s", 0xa800000, 0x0800000, CRC(266a3eea) SHA1(795ecc5589a0152b9cf1e03e454ed1ea01501942) ) |
| 3747 | 3747 | |
| 3748 | 3748 | // 834-13842 1999 317-0254-COM Naomi |
| 3749 | | ROM_PARAMETER( ":rom_board:segam2crypt:key", "280e8f84" ) |
| 3749 | ROM_PARAMETER( ":rom_board:segam2crypt:key", "080e8f84" ) |
| 3750 | 3750 | |
| 3751 | 3751 | ROM_REGION( 0x10000, "drivebd", 0 ) /* drive board ROM */ |
| 3752 | 3752 | ROM_LOAD( "epr-21867.bin", 0x000000, 0x010000, CRC(4f93a2a0) SHA1(875907e7fcfc44850e2c60c12268ac61c742f217) ) |
| r243230 | r243231 | |
| 3781 | 3781 | ROM_LOAD( "mpr-22847.ic21s", 0xa800000, 0x800000, CRC(955ad42e) SHA1(e396ca02b5786557434632c4fac56af3a4a9f8ce) ) |
| 3782 | 3782 | |
| 3783 | 3783 | // 834-13950 1999 317-0267-COM Naomi |
| 3784 | | ROM_PARAMETER( ":rom_board:segam2crypt:key", "2806efd4" ) |
| 3784 | ROM_PARAMETER( ":rom_board:segam2crypt:key", "0806efd4" ) |
| 3785 | 3785 | ROM_END |
| 3786 | 3786 | |
| 3787 | 3787 | // There is also a development cart (171-7885A). Content is the same. |
| r243230 | r243231 | |
| 3814 | 3814 | ROM_LOAD( "mpr-23398.ic21s", 0xa800000, 0x800000, CRC(ea4d4d2a) SHA1(3dc9c7164516ae7f3b988c088ab819d8fd40d75e) ) |
| 3815 | 3815 | |
| 3816 | 3816 | // 840-0042 2001 317-0287-COM Naomi |
| 3817 | | ROM_PARAMETER( ":rom_board:segam2crypt:key", "281666c6" ) |
| 3817 | ROM_PARAMETER( ":rom_board:segam2crypt:key", "081666c6" ) |
| 3818 | 3818 | ROM_END |
| 3819 | 3819 | |
| 3820 | 3820 | ROM_START( alpiltdx ) |
| r243230 | r243231 | |
| 3836 | 3836 | ROM_LOAD( "mpr-21738.ic11", 0x5800000, 0x800000, CRC(95a592e8) SHA1(862dce467e8805381bab001df68262f1baf3c498) ) |
| 3837 | 3837 | |
| 3838 | 3838 | // 834-????? 1999 317-0251-COM Naomi |
| 3839 | | ROM_PARAMETER( ":rom_board:segam2crypt:key", "28070e41" ) |
| 3839 | ROM_PARAMETER( ":rom_board:segam2crypt:key", "08070e41" ) |
| 3840 | 3840 | |
| 3841 | 3841 | // on-cart X76F100 eeprom contents |
| 3842 | 3842 | ROM_REGION( 0x84, "naomibd_eeprom", 0 ) |
| r243230 | r243231 | |
| 3862 | 3862 | ROM_LOAD( "mpr-21738.ic11", 0x5800000, 0x800000, CRC(95a592e8) SHA1(862dce467e8805381bab001df68262f1baf3c498) ) |
| 3863 | 3863 | |
| 3864 | 3864 | // 840-0005 1999 317-0251-COM Naomi |
| 3865 | | ROM_PARAMETER( ":rom_board:segam2crypt:key", "28070e41" ) |
| 3865 | ROM_PARAMETER( ":rom_board:segam2crypt:key", "08070e41" ) |
| 3866 | 3866 | ROM_END |
| 3867 | 3867 | |
| 3868 | 3868 | ROM_START( hotd2 ) |
| r243230 | r243231 | |
| 4000 | 4000 | ROM_LOAD("mpr-21831.ic11", 0x5800000, 0x0800000, CRC(751848d0) SHA1(9c2267fd3c6f9ea5f2679bb2ca20d511a49b2845) ) |
| 4001 | 4001 | |
| 4002 | 4002 | // 840-0007 1999 317-0253-JPN Naomi |
| 4003 | | ROM_PARAMETER( ":rom_board:segam2crypt:key", "28074a61" ) |
| 4003 | ROM_PARAMETER( ":rom_board:segam2crypt:key", "08074a61" ) |
| 4004 | 4004 | ROM_END |
| 4005 | 4005 | |
| 4006 | 4006 | /* |
| r243230 | r243231 | |
| 4090 | 4090 | ROM_LOAD( "x76f100.ic37", 0x000000, 0x000084, CRC(c79251d5) SHA1(3e70bbbb6d28bade7eec7e27d716463045656f98) ) |
| 4091 | 4091 | |
| 4092 | 4092 | // 840-0008 1999 317-0255-JPN Naomi |
| 4093 | | ROM_PARAMETER( ":rom_board:segam2crypt:key", "28028ea5" ) |
| 4093 | ROM_PARAMETER( ":rom_board:segam2crypt:key", "08028ea5" ) |
| 4094 | 4094 | ROM_END |
| 4095 | 4095 | |
| 4096 | 4096 | ROM_START( tduno2 ) |
| r243230 | r243231 | |
| 4167 | 4167 | ROM_LOAD( "mpr-23534.ic10", 0x9800000, 0x1000000, CRC(62ed85b6) SHA1(b88336bc6115c92a839981cb0c0d0a67b1f7eda5) ) |
| 4168 | 4168 | |
| 4169 | 4169 | // 840-0043 2000 317-0288-COM Naomi |
| 4170 | | ROM_PARAMETER( ":rom_board:segam2crypt:key", "281c2347" ) |
| 4170 | ROM_PARAMETER( ":rom_board:segam2crypt:key", "081c2347" ) |
| 4171 | 4171 | ROM_END |
| 4172 | 4172 | |
| 4173 | 4173 | ROM_START( crakndj2 ) |
| r243230 | r243231 | |
| 4201 | 4201 | ROM_LOAD( "rom20.ic20s", 0xa000000, 0x800000, CRC(aabcd580) SHA1(9455e218ab381c7ad5adb2884da39ca7948169d5) ) |
| 4202 | 4202 | |
| 4203 | 4203 | // 840-0068 2001 317-0311-COM Naomi |
| 4204 | | ROM_PARAMETER( ":rom_board:segam2crypt:key", "28428247" ) |
| 4204 | ROM_PARAMETER( ":rom_board:segam2crypt:key", "08428247" ) |
| 4205 | 4205 | ROM_END |
| 4206 | 4206 | |
| 4207 | 4207 | ROM_START( samba2k ) |
| r243230 | r243231 | |
| 4223 | 4223 | ROM_LOAD( "mpr-23599.ic11", 0x0a800000, 0x1000000, CRC(1fd2e792) SHA1(6f299e527be529f85d0e8b4ce0e7a06ac0d25fe9) ) |
| 4224 | 4224 | |
| 4225 | 4225 | // 840-0047 2000 317-0295-COM Naomi |
| 4226 | | ROM_PARAMETER( ":rom_board:segam2crypt:key", "281702cf" ) |
| 4226 | ROM_PARAMETER( ":rom_board:segam2crypt:key", "081702cf" ) |
| 4227 | 4227 | ROM_END |
| 4228 | 4228 | |
| 4229 | 4229 | ROM_START( alienfnt ) |
| r243230 | r243231 | |
| 4239 | 4239 | ROM_LOAD( "mpr-23585.ic5", 0x4800000, 0x1000000, CRC(883a6482) SHA1(e3145710df793b7fd67f02707904416210a71978) ) |
| 4240 | 4240 | |
| 4241 | 4241 | // 840-0048 2001 317-0293-COM Naomi |
| 4242 | | ROM_PARAMETER( ":rom_board:segam2crypt:key", "28174343" ) |
| 4242 | ROM_PARAMETER( ":rom_board:segam2crypt:key", "08174343" ) |
| 4243 | 4243 | ROM_END |
| 4244 | 4244 | |
| 4245 | 4245 | ROM_START( alienfnta ) |
| r243230 | r243231 | |
| 4255 | 4255 | ROM_LOAD( "mpr-23585.ic5", 0x4800000, 0x1000000, CRC(883a6482) SHA1(e3145710df793b7fd67f02707904416210a71978) ) |
| 4256 | 4256 | |
| 4257 | 4257 | // 840-0048 2001 317-0293-COM Naomi |
| 4258 | | ROM_PARAMETER( ":rom_board:segam2crypt:key", "28174343" ) |
| 4258 | ROM_PARAMETER( ":rom_board:segam2crypt:key", "08174343" ) |
| 4259 | 4259 | ROM_END |
| 4260 | 4260 | |
| 4261 | 4261 | /* |
| r243230 | r243231 | |
| 4518 | 4518 | ROM_LOAD("mpr-22034.ic10",0x5000000, 0x0800000, CRC(3aa5ce5e) SHA1(f00a906235e4522d6fc2ac771324114346875314) ) |
| 4519 | 4519 | |
| 4520 | 4520 | // 840-0011 1999 317-0257-COM Naomi |
| 4521 | | ROM_PARAMETER( ":rom_board:segam2crypt:key", "2802ca85" ) |
| 4521 | ROM_PARAMETER( ":rom_board:segam2crypt:key", "0802ca85" ) |
| 4522 | 4522 | ROM_END |
| 4523 | 4523 | |
| 4524 | 4524 | /* Crazy Taxi */ |
| r243230 | r243231 | |
| 4543 | 4543 | ROM_LOAD( "mpr-21683.ic15s", 0x7800000, 0x800000, CRC(ac8a27e0) SHA1(8e71d853a102dd6c164d5326e6d157ccfb8c7b36) ) |
| 4544 | 4544 | |
| 4545 | 4545 | // 840-0002 1999 317-0248-COM Naomi |
| 4546 | | ROM_PARAMETER( ":rom_board:segam2crypt:key", "280d2f45" ) |
| 4546 | ROM_PARAMETER( ":rom_board:segam2crypt:key", "080d2f45" ) |
| 4547 | 4547 | ROM_END |
| 4548 | 4548 | |
| 4549 | 4549 | /* Jambo! Safari */ |
| r243230 | r243231 | |
| 4563 | 4563 | ROM_LOAD( "mpr-22825.ic8", 0x4000000, 0x800000, CRC(85bada10) SHA1(b6e15d8f1d6bca12ffa4816ed0393c04ca500fba) ) |
| 4564 | 4564 | |
| 4565 | 4565 | // 840-0013 1999 317-0264-COM Naomi |
| 4566 | | ROM_PARAMETER( ":rom_board:segam2crypt:key", "280fab95" ) |
| 4566 | ROM_PARAMETER( ":rom_board:segam2crypt:key", "080fab95" ) |
| 4567 | 4567 | ROM_END |
| 4568 | 4568 | |
| 4569 | 4569 | /* 18 Wheeler (deluxe) (Rev A) */ |
| r243230 | r243231 | |
| 4595 | 4595 | ROM_LOAD( "mpr-22183.ic20s", 0xa000000, 0x800000, CRC(776af308) SHA1(7d29cb4dce75d34c622549fea7e102868d0da60a) ) |
| 4596 | 4596 | |
| 4597 | 4597 | // 840-0023 2000 317-0273-COM Naomi |
| 4598 | | ROM_PARAMETER( ":rom_board:segam2crypt:key", "2807cf54" ) |
| 4598 | ROM_PARAMETER( ":rom_board:segam2crypt:key", "0807cf54" ) |
| 4599 | 4599 | |
| 4600 | 4600 | // JVS I/O board 837-13844, code is for a Z80 of unknown type (it's inside the big Sega ASIC) |
| 4601 | 4601 | ROM_REGION( 0x20000, "jvsio", ROMREGION_ERASEFF) |
| r243230 | r243231 | |
| 4637 | 4637 | ROM_LOAD( "mpr-22183.ic20s", 0xa000000, 0x800000, CRC(776af308) SHA1(7d29cb4dce75d34c622549fea7e102868d0da60a) ) |
| 4638 | 4638 | |
| 4639 | 4639 | // 840-0023 2000 317-0273-COM Naomi |
| 4640 | | ROM_PARAMETER( ":rom_board:segam2crypt:key", "2807cf54" ) |
| 4640 | ROM_PARAMETER( ":rom_board:segam2crypt:key", "0807cf54" ) |
| 4641 | 4641 | |
| 4642 | 4642 | // JVS I/O board 837-13844, code is for a Z80 of unknown type (it's inside the big Sega ASIC) |
| 4643 | 4643 | ROM_REGION( 0x20000, "jvsio", ROMREGION_ERASEFF) |
| r243230 | r243231 | |
| 4679 | 4679 | ROM_LOAD( "mpr-22183.ic20s", 0xa000000, 0x800000, CRC(776af308) SHA1(7d29cb4dce75d34c622549fea7e102868d0da60a) ) |
| 4680 | 4680 | |
| 4681 | 4681 | // 840-0023 2000 317-0273-COM Naomi |
| 4682 | | ROM_PARAMETER( ":rom_board:segam2crypt:key", "2807cf54" ) |
| 4682 | ROM_PARAMETER( ":rom_board:segam2crypt:key", "0807cf54" ) |
| 4683 | 4683 | |
| 4684 | 4684 | // JVS I/O board 837-13844, code is for a Z80 of unknown type (it's inside the big Sega ASIC) |
| 4685 | 4685 | ROM_REGION( 0x20000, "jvsio", ROMREGION_ERASEFF) |
| r243230 | r243231 | |
| 4712 | 4712 | ROM_LOAD( "mpr-22992.ic15s", 0x7800000, 0x800000, CRC(5eb6c4c6) SHA1(5dc1bced7ebd7d7e01f74d03706ec4a96585628d) ) |
| 4713 | 4713 | |
| 4714 | 4714 | // 840-0025 1999 317-0274-JPN Naomi |
| 4715 | | ROM_PARAMETER( ":rom_board:segam2crypt:key", "280b8ef5" ) |
| 4715 | ROM_PARAMETER( ":rom_board:segam2crypt:key", "080b8ef5" ) |
| 4716 | 4716 | ROM_END |
| 4717 | 4717 | |
| 4718 | 4718 | /* Sega Strike Fighter */ |
| r243230 | r243231 | |
| 4744 | 4744 | ROM_LOAD( "mpr-23321.ic20s", 0xa000000, 0x800000, CRC(018627d4) SHA1(2519f39ad046d14f602648fed39bc3719185b55e) ) |
| 4745 | 4745 | |
| 4746 | 4746 | // 840-0035 2000 317-0281-COM Naomi |
| 4747 | | ROM_PARAMETER( ":rom_board:segam2crypt:key", "28132303" ) |
| 4747 | ROM_PARAMETER( ":rom_board:segam2crypt:key", "08132303" ) |
| 4748 | 4748 | ROM_END |
| 4749 | 4749 | |
| 4750 | 4750 | // EPR ROM have different number, possible updated/bugfixed re-release or STD/DLX version, difference with original set is unknown, have "Rev.A" label too |
| r243230 | r243231 | |
| 4776 | 4776 | ROM_LOAD( "mpr-23321.ic20s", 0xa000000, 0x800000, CRC(018627d4) SHA1(2519f39ad046d14f602648fed39bc3719185b55e) ) |
| 4777 | 4777 | |
| 4778 | 4778 | // 840-0035 2000 317-0281-COM Naomi |
| 4779 | | ROM_PARAMETER( ":rom_board:segam2crypt:key", "28132303" ) |
| 4779 | ROM_PARAMETER( ":rom_board:segam2crypt:key", "08132303" ) |
| 4780 | 4780 | ROM_END |
| 4781 | 4781 | |
| 4782 | 4782 | |
| r243230 | r243231 | |
| 4796 | 4796 | ROM_LOAD( "mpr-22915.ic6", 0x3000000, 0x800000, CRC(e48148ac) SHA1(c1273353eeaf9bb6b185f133281d7d04271bc895) ) |
| 4797 | 4797 | |
| 4798 | 4798 | // 840-0018 1999 317-0268-COM Naomi |
| 4799 | | ROM_PARAMETER( ":rom_board:segam2crypt:key", "2808ae51" ) |
| 4799 | ROM_PARAMETER( ":rom_board:segam2crypt:key", "0808ae51" ) |
| 4800 | 4800 | ROM_END |
| 4801 | 4801 | |
| 4802 | 4802 | /* |
| r243230 | r243231 | |
| 4853 | 4853 | ROM_LOAD("mpr-23340.ic17s",0x8800000, 0x0800000, CRC(001604f8) SHA1(615ec027d383d44d4aadb1175be6320e4139d7d1) ) |
| 4854 | 4854 | |
| 4855 | 4855 | // 840-0041 2000 317-0286-COM Naomi |
| 4856 | | ROM_PARAMETER( ":rom_board:segam2crypt:key", "281a66ca" ) |
| 4856 | ROM_PARAMETER( ":rom_board:segam2crypt:key", "081a66ca" ) |
| 4857 | 4857 | ROM_END |
| 4858 | 4858 | |
| 4859 | 4859 | |
| r243230 | r243231 | |
| 5061 | 5061 | ROM_LOAD("mpr-22160.ic19s",0x9800000, 0x0800000, CRC(579eef4e) SHA1(bfcabd57f623647053afcedcabfbc74e5736819f) ) |
| 5062 | 5062 | |
| 5063 | 5063 | // 840-0017 1999 317-0266-COM Naomi |
| 5064 | | ROM_PARAMETER( ":rom_board:segam2crypt:key", "280fea94" ) |
| 5064 | ROM_PARAMETER( ":rom_board:segam2crypt:key", "080fea94" ) |
| 5065 | 5065 | ROM_END |
| 5066 | 5066 | |
| 5067 | 5067 | /* |
| r243230 | r243231 | |
| 5154 | 5154 | ROM_LOAD("mpr-22965.ic16s",0x8000000, 0x0800000, CRC(8f7bfa8a) SHA1(19f137b1552978d232785c4408805b71835585c6) ) |
| 5155 | 5155 | |
| 5156 | 5156 | // 840-0020 1999 317-0270-COM Naomi |
| 5157 | | ROM_PARAMETER( ":rom_board:segam2crypt:key", "280a8b5d" ) |
| 5157 | ROM_PARAMETER( ":rom_board:segam2crypt:key", "080a8b5d" ) |
| 5158 | 5158 | ROM_END |
| 5159 | 5159 | |
| 5160 | 5160 | // prototype - only works with US BIOS |
| r243230 | r243231 | |
| 5182 | 5182 | ROM_LOAD("mpr-22965.ic16s",0x8000000, 0x0800000, CRC(8f7bfa8a) SHA1(19f137b1552978d232785c4408805b71835585c6) ) |
| 5183 | 5183 | |
| 5184 | 5184 | // 840-0020 1999 317-0270-COM Naomi |
| 5185 | | ROM_PARAMETER( ":rom_board:segam2crypt:key", "280a8b5d" ) |
| 5185 | ROM_PARAMETER( ":rom_board:segam2crypt:key", "080a8b5d" ) |
| 5186 | 5186 | ROM_END |
| 5187 | 5187 | |
| 5188 | 5188 | /* |
| r243230 | r243231 | |
| 5465 | 5465 | ROM_LOAD("mpr-22948.ic21s", 0xa800000, 0x0800000, CRC(1b0de917) SHA1(fd1742ea9bb2f1ce871ee3266171f26634e1c8e7) ) |
| 5466 | 5466 | |
| 5467 | 5467 | // 840-0021 2000 317-0271-COM Naomi |
| 5468 | | ROM_PARAMETER( ":rom_board:segam2crypt:key", "28068b58" ) |
| 5468 | ROM_PARAMETER( ":rom_board:segam2crypt:key", "08068b58" ) |
| 5469 | 5469 | ROM_END |
| 5470 | 5470 | |
| 5471 | 5471 | ROM_START( virnbap ) |
| r243230 | r243231 | |
| 5497 | 5497 | ROM_LOAD("mpr-22948.ic21s", 0xa800000, 0x0800000, CRC(1b0de917) SHA1(fd1742ea9bb2f1ce871ee3266171f26634e1c8e7) ) |
| 5498 | 5498 | |
| 5499 | 5499 | // 840-0021 2000 317-0271-COM Naomi |
| 5500 | | ROM_PARAMETER( ":rom_board:segam2crypt:key", "28068b58" ) |
| 5500 | ROM_PARAMETER( ":rom_board:segam2crypt:key", "08068b58" ) |
| 5501 | 5501 | ROM_END |
| 5502 | 5502 | |
| 5503 | 5503 | /* |
| r243230 | r243231 | |
| 5550 | 5550 | ROM_LOAD("mpr-21923.ic15s",0x7800000, 0x0400000, CRC(d127d9a5) SHA1(78c95357344ea15469b84fa8b1332e76521892cd) ) |
| 5551 | 5551 | |
| 5552 | 5552 | // 840-0010 1999 317-0258-COM Naomi |
| 5553 | | ROM_PARAMETER( ":rom_board:segam2crypt:key", "28088b08" ) |
| 5553 | ROM_PARAMETER( ":rom_board:segam2crypt:key", "08088b08" ) |
| 5554 | 5554 | ROM_END |
| 5555 | 5555 | |
| 5556 | 5556 | /* |
| r243230 | r243231 | |
| 5595 | 5595 | ROM_LOAD("mpr-22926.ic11",0x5800000, 0x0800000, CRC(57eec89d) SHA1(dd8f9a9155e51ee5260f559449fb0ea245077952) ) |
| 5596 | 5596 | |
| 5597 | 5597 | // 840-0015 1999 317-0263-COM Naomi |
| 5598 | | ROM_PARAMETER( ":rom_board:segam2crypt:key", "2803eb15" ) |
| 5598 | ROM_PARAMETER( ":rom_board:segam2crypt:key", "0803eb15" ) |
| 5599 | 5599 | ROM_END |
| 5600 | 5600 | |
| 5601 | 5601 | /* |
| r243230 | r243231 | |
| 5621 | 5621 | ROM_LOAD( "mpr-22269.ic8", 0x7800000, 0x1000000, CRC(6c0cf740) SHA1(da10b33a6e54afbe1d7e52801216e7119b0b33b1) ) |
| 5622 | 5622 | |
| 5623 | 5623 | // 840-0040 2000 317-0285-COM Naomi |
| 5624 | | ROM_PARAMETER( ":rom_board:segam2crypt:key", "281627c3" ) |
| 5624 | ROM_PARAMETER( ":rom_board:segam2crypt:key", "081627c3" ) |
| 5625 | 5625 | ROM_END |
| 5626 | 5626 | |
| 5627 | 5627 | ROM_START( mushik2e ) |
| r243230 | r243231 | |
| 5938 | 5938 | ROM_LOAD("mpr-21726.ic19s",0x9800000, 0x0800000, CRC(429bf290) SHA1(6733e1bcf100e73ab43273f6feedc187fcaa55d4) ) |
| 5939 | 5939 | |
| 5940 | 5940 | // 840-0003 1999 317-0249-COM Naomi |
| 5941 | | ROM_PARAMETER( ":rom_board:segam2crypt:key", "28012b41" ) |
| 5941 | ROM_PARAMETER( ":rom_board:segam2crypt:key", "08012b41" ) |
| 5942 | 5942 | ROM_END |
| 5943 | 5943 | |
| 5944 | 5944 | ROM_START( gunsur2 ) |
| r243230 | r243231 | |
| 6200 | 6200 | ROM_LOAD( "maz1ma8.4d", 0x8000000, 0x1000000, CRC(d46c9f40) SHA1(45eec7fa3d4261f12438e841254fa75d572331b3) ) |
| 6201 | 6201 | |
| 6202 | 6202 | // 25869812 2002 317-0266-COM Naomi |
| 6203 | | ROM_PARAMETER( ":rom_board:segam2crypt:key", "280fea94" ) |
| 6203 | ROM_PARAMETER( ":rom_board:segam2crypt:key", "080fea94" ) |
| 6204 | 6204 | ROM_END |
| 6205 | 6205 | |
| 6206 | 6206 | ROM_START( mazana ) |
| r243230 | r243231 | |
| 6219 | 6219 | ROM_LOAD( "maz1ma8.4d", 0x8000000, 0x1000000, CRC(d46c9f40) SHA1(45eec7fa3d4261f12438e841254fa75d572331b3) ) |
| 6220 | 6220 | |
| 6221 | 6221 | // 25869812 2002 317-0266-COM Naomi |
| 6222 | | ROM_PARAMETER( ":rom_board:segam2crypt:key", "280fea94" ) |
| 6222 | ROM_PARAMETER( ":rom_board:segam2crypt:key", "080fea94" ) |
| 6223 | 6223 | ROM_END |
| 6224 | 6224 | |
| 6225 | 6225 | ROM_START( vtenis2c ) |
| r243230 | r243231 | |
| 6392 | 6392 | ROM_LOAD( "ic16s.bin", 0x8000000, 0x800000, CRC(b8493dbe) SHA1(b641417e1bda49341e7ff86340072d74e3330665) ) |
| 6393 | 6393 | |
| 6394 | 6394 | // 840-0073 2001 317-0316-JPN Naomi |
| 6395 | | ROM_PARAMETER( ":rom_board:segam2crypt:key", "294bc3e3" ) |
| 6395 | ROM_PARAMETER( ":rom_board:segam2crypt:key", "094bc3e3" ) |
| 6396 | 6396 | ROM_END |
| 6397 | 6397 | |
| 6398 | 6398 | ROM_START( ringout ) |
| r243230 | r243231 | |
| 6413 | 6413 | ROM_LOAD( "mpr-21770.ic10", 0x5000000, 0x800000, CRC(c5308e61) SHA1(e51f8026351d5ffbda2a5bed39aeef543366febf) ) |
| 6414 | 6414 | |
| 6415 | 6415 | // 840-0004 1999 317-0250-COM Naomi |
| 6416 | | ROM_PARAMETER( ":rom_board:segam2crypt:key", "280b1e40" ) |
| 6416 | ROM_PARAMETER( ":rom_board:segam2crypt:key", "080b1e40" ) |
| 6417 | 6417 | ROM_END |
| 6418 | 6418 | |
| 6419 | 6419 | ROM_START( vonot ) |
| r243230 | r243231 | |
| 6437 | 6437 | ROM_LOAD( "mpr-23194.ic13s", 0x6800000, 0x800000, CRC(5adea0bd) SHA1(f8614ba83d5f61556c3db1a1796a02ed2c51ce2a) ) |
| 6438 | 6438 | |
| 6439 | 6439 | // 840-0028 2000 317-0279-COM Naomi |
| 6440 | | ROM_PARAMETER( ":rom_board:segam2crypt:key", "28010715" ) |
| 6440 | ROM_PARAMETER( ":rom_board:segam2crypt:key", "08010715" ) |
| 6441 | 6441 | ROM_END |
| 6442 | 6442 | |
| 6443 | 6443 | ROM_START( derbyo2k ) |
| r243230 | r243231 | |
| 7801 | 7801 | ROM_LOAD( "mpr-23662.ic11", 0xa800000, 0x0800000, CRC(d6ef7d68) SHA1(4ee396af6c5caf4c5af6e9ad0e03a7ac2c5039f4) ) |
| 7802 | 7802 | |
| 7803 | 7803 | // 840-0061 2001 317-0310-COM Naomi 2 |
| 7804 | | ROM_PARAMETER( ":rom_board:segam2crypt:key", "2cee834a" ) |
| 7804 | ROM_PARAMETER( ":rom_board:segam2crypt:key", "0cee834a" ) |
| 7805 | 7805 | ROM_END |
| 7806 | 7806 | |
| 7807 | 7807 | ROM_START( vstrik3cb ) |
| r243230 | r243231 | |
| 7823 | 7823 | ROM_LOAD( "mpr-23662.ic11", 0xa800000, 0x0800000, CRC(d6ef7d68) SHA1(4ee396af6c5caf4c5af6e9ad0e03a7ac2c5039f4) ) |
| 7824 | 7824 | |
| 7825 | 7825 | // 840-0061 2001 317-0310-COM Naomi 2 |
| 7826 | | ROM_PARAMETER( ":rom_board:segam2crypt:key", "2cee834a" ) |
| 7826 | ROM_PARAMETER( ":rom_board:segam2crypt:key", "0cee834a" ) |
| 7827 | 7827 | ROM_END |
| 7828 | 7828 | |
| 7829 | 7829 | ROM_START( wldrider ) |
| r243230 | r243231 | |
| 7844 | 7844 | ROM_LOAD( "mpr-23620.ic10", 0x9800000, 0x1000000, CRC(67aa15a9) SHA1(42c24cbf7069c27430a71509a872cd1c4224aaeb) ) |
| 7845 | 7845 | |
| 7846 | 7846 | // 840-0046 2001 317-0301-COM Naomi 2 |
| 7847 | | ROM_PARAMETER( ":rom_board:segam2crypt:key", "2ce7a703" ) |
| 7847 | ROM_PARAMETER( ":rom_board:segam2crypt:key", "0ce7a703" ) |
| 7848 | 7848 | ROM_END |
| 7849 | 7849 | |
| 7850 | 7850 | ROM_START( vf4cart ) |
| r243230 | r243231 | |
| 7866 | 7866 | ROM_LOAD( "mpr-23784.ic11", 0xa800000, 0x1000000, CRC(f74f2fee) SHA1(84b07baa6d116727e66ef27e24ba6484c3393891) ) |
| 7867 | 7867 | |
| 7868 | 7868 | // 840-0080 2002 317-0324-COM Naomi 2 |
| 7869 | | ROM_PARAMETER( ":rom_board:segam2crypt:key", "2eef2f96" ) |
| 7869 | ROM_PARAMETER( ":rom_board:segam2crypt:key", "0eef2f96" ) |
| 7870 | 7870 | ROM_END |
| 7871 | 7871 | |
| 7872 | 7872 | // There is also a development cart (171-7885A) with 20x 64Mb FlashROMs instead of 10x 128Mb MaskROMs. Content is the same. |
| r243230 | r243231 | |
| 7989 | 7989 | ROM_LOAD( "mpr-23703.ic11", 0xa800000, 0x1000000, CRC(702b8b4a) SHA1(3a8dfde458f341e7db20664382b9fce2b6e5d462) ) |
| 7990 | 7990 | |
| 7991 | 7991 | // 840-0062 2001 317-0313-COM Naomi 2 |
| 7992 | | ROM_PARAMETER( ":rom_board:segam2crypt:key", "2ce7d742" ) |
| 7992 | ROM_PARAMETER( ":rom_board:segam2crypt:key", "0ce7d742" ) |
| 7993 | 7993 | ROM_END |
| 7994 | 7994 | |
| 7995 | 7995 | ROM_START( clubkrtd ) |
| r243230 | r243231 | |
| 8033 | 8033 | ROM_LOAD( "mpr-23703.ic11", 0xa800000, 0x1000000, CRC(702b8b4a) SHA1(3a8dfde458f341e7db20664382b9fce2b6e5d462) ) |
| 8034 | 8034 | |
| 8035 | 8035 | // 840-0062 2001 317-0313-COM Naomi 2 |
| 8036 | | ROM_PARAMETER( ":rom_board:segam2crypt:key", "2ce7d742" ) |
| 8036 | ROM_PARAMETER( ":rom_board:segam2crypt:key", "0ce7d742" ) |
| 8037 | 8037 | ROM_END |
| 8038 | 8038 | |
| 8039 | 8039 | ROM_START( clubkprz ) |
| r243230 | r243231 | |
| 8066 | 8066 | ROM_LOAD( "at25010.ic3s", 0x000000, 0x000084, CRC(0142d8be) SHA1(5922b6c47b12b19e1fa7bbe9aae391905038a7ff) ) |
| 8067 | 8067 | |
| 8068 | 8068 | // 840-0062 2001 317-0313-COM Naomi 2 |
| 8069 | | ROM_PARAMETER( ":rom_board:segam2crypt:key", "2ce7d742" ) |
| 8069 | ROM_PARAMETER( ":rom_board:segam2crypt:key", "0ce7d742" ) |
| 8070 | 8070 | ROM_END |
| 8071 | 8071 | |
| 8072 | 8072 | ROM_START( clubkpzb ) |
| r243230 | r243231 | |
| 8095 | 8095 | ROM_COPY( "rom_board", 0x1000000, 0x400000, 0xc00000 ) |
| 8096 | 8096 | |
| 8097 | 8097 | // 840-0062 2001 317-0313-COM Naomi 2 |
| 8098 | | ROM_PARAMETER( ":rom_board:segam2crypt:key", "2ce7d742" ) |
| 8098 | ROM_PARAMETER( ":rom_board:segam2crypt:key", "0ce7d742" ) |
| 8099 | 8099 | |
| 8100 | 8100 | // this dump can't be used as main_eeprom, because that's exactly 0x80 bytes |
| 8101 | 8101 | ROM_REGION(0x84, "some_eeprom", 0) |
| r243230 | r243231 | |
| 8130 | 8130 | ROM_COPY( "rom_board", 0x1000000, 0x400000, 0xc00000 ) |
| 8131 | 8131 | |
| 8132 | 8132 | // 840-0062 2001 317-0313-COM Naomi 2 |
| 8133 | | ROM_PARAMETER( ":rom_board:segam2crypt:key", "2ce7d742" ) |
| 8133 | ROM_PARAMETER( ":rom_board:segam2crypt:key", "0ce7d742" ) |
| 8134 | 8134 | ROM_END |
| 8135 | 8135 | |
| 8136 | 8136 | // uses the same mask roms data as clubk2k3, but not in 32bit dissected form, EPR doesn't have checksumms for them, so rom test shows all roms as BAD |
trunk/src/mame/drivers/tx1.c
| r243230 | r243231 | |
| 795 | 795 | ROM_REGION( 0x10000, "audio_cpu", 0 ) |
| 796 | 796 | ROM_LOAD( "8411-136027-157.11", 0x00000, 0x2000, CRC(10ae3075) SHA1(69c5f62f2473aba848383eed3cecf15e273d86ca) ) |
| 797 | 797 | |
| 798 | | ROM_REGION( 0x8000, "char_tiles", 0 ) |
| 798 | ROM_REGION( 0x20000, "char_tiles", 0 ) |
| 799 | 799 | ROM_LOAD( "8411-136027-156.204", 0x0000, 0x4000, CRC(60f3c616) SHA1(59c4361891e4274e27e6279c919e8fd6803af7cf) ) |
| 800 | 800 | ROM_LOAD( "8411-136027-155.174", 0x4000, 0x4000, CRC(e59a6b72) SHA1(c10efa77ab421ac60b97227a8d547f50f8415670) ) |
| 801 | 801 | |
| 802 | | ROM_REGION( 0x10000, "obj_tiles", 0 ) |
| 802 | ROM_REGION( 0x40000, "obj_tiles", 0 ) |
| 803 | 803 | ROM_LOAD( "8411-136027-114.203", 0x0000, 0x4000, CRC(fc91328b) SHA1(e57fd2056b65d37cf2e1f0af56616c6555df3006) ) |
| 804 | 804 | ROM_LOAD( "8411-136027-116.258", 0x4000, 0x4000, CRC(5745f671) SHA1(6e471633cd6de9926b3361a84430c088e1f6a097) ) |
| 805 | 805 | ROM_LOAD( "8411-136027-115.173", 0x8000, 0x4000, CRC(720e5873) SHA1(151d9063c35b26f5876cf94bdf0c2665ec701bbd) ) |
| 806 | 806 | ROM_LOAD( "8411-136027-117.232", 0xc000, 0x4000, CRC(3c68d0bc) SHA1(2dbaf2a268b90214fd61c016ac945d4371057826) ) |
| 807 | 807 | |
| 808 | | ROM_REGION( 0x6000, "road", 0 ) |
| 808 | ROM_REGION( 0x40000, "gfx3", 0 ) |
| 809 | 809 | ROM_LOAD( "8411-136027-146.56", 0x0000, 0x2000, CRC(5635b8c1) SHA1(5cc9437a2ff0843f1917f2451852d4561c240b24) ) |
| 810 | 810 | ROM_LOAD( "8411-136027-147.66", 0x2000, 0x2000, CRC(03d83cf8) SHA1(5c0cfc6bf02ad2b3f37e1ceb493f69eb9829ab1e) ) |
| 811 | 811 | ROM_LOAD( "8411-136027-148.76", 0x4000, 0x2000, CRC(ad56013a) SHA1(ae3a91f58f30daff334754476db33ad1d12569fc) ) |
| r243230 | r243231 | |
| 816 | 816 | ROM_LOAD16_BYTE( "136027-143.ic223", 0x8000, 0x0200, CRC(22c77af6) SHA1(1be8585b95316b4fc5712cdaef699e676320cd4d) ) |
| 817 | 817 | ROM_LOAD16_BYTE( "136027-142.ic213", 0x8001, 0x0200, CRC(f6b8b70b) SHA1(b79374acf11d71db1e4ad3c494ac5f500a52677b) ) |
| 818 | 818 | |
| 819 | | ROM_REGION( 0x8000, "obj_map", 0 ) |
| 819 | ROM_REGION( 0x50000, "obj_map", 0 ) |
| 820 | 820 | ROM_LOAD( "8411-136027-119.106", 0x0000, 0x4000, CRC(88eec0fb) SHA1(81d7a69dc1a4b3b81d7f28d97a3f80697cdcc6eb) ) |
| 821 | 821 | ROM_LOAD( "8411-136027-120.73", 0x4000, 0x4000, CRC(407cbe65) SHA1(e1c11b65f3c6abde6d55afeaffdb39cdd6d66377) ) |
| 822 | 822 | |
| 823 | | ROM_REGION( 0x6000, "obj_luts", 0 ) |
| 823 | ROM_REGION( 0x50000, "user3", 0 ) |
| 824 | 824 | ROM_LOAD( "8411-136027-113.48", 0x0000, 0x2000, CRC(4b3d7956) SHA1(fc2432dd69f3be7007d4fd6f7c86c7c19453b1ba) ) |
| 825 | 825 | ROM_LOAD( "8411-136027-118.281", 0x2000, 0x4000, CRC(de418dc7) SHA1(1233e2f7499ec5a73a40ee336d3fe26c06187784) ) |
| 826 | 826 | |
| r243230 | r243231 | |
| 882 | 882 | ROM_REGION( 0x10000, "audio_cpu", 0 ) |
| 883 | 883 | ROM_LOAD( "tx1_22h.ic9", 0x00000, 0x2000, CRC(66376232) SHA1(b8a026dae47173e7760eea4f52e67e525ad1b70b) ) |
| 884 | 884 | |
| 885 | | ROM_REGION( 0x8000, "char_tiles", 0 ) |
| 885 | ROM_REGION( 0x20000, "char_tiles", 0 ) |
| 886 | 886 | ROM_LOAD( "tx1_21a.ic204", 0x0000, 0x4000, CRC(cd3441ad) SHA1(8e6597b3177b8aaa34ed3373d85fc4b6231e1333) ) |
| 887 | 887 | ROM_LOAD( "tx1_20a.ic174", 0x4000, 0x4000, CRC(dbe595fc) SHA1(1ed2f775f0a1b46a2ffbc056eb4ef732ed546d3c) ) |
| 888 | 888 | |
| 889 | | ROM_REGION( 0x10000, "obj_tiles", 0 ) |
| 889 | ROM_REGION( 0x40000, "obj_tiles", 0 ) |
| 890 | 890 | ROM_LOAD( "tx1_16b.ic203", 0x0000, 0x4000, CRC(1141c965) SHA1(4b90c1428bcbd72d0449c064856a5596269b3fc6) ) |
| 891 | 891 | ROM_LOAD( "tx1_18b.ic258", 0x4000, 0x4000, CRC(0ad36d68) SHA1(fd5a65c56557c1bc9c0f3916f15f62500b52bfe0) ) |
| 892 | 892 | ROM_LOAD( "tx1_15b.ic173", 0x8000, 0x4000, CRC(30d1a8d5) SHA1(b4c585b7b8a8920bb3949d643e9e10c17d4009a0) ) |
| 893 | 893 | ROM_LOAD( "tx1_17b.ic232", 0xc000, 0x4000, CRC(364bb354) SHA1(a26581ca1088b979285471e2c6595048df84d75e) ) |
| 894 | 894 | |
| 895 | | ROM_REGION( 0x6000, "road", 0 ) |
| 895 | ROM_REGION( 0x40000, "gfx3", 0 ) |
| 896 | 896 | ROM_LOAD( "tx1_5a.ic56", 0x0000, 0x2000, CRC(5635b8c1) SHA1(5cc9437a2ff0843f1917f2451852d4561c240b24) ) |
| 897 | 897 | ROM_LOAD( "tx1_6a.ic66", 0x2000, 0x2000, CRC(03d83cf8) SHA1(5c0cfc6bf02ad2b3f37e1ceb493f69eb9829ab1e) ) |
| 898 | 898 | ROM_LOAD( "tx1_7a.ic76", 0x4000, 0x2000, CRC(ad56013a) SHA1(ae3a91f58f30daff334754476db33ad1d12569fc) ) |
| r243230 | r243231 | |
| 903 | 903 | ROM_LOAD16_BYTE( "xb02b.ic223", 0x8000, 0x0200, CRC(22c77af6) SHA1(1be8585b95316b4fc5712cdaef699e676320cd4d) ) |
| 904 | 904 | ROM_LOAD16_BYTE( "xb01b.ic213", 0x8001, 0x0200, CRC(f6b8b70b) SHA1(b79374acf11d71db1e4ad3c494ac5f500a52677b) ) |
| 905 | 905 | |
| 906 | | ROM_REGION( 0x8000, "obj_map", 0 ) |
| 906 | ROM_REGION( 0x50000, "obj_map", 0 ) |
| 907 | 907 | ROM_LOAD( "tx1_14b.ic106", 0x0000, 0x4000, CRC(68c63d6e) SHA1(110e02b99c44d31041be588bd14642e26890ecbd) ) |
| 908 | 908 | ROM_LOAD( "tx1_13b.ic73", 0x4000, 0x4000, CRC(b0c581b2) SHA1(20926bc15e7c97045b219b828acfcdd99b8712a6) ) |
| 909 | 909 | |
| 910 | | ROM_REGION( 0x6000, "obj_luts", 0 ) |
| 910 | ROM_REGION( 0x50000, "user3", 0 ) |
| 911 | 911 | ROM_LOAD( "tx1_12b.ic48", 0x0000, 0x2000, CRC(4b3d7956) SHA1(fc2432dd69f3be7007d4fd6f7c86c7c19453b1ba) ) |
| 912 | 912 | ROM_LOAD( "tx1_19b.ic281", 0x2000, 0x4000, CRC(cb250de6) SHA1(4bf3006986fb8cbb3dd4fa988e6471633614e4bb) ) |
| 913 | 913 | |
| r243230 | r243231 | |
| 963 | 963 | ROM_REGION( 0x10000, "audio_cpu", 0 ) /* Label was missing */ |
| 964 | 964 | ROM_LOAD( "8411-136027-157.11", 0x00000, 0x2000, CRC(10ae3075) SHA1(69c5f62f2473aba848383eed3cecf15e273d86ca) ) /* Unconfirmed TC013A or the later TC013B */ |
| 965 | 965 | |
| 966 | | ROM_REGION( 0x8000, "char_tiles", 0 ) |
| 966 | ROM_REGION( 0x20000, "char_tiles", 0 ) |
| 967 | 967 | ROM_LOAD( "tx1_21a.ic204", 0x0000, 0x4000, CRC(cd3441ad) SHA1(8e6597b3177b8aaa34ed3373d85fc4b6231e1333) ) |
| 968 | 968 | ROM_LOAD( "tx1_20a.ic174", 0x4000, 0x4000, CRC(dbe595fc) SHA1(1ed2f775f0a1b46a2ffbc056eb4ef732ed546d3c) ) |
| 969 | 969 | |
| 970 | | ROM_REGION( 0x10000, "obj_tiles", 0 ) |
| 970 | ROM_REGION( 0x40000, "obj_tiles", 0 ) |
| 971 | 971 | ROM_LOAD( "tx1_16b.ic203", 0x0000, 0x4000, CRC(1141c965) SHA1(4b90c1428bcbd72d0449c064856a5596269b3fc6) ) |
| 972 | 972 | ROM_LOAD( "tx1_18b.ic258", 0x4000, 0x4000, CRC(0ad36d68) SHA1(fd5a65c56557c1bc9c0f3916f15f62500b52bfe0) ) |
| 973 | 973 | ROM_LOAD( "tx1_15b.ic173", 0x8000, 0x4000, CRC(30d1a8d5) SHA1(b4c585b7b8a8920bb3949d643e9e10c17d4009a0) ) |
| 974 | 974 | ROM_LOAD( "tx1_17b.ic232", 0xc000, 0x4000, CRC(364bb354) SHA1(a26581ca1088b979285471e2c6595048df84d75e) ) |
| 975 | 975 | |
| 976 | | ROM_REGION( 0x6000, "road", 0 ) |
| 976 | ROM_REGION( 0x40000, "gfx3", 0 ) |
| 977 | 977 | ROM_LOAD( "tx1_5a.ic56", 0x0000, 0x2000, CRC(5635b8c1) SHA1(5cc9437a2ff0843f1917f2451852d4561c240b24) ) |
| 978 | 978 | ROM_LOAD( "tx1_6a.ic66", 0x2000, 0x2000, CRC(03d83cf8) SHA1(5c0cfc6bf02ad2b3f37e1ceb493f69eb9829ab1e) ) |
| 979 | 979 | ROM_LOAD( "tx1_7a.ic76", 0x4000, 0x2000, CRC(ad56013a) SHA1(ae3a91f58f30daff334754476db33ad1d12569fc) ) |
| r243230 | r243231 | |
| 984 | 984 | ROM_LOAD16_BYTE( "xb02b.ic223", 0x8000, 0x0200, CRC(22c77af6) SHA1(1be8585b95316b4fc5712cdaef699e676320cd4d) ) |
| 985 | 985 | ROM_LOAD16_BYTE( "xb01b.ic213", 0x8001, 0x0200, CRC(f6b8b70b) SHA1(b79374acf11d71db1e4ad3c494ac5f500a52677b) ) |
| 986 | 986 | |
| 987 | | ROM_REGION( 0x8000, "obj_map", 0 ) |
| 987 | ROM_REGION( 0x50000, "obj_map", 0 ) |
| 988 | 988 | ROM_LOAD( "tx1_14b.ic106", 0x0000, 0x4000, CRC(68c63d6e) SHA1(110e02b99c44d31041be588bd14642e26890ecbd) ) |
| 989 | 989 | ROM_LOAD( "tx1_13b.ic73", 0x4000, 0x4000, CRC(b0c581b2) SHA1(20926bc15e7c97045b219b828acfcdd99b8712a6) ) |
| 990 | 990 | |
| 991 | | ROM_REGION( 0x6000, "obj_luts", 0 ) |
| 991 | ROM_REGION( 0x50000, "user3", 0 ) |
| 992 | 992 | ROM_LOAD( "tx1_12b.ic48", 0x0000, 0x2000, CRC(4b3d7956) SHA1(fc2432dd69f3be7007d4fd6f7c86c7c19453b1ba) ) |
| 993 | 993 | ROM_LOAD( "tx1_19b.ic281", 0x2000, 0x4000, CRC(cb250de6) SHA1(4bf3006986fb8cbb3dd4fa988e6471633614e4bb) ) |
| 994 | 994 | |
| r243230 | r243231 | |
| 1072 | 1072 | ROM_LOAD( "bug25.157", 0x2c000, 0x4000, CRC(80c4e045) SHA1(be3b537d3ed3ee74fc51059aa744dca4d63431f6) ) |
| 1073 | 1073 | ROM_RELOAD( 0x38000, 0x4000 ) |
| 1074 | 1074 | |
| 1075 | | ROM_REGION( 0x8000, "road", 0 ) |
| 1075 | ROM_REGION( 0x40000, "road", 0 ) |
| 1076 | 1076 | ROM_LOAD( "bug12.58", 0x0000, 0x2000, CRC(bd34d55c) SHA1(05a719a6eff5af3aaaa1e0ee783b18597582ed64) ) |
| 1077 | 1077 | ROM_LOAD( "bug11.57", 0x2000, 0x2000, CRC(a44d43eb) SHA1(c4d68c7e123506acaa6adc353579cac19ecb3a9d) ) |
| 1078 | 1078 | ROM_LOAD( "bb3.137", 0x4000, 0x0200, CRC(ad76f3fb) SHA1(bf96f903b32e009a2592df0f28cc3e20b039f4d4) ) |
| r243230 | r243231 | |
| 1086 | 1086 | ROM_LOAD16_BYTE( "bb1.245", 0x8000, 0x0200, CRC(0ddbd36d) SHA1(7a08901a350c315d46ab8d0aa881db384b9f37d2) ) |
| 1087 | 1087 | ROM_LOAD16_BYTE( "bb2.220", 0x8001, 0x0200, CRC(71d47de1) SHA1(2da9aeb3f2ebb1114631c8042a37c4f4c18e741b) ) |
| 1088 | 1088 | |
| 1089 | | ROM_REGION( 0x10000, "obj_map", 0 ) |
| 1089 | ROM_REGION( 0x100000, "obj_map", 0 ) |
| 1090 | 1090 | ROM_LOAD( "bug16.210", 0x0000, 0x4000, CRC(8b64409e) SHA1(1fb4c6923e6a9e1f2a63a2c335b63e2bdc44b61f) ) |
| 1091 | 1091 | ROM_LOAD( "bug14.209", 0x4000, 0x4000, CRC(4e765282) SHA1(f7d69d39823a8b33bd0e5b1bd78a5d68a293e221) ) |
| 1092 | 1092 | ROM_LOAD( "bug17.182", 0x8000, 0x4000, CRC(a5d84df6) SHA1(4e33ef0bee383e0d47b0c679cd2a54edb7ca0e3e) ) |
| 1093 | 1093 | ROM_LOAD( "bug15.181", 0xc000, 0x4000, CRC(d519de10) SHA1(535d05e11af65be65f3d9924b0c48faf8dcfd1bf) ) |
| 1094 | 1094 | |
| 1095 | | ROM_REGION( 0x6000, "obj_luts", 0 ) |
| 1095 | ROM_REGION( 0x10000, "obj_luts", 0 ) |
| 1096 | 1096 | ROM_LOAD( "bug13.124", 0x0000, 0x2000, CRC(53604d7a) SHA1(bfa304cd885162ece7a5f54988d9880fc541eb3a) ) |
| 1097 | 1097 | ROM_LOAD( "bug18.156", 0x2000, 0x4000, CRC(e58321a6) SHA1(81be87d3c6046bb375c74362dc940f0269b39d1d) ) |
| 1098 | 1098 | |
| r243230 | r243231 | |
| 1161 | 1161 | ROM_LOAD( "bug30s.145", 0x20000, 0x8000, CRC(11d8e2a8) SHA1(9bf198229a12d331e8e7352b7ee3f39f6891f517) ) |
| 1162 | 1162 | ROM_LOAD( "bug23s.142", 0x28000, 0x8000, CRC(015db5d8) SHA1(39ef8b44f2eb9399fb1555cffa6763e06d59c181) ) |
| 1163 | 1163 | |
| 1164 | | ROM_REGION( 0x8000, "road", 0 ) |
| 1164 | ROM_REGION( 0x40000, "road", 0 ) |
| 1165 | 1165 | ROM_LOAD( "bug11s.225",0x0000, 0x4000, CRC(771af4e1) SHA1(a42b164dd0567c78c0d308ee48d63e5a284897bb) ) |
| 1166 | 1166 | ROM_LOAD( "bb3s.195", 0x4000, 0x0200, CRC(2ab3d5ff) SHA1(9f8359cb4ba2e7d15dbb9dc21cd71c0902cd2153) ) |
| 1167 | 1167 | ROM_LOAD( "bb4s.193", 0x4200, 0x0200, CRC(630f68a4) SHA1(d730f050353c688f81d090e33e00cd35e7b7b6fa) ) |
| r243230 | r243231 | |
| 1174 | 1174 | ROM_LOAD16_BYTE( "bb1.163", 0x8000, 0x0200, CRC(0ddbd36d) SHA1(7a08901a350c315d46ab8d0aa881db384b9f37d2) ) |
| 1175 | 1175 | ROM_LOAD16_BYTE( "bb2.162", 0x8001, 0x0200, CRC(71d47de1) SHA1(2da9aeb3f2ebb1114631c8042a37c4f4c18e741b) ) |
| 1176 | 1176 | |
| 1177 | | ROM_REGION( 0x10000, "obj_map", 0 ) |
| 1177 | ROM_REGION( 0x100000, "obj_map", 0 ) |
| 1178 | 1178 | ROM_LOAD( "bug16s.139", 0x0000, 0x8000, CRC(1903a9ad) SHA1(526c404c15e3f04b4afb27dee66e9deb0a6b9704) ) |
| 1179 | 1179 | ROM_LOAD( "bug17s.140", 0x8000, 0x8000, CRC(82cabdd4) SHA1(94324fcf83c373621fc40553473ae3cb552ab704) ) |
| 1180 | 1180 | |
| 1181 | | ROM_REGION( 0x6000, "obj_luts", 0 ) |
| 1181 | ROM_REGION( 0x10000, "obj_luts", 0 ) |
| 1182 | 1182 | ROM_LOAD( "bug13.32", 0x0000, 0x2000, CRC(53604d7a) SHA1(bfa304cd885162ece7a5f54988d9880fc541eb3a) ) |
| 1183 | 1183 | ROM_LOAD( "bug18s.141", 0x2000, 0x4000, CRC(67786327) SHA1(32cc1f5bc654497c968ddcd4af29720c6d659482) ) |
| 1184 | 1184 | |
trunk/src/mame/machine/315-5838_317-0229_comp.c
| r243230 | r243231 | |
| 1 | 1 | /* Sega Compression (and possibly encryption) device |
| 2 | 2 | |
| 3 | | 315-5838 - Decathlete (ST-V) |
| 4 | | 317-0229 - Dead or Alive (Model 2A) |
| 3 | 315-5838 - Decathlete (ST-V) |
| 4 | 317-0229 - Dead or Alive (Model 2A) |
| 5 | 5 | |
| 6 | | Package Type: TQFP100 |
| 6 | Package Type: TQFP100 |
| 7 | 7 | |
| 8 | | This appears to be a dual channel compression chip, used in 1996, predating the 5881. |
| 9 | | Decathlete uses it to compress ALL the game graphics, Dead or Alive uses it for a |
| 10 | | dumb security check, decompressing a single string. |
| 8 | This appears to be a dual channel compression chip, used in 1996, predating the 5881. |
| 9 | Decathlete uses it to compress ALL the game graphics, Dead or Alive uses it for a |
| 10 | dumb security check, decompressing a single string. |
| 11 | 11 | |
| 12 | | Each channel appears to be connected to a different set of ROMs, however there is |
| 13 | | defintiely only a single 315-5838 chip. (could the different channels actually just |
| 14 | | be mirror addresses, with part of the address determining the ROMs to use?) |
| 12 | Each channel appears to be connected to a different set of ROMs, however there is |
| 13 | defintiely only 315-5838 single chip. |
| 15 | 14 | |
| 16 | | Dead of Alive only uses a single channel, and has the source data in RAM, not ROM. |
| 17 | | This is similar to how some 5881 games were set up, with the ST-V versions decrypting |
| 18 | | data directly from ROM and the Model 2 ones using a RAM source buffer. |
| 15 | Dead of Alive only uses a single channel, and has the source data in RAM, not ROM. |
| 16 | This is similar to how some 5881 games were set up, with the ST-V versions decrypting |
| 17 | data directly from ROM and the Model 2 ones using a RAM source buffer. |
| 19 | 18 | |
| 20 | | Looking at the values read I don't think there is any address based encryption, for |
| 21 | | example many blocks where you'd expect a zero fill start with repeating patterns |
| 22 | | of 8f708f70 (different lengths) channel would appear to relate to compressed 0x00 data |
| 19 | Looking at the values read I don't think there is any address based encryption, for |
| 20 | example many blocks where you'd expect a zero fill start with repeating patterns |
| 21 | of 8f708f70 (different lengths) which would appear to relate to compressed 0x00 data |
| 23 | 22 | |
| 24 | | read addr 0071253c, blah_r 8f708f70 - read count count 00000004 |
| 25 | | read addr 00712540, blah_r 8f708f70 - read count count 00000008 |
| 26 | | read addr 00712544, blah_r 8f708f70 - read count count 0000000c |
| 27 | | read addr 00712548, blah_r 8f708f70 - read count count 00000010 |
| 28 | | read addr 0071254c, blah_r 8f708f70 - read count count 00000014 |
| 29 | | read addr 00712550, blah_r 8f708f70 - read count count 00000018 |
| 30 | | read addr 00712554, blah_r 8f708f70 - read count count 0000001c |
| 23 | read addr 0071253c, blah_r 8f708f70 - read count count 00000004 |
| 24 | read addr 00712540, blah_r 8f708f70 - read count count 00000008 |
| 25 | read addr 00712544, blah_r 8f708f70 - read count count 0000000c |
| 26 | read addr 00712548, blah_r 8f708f70 - read count count 00000010 |
| 27 | read addr 0071254c, blah_r 8f708f70 - read count count 00000014 |
| 28 | read addr 00712550, blah_r 8f708f70 - read count count 00000018 |
| 29 | read addr 00712554, blah_r 8f708f70 - read count count 0000001c |
| 31 | 30 | |
| 32 | 31 | */ |
| 33 | 32 | |
| r243230 | r243231 | |
| 47 | 46 | |
| 48 | 47 | void sega_315_5838_comp_device::device_start() |
| 49 | 48 | { |
| 50 | | for (int i = 0; i < 2; i++) |
| 51 | | { |
| 52 | | m_channel[i].m_decathlt_lastcount = 0; |
| 53 | | m_channel[i].m_decathlt_prot_uploadmode = 0; |
| 54 | | m_channel[i].m_decathlt_prot_uploadoffset = 0; |
| 55 | | m_channel[i].m_read_ch.bind_relative_to(*owner()); |
| 49 | m_decathlt_lastcount = 0; |
| 50 | m_decathlt_prot_uploadmode = 0; |
| 51 | m_decathlt_prot_uploadoffset = 0; |
| 56 | 52 | |
| 57 | | } |
| 53 | m_read_ch1.bind_relative_to(*owner()); |
| 54 | m_read_ch2.bind_relative_to(*owner()); |
| 58 | 55 | } |
| 59 | 56 | |
| 60 | 57 | void sega_315_5838_comp_device::device_reset() |
| 61 | 58 | { |
| 62 | | for (int i = 0; i < 2; i++) |
| 63 | | { |
| 64 | | m_channel[i].m_srcoffset = 0; |
| 65 | | m_channel[i].m_decathlt_lastcount = 0; |
| 66 | | m_channel[i].m_decathlt_prot_uploadmode = 0; |
| 67 | | m_channel[i].m_decathlt_prot_uploadoffset = 0; |
| 68 | | } |
| 59 | memset(m_decathlt_protregs, 0, sizeof(m_decathlt_protregs)); |
| 60 | m_decathlt_lastcount = 0; |
| 61 | m_decathlt_prot_uploadmode = 0; |
| 62 | m_decathlt_prot_uploadoffset = 0; |
| 63 | m_decathlt_part = 1; |
| 69 | 64 | |
| 70 | 65 | m_protstate = 0; |
| 71 | 66 | } |
| r243230 | r243231 | |
| 82 | 77 | #endif |
| 83 | 78 | |
| 84 | 79 | |
| 85 | | READ32_MEMBER(sega_315_5838_comp_device::decathlt_prot1_r) |
| 80 | READ32_MEMBER(sega_315_5838_comp_device::decathlt_prot_r) |
| 86 | 81 | { |
| 87 | | return genericdecathlt_prot_r(mem_mask, 0); |
| 82 | return genericdecathlt_prot_r(offset, mem_mask, 0); |
| 88 | 83 | } |
| 89 | 84 | |
| 90 | | READ32_MEMBER(sega_315_5838_comp_device::decathlt_prot2_r) |
| 85 | READ32_MEMBER(sega_315_5838_comp_device::decathlt_prot_ch2_r) |
| 91 | 86 | { |
| 92 | | return genericdecathlt_prot_r(mem_mask, 1); |
| 87 | return genericdecathlt_prot_r(offset, mem_mask, 1); |
| 93 | 88 | } |
| 94 | 89 | |
| 95 | 90 | |
| 96 | | UINT32 sega_315_5838_comp_device::genericdecathlt_prot_r(UINT32 mem_mask, int channel) |
| 91 | UINT32 sega_315_5838_comp_device::genericdecathlt_prot_r(UINT32 offset, UINT32 mem_mask, int which) |
| 97 | 92 | { |
| 98 | | // UINT32 *fake0 = (UINT32*)memregion( ":fake0" )->base(); |
| 99 | | // UINT32 retvalue = 0xffff; |
| 100 | 93 | |
| 101 | | switch (m_channel[channel].m_srcoffset) |
| 94 | // UINT32 *fake0 = (UINT32*)memregion( ":fake0" )->base(); |
| 95 | |
| 96 | if (offset==2) |
| 102 | 97 | { |
| 103 | | default: |
| 98 | // UINT32 retvalue = 0xffff; |
| 104 | 99 | |
| 105 | | m_channel[channel].m_decathlt_lastcount++; |
| 100 | switch (m_decathlt_protregs[0]) |
| 101 | { |
| 102 | default: |
| 106 | 103 | |
| 107 | | UINT32 tempdata = 0; |
| 108 | | tempdata |= m_channel[channel].m_read_ch(m_channel[channel].m_srcoffset) << 0; |
| 109 | | m_channel[channel].m_srcoffset++; |
| 110 | | tempdata |= m_channel[channel].m_read_ch(m_channel[channel].m_srcoffset) << 16; |
| 111 | | m_channel[channel].m_srcoffset++; |
| 104 | m_decathlt_lastcount++; |
| 112 | 105 | |
| 106 | UINT32 tempdata = 0; |
| 113 | 107 | |
| 114 | | #ifdef DEBUG_DATA_DUMP |
| 115 | | //printf("read addr %08x, blah_r %08x - read count count %08x\n", m_channel[channel].m_srcoffset*2, tempdata, m_channel[channel].m_decathlt_lastcount*4); |
| 116 | | fwrite(&tempdata, 1, 4, tempfile); |
| 117 | | #else |
| 118 | | logerror("read addr %08x, blah_r %08x - read count count %08x\n", m_channel[channel].m_srcoffset*2, tempdata, m_channel[channel].m_decathlt_lastcount*4); |
| 119 | | #endif |
| 108 | if (which == 0) |
| 109 | { |
| 110 | tempdata |= m_read_ch1(m_decathlt_protregs[0]) << 16; |
| 111 | m_decathlt_protregs[0]++; |
| 112 | tempdata |= m_read_ch1(m_decathlt_protregs[0]) << 0; |
| 113 | m_decathlt_protregs[0]++; |
| 114 | } |
| 115 | else |
| 116 | { |
| 117 | tempdata |= m_read_ch2(m_decathlt_protregs[0]) << 16; |
| 118 | m_decathlt_protregs[0]++; |
| 119 | tempdata |= m_read_ch2(m_decathlt_protregs[0]) << 0; |
| 120 | m_decathlt_protregs[0]++; |
| 121 | } |
| 120 | 122 | |
| 121 | | return tempdata; |
| 123 | #ifdef DEBUG_DATA_DUMP |
| 124 | //printf("read addr %08x, blah_r %08x - read count count %08x\n", m_decathlt_protregs[0]*2, tempdata, m_decathlt_lastcount*4); |
| 125 | fwrite(&tempdata, 1, 4, tempfile); |
| 126 | #else |
| 127 | logerror("read addr %08x, blah_r %08x - read count count %08x\n", m_decathlt_protregs[0]*2, tempdata, m_decathlt_lastcount*4); |
| 128 | #endif |
| 129 | |
| 130 | return tempdata; |
| 122 | 131 | #if 0 |
| 123 | | case 0x03228e4: |
| 124 | | if (fake0) retvalue = fake0[(((0x20080/4)+m_channel[channel].m_decathlt_lastcount))]; |
| 125 | | m_channel[channel].m_decathlt_lastcount++; |
| 126 | | return retvalue; |
| 132 | case 0x03228e4: |
| 133 | if (fake0) retvalue = fake0[(((0x20080/4)+m_decathlt_lastcount))]; |
| 134 | m_decathlt_lastcount++; |
| 135 | return retvalue; |
| 127 | 136 | |
| 128 | | case 0x00a9f3a: |
| 129 | | if (fake0) retvalue = fake0[(((0x00000/4)+m_channel[channel].m_decathlt_lastcount))]; |
| 130 | | m_channel[channel].m_decathlt_lastcount++; |
| 131 | | return retvalue; |
| 137 | case 0x00a9f3a: |
| 138 | if (fake0) retvalue = fake0[(((0x00000/4)+m_decathlt_lastcount))]; |
| 139 | m_decathlt_lastcount++; |
| 140 | return retvalue; |
| 132 | 141 | |
| 133 | | case 0x0213ab4: |
| 134 | | if (fake0) retvalue = fake0[(((0x40000/4)+m_channel[channel].m_decathlt_lastcount))]; |
| 135 | | m_channel[channel].m_decathlt_lastcount++; |
| 136 | | return retvalue; |
| 142 | case 0x0213ab4: |
| 143 | if (fake0) retvalue = fake0[(((0x40000/4)+m_decathlt_lastcount))]; |
| 144 | m_decathlt_lastcount++; |
| 145 | return retvalue; |
| 137 | 146 | |
| 138 | | case 0x01efaf0: |
| 139 | | if (fake0) retvalue = fake0[(((0x60000/4)+m_channel[channel].m_decathlt_lastcount))]; |
| 140 | | m_channel[channel].m_decathlt_lastcount++; |
| 141 | | return retvalue; |
| 147 | case 0x01efaf0: |
| 148 | if (fake0) retvalue = fake0[(((0x60000/4)+m_decathlt_lastcount))]; |
| 149 | m_decathlt_lastcount++; |
| 150 | return retvalue; |
| 142 | 151 | |
| 143 | | case 0x033f16c: |
| 144 | | case 0x038929c: |
| 152 | case 0x033f16c: |
| 153 | case 0x038929c: |
| 145 | 154 | |
| 146 | 155 | |
| 147 | 156 | |
| 148 | | case 0x00de05a: |
| 149 | | case 0x0334258: |
| 150 | | case 0x019fb82: |
| 151 | | case 0x033dbf6: |
| 152 | | case 0x0011ac6: |
| 153 | | case 0x00060dc: |
| 154 | | case 0x0000002: |
| 155 | | case 0x0008c90: |
| 156 | | case 0x035cdc8: |
| 157 | | case 0x0327960: |
| 158 | | case 0x0329b8c: |
| 159 | | case 0x00d6e92: |
| 160 | | case 0x000081e: |
| 161 | | case 0x00035d6: |
| 162 | | case 0x00089a6: |
| 163 | | case 0x03315f4: |
| 164 | | case 0x0023fe0: |
| 165 | | case 0x001e290: |
| 166 | | case 0x0026e86: |
| 167 | | case 0x0012494: |
| 168 | | case 0x001b35a: |
| 169 | | case 0x0018424: |
| 157 | case 0x00de05a: |
| 158 | case 0x0334258: |
| 159 | case 0x019fb82: |
| 160 | case 0x033dbf6: |
| 161 | case 0x0011ac6: |
| 162 | case 0x00060dc: |
| 163 | case 0x0000002: |
| 164 | case 0x0008c90: |
| 165 | case 0x035cdc8: |
| 166 | case 0x0327960: |
| 167 | case 0x0329b8c: |
| 168 | case 0x00d6e92: |
| 169 | case 0x000081e: |
| 170 | case 0x00035d6: |
| 171 | case 0x00089a6: |
| 172 | case 0x03315f4: |
| 173 | case 0x0023fe0: |
| 174 | case 0x001e290: |
| 175 | case 0x0026e86: |
| 176 | case 0x0012494: |
| 177 | case 0x001b35a: |
| 178 | case 0x0018424: |
| 170 | 179 | |
| 171 | | return retvalue; |
| 180 | return retvalue; |
| 172 | 181 | #endif |
| 182 | } |
| 183 | |
| 184 | |
| 173 | 185 | } |
| 186 | else |
| 187 | { |
| 188 | logerror("%06x Decathlete prot R offset %04x mask %08x regs %08x, %08x, %08x, %08x\n", safe_pc(), offset, mem_mask, m_decathlt_protregs[0], m_decathlt_protregs[1], m_decathlt_protregs[2], m_decathlt_protregs[3]); |
| 189 | } |
| 174 | 190 | |
| 175 | | return 0xffffffff; |
| 191 | return m_decathlt_protregs[offset]; |
| 176 | 192 | } |
| 177 | 193 | |
| 178 | | void sega_315_5838_comp_device::set_prot_addr(UINT32 data, UINT32 mem_mask, int channel) |
| 194 | |
| 195 | void sega_315_5838_comp_device::write_prot_data(UINT32 data, UINT32 mem_mask, int offset, int which) |
| 179 | 196 | { |
| 180 | | // printf("set_prot_addr\n"); |
| 181 | | COMBINE_DATA(&m_channel[channel].m_srcoffset); |
| 182 | 197 | |
| 183 | | //if (m_decathlt_part==0) logerror("%d, last read count was %06x\n",channel, m_channel[channel].m_decathlt_lastcount*4); |
| 184 | | m_channel[channel].m_decathlt_lastcount = 0; |
| 198 | printf("write_prot_data %08x %08x %08x\n", offset, data, mem_mask); |
| 185 | 199 | |
| 186 | | if (mem_mask == 0x0000ffff) |
| 200 | m_decathlt_protregs[offset] = (data&mem_mask)|(m_decathlt_protregs[offset]&~mem_mask); |
| 201 | // m_decathlt_protregs[0] = 0x0c00000/4; |
| 202 | |
| 203 | if (offset==0) // seems to set a source address |
| 187 | 204 | { |
| 188 | | printf("set source address to %08x (channel %d)\n", m_channel[channel].m_srcoffset, channel); |
| 189 | | } |
| 205 | m_decathlt_part ^=1; |
| 190 | 206 | |
| 207 | //if (m_decathlt_part==0) logerror("%d, last read count was %06x\n",which, m_decathlt_lastcount*4); |
| 208 | m_decathlt_lastcount = 0; |
| 209 | if (m_decathlt_part==1) logerror("%d Decathlete prot W offset %04x data %08x, %08x, >>> regs %08x <<<<, %08x, %08x, %08x\n",which, offset, data, m_decathlt_protregs[0], m_decathlt_protregs[0]*4, m_decathlt_protregs[1], m_decathlt_protregs[2], m_decathlt_protregs[3]); |
| 191 | 210 | |
| 192 | 211 | #ifdef DEBUG_DATA_DUMP |
| 193 | | if (mem_mask == 0x0000ffff) |
| 194 | | { |
| 195 | | if (tempfile) |
| 196 | | fclose(tempfile); |
| 197 | | |
| 198 | | char filename[256]; |
| 199 | | sprintf(filename, "%d_compressed_%08x", channel, m_channel[channel].m_srcoffset * 2); |
| 200 | | tempfile = fopen(filename, "w+b"); |
| 201 | | |
| 202 | | // the table and dictionary are uploaded repeatedly, usually before groups of data transfers but |
| 203 | | // it's always the same tables (one pair for each channel) |
| 212 | if (mem_mask == 0x0000ffff) |
| 204 | 213 | { |
| 205 | | FILE* fp; |
| 206 | | sprintf(filename, "%d_compressed_table1", channel); |
| 207 | | fp = fopen(filename, "w+b"); |
| 208 | | fwrite(&m_channel[channel].m_decathlt_prottable1, 24, 2, fp); |
| 209 | | fclose(fp); |
| 210 | | } |
| 214 | if (tempfile) |
| 215 | fclose(tempfile); |
| 211 | 216 | |
| 212 | | { |
| 213 | | FILE* fp; |
| 214 | | sprintf(filename, "%d_compressed_dictionary", channel); |
| 215 | | fp = fopen(filename, "w+b"); |
| 216 | | fwrite(&m_channel[channel].m_decathlt_dictionary, 128, 2, fp); |
| 217 | | fclose(fp); |
| 217 | char filename[256]; |
| 218 | sprintf(filename, "%d_compressed_%08x", which, m_decathlt_protregs[0] ); |
| 219 | tempfile = fopen(filename, "w+b"); |
| 218 | 220 | } |
| 219 | | } |
| 220 | 221 | #endif |
| 221 | 222 | |
| 222 | | } |
| 223 | | |
| 224 | | void sega_315_5838_comp_device::set_upload_mode(UINT16 data, int channel) |
| 225 | | { |
| 226 | | if ((data == 0x8000) || (data == 0x0000)) |
| 227 | | { |
| 228 | | // logerror("changed to upload mode 1\n"); |
| 229 | | m_channel[channel].m_decathlt_prot_uploadmode = 1; |
| 230 | | m_channel[channel].m_decathlt_prot_uploadoffset = 0; |
| 231 | 223 | } |
| 232 | | else if ((data == 0x8080) || (data == 0x0080)) |
| 233 | | { |
| 234 | | m_channel[channel].m_decathlt_prot_uploadmode = 2; |
| 235 | | m_channel[channel].m_decathlt_prot_uploadoffset = 0; |
| 236 | | } |
| 237 | | else |
| 238 | | { |
| 239 | | fatalerror("unknown upload mode\n"); |
| 240 | | } |
| 241 | | } |
| 242 | 224 | |
| 243 | | void sega_315_5838_comp_device::upload_table_data(UINT16 data, int channel) |
| 244 | | { |
| 245 | | if (m_channel[channel].m_decathlt_prot_uploadmode == 1) |
| 225 | if (offset==1) // uploads 2 tables... |
| 246 | 226 | { |
| 247 | | if (m_channel[channel].m_decathlt_prot_uploadoffset >= 24) |
| 227 | if (mem_mask==0xffff0000) |
| 248 | 228 | { |
| 249 | | fatalerror("upload mode 1 error, too big\n"); |
| 250 | | return; |
| 229 | if (data == 0x80000000) |
| 230 | { |
| 231 | // logerror("changed to upload mode 1\n"); |
| 232 | m_decathlt_prot_uploadmode = 1; |
| 233 | m_decathlt_prot_uploadoffset = 0; |
| 234 | } |
| 235 | else if (data == 0x80800000) |
| 236 | { |
| 237 | // logerror("changed to upload mode 2\n"); |
| 238 | m_decathlt_prot_uploadmode = 2; |
| 239 | m_decathlt_prot_uploadoffset = 0; |
| 240 | } |
| 241 | else |
| 242 | { |
| 243 | // logerror("unknown upload mode\n"); |
| 244 | m_decathlt_prot_uploadmode = 2; |
| 245 | m_decathlt_prot_uploadoffset = 0; |
| 246 | } |
| 247 | |
| 248 | // logerror("ARGH! %08x %08x\n",mem_mask,data); |
| 251 | 249 | } |
| 250 | else if (mem_mask==0x0000ffff) |
| 251 | { |
| 252 | if (m_decathlt_prot_uploadmode==1) |
| 253 | { |
| 254 | if (m_decathlt_prot_uploadoffset>=24) |
| 255 | { |
| 256 | // logerror("upload mode 1 error, too big\n"); |
| 257 | return; |
| 258 | } |
| 252 | 259 | |
| 253 | | //logerror("uploading table 1 %04x %04x\n",m_channel[channel].m_decathlt_prot_uploadoffset, data&0xffff); |
| 254 | | m_channel[channel].m_decathlt_prottable1[m_channel[channel].m_decathlt_prot_uploadoffset] = data & 0xffff; |
| 255 | | m_channel[channel].m_decathlt_prot_uploadoffset++; |
| 256 | | printf("unk table 1 %04x (channel %d)\n", data & 0xffff, channel); |
| 257 | | } |
| 258 | | else if (m_channel[channel].m_decathlt_prot_uploadmode == 2) |
| 259 | | { |
| 260 | | if (m_channel[channel].m_decathlt_prot_uploadoffset >= 128) |
| 261 | | { |
| 262 | | fatalerror("upload mode 2 error, too big\n"); |
| 263 | | return; |
| 260 | //logerror("uploading table 1 %04x %04x\n",m_decathlt_prot_uploadoffset, data&0xffff); |
| 261 | m_decathlt_prottable1[m_decathlt_prot_uploadoffset]=data&0xffff; |
| 262 | m_decathlt_prot_uploadoffset++; |
| 263 | |
| 264 | printf("table 1 %04x\n", data & 0xffff); |
| 265 | |
| 266 | { |
| 267 | /* 0x18 (24) values in this table, rom data is 0x1800000 long, maybe it has |
| 268 | something to do with that? or 24-address b its? |
| 269 | |
| 270 | uploaded values appear to be 12-bit, some are repeated |
| 271 | */ |
| 272 | |
| 273 | { |
| 274 | FILE* fp; |
| 275 | if (which==1) fp = fopen("table1x","wb"); |
| 276 | else fp = fopen("table1","wb"); |
| 277 | |
| 278 | { |
| 279 | fwrite(&m_decathlt_prottable1,24,2,fp); |
| 280 | } |
| 281 | fclose(fp); |
| 282 | } |
| 283 | } |
| 284 | |
| 285 | } |
| 286 | else if (m_decathlt_prot_uploadmode==2) |
| 287 | { |
| 288 | if (m_decathlt_prot_uploadoffset>=128) |
| 289 | { |
| 290 | //logerror("upload mode 2 error, too big\n"); |
| 291 | return; |
| 292 | } |
| 293 | |
| 294 | //logerror("uploading table 2 %04x %04x\n",m_decathlt_prot_uploadoffset, data&0xffff); |
| 295 | m_decathlt_prottable2[m_decathlt_prot_uploadoffset]=data&0xffff; |
| 296 | m_decathlt_prot_uploadoffset++; |
| 297 | |
| 298 | printf("dictionary %04x\n", data & 0xffff); |
| 299 | |
| 300 | |
| 301 | { |
| 302 | /* the table uploaded here is a 256 byte table with 256 unique values, remaps something? */ |
| 303 | |
| 304 | { |
| 305 | FILE* fp; |
| 306 | if (which==1) fp = fopen("table2x","wb"); |
| 307 | else fp = fopen("table2","wb"); |
| 308 | |
| 309 | { |
| 310 | fwrite(&m_decathlt_prottable2,128,2,fp); |
| 311 | } |
| 312 | fclose(fp); |
| 313 | } |
| 314 | } |
| 315 | } |
| 316 | else |
| 317 | { |
| 318 | // logerror("unknown upload mode!\n"); |
| 319 | } |
| 264 | 320 | } |
| 265 | | |
| 266 | | //logerror("uploading table 2 %04x %04x\n",m_channel[channel].m_decathlt_prot_uploadoffset, data&0xffff); |
| 267 | | m_channel[channel].m_decathlt_dictionary[m_channel[channel].m_decathlt_prot_uploadoffset] = data & 0xffff; |
| 268 | | m_channel[channel].m_decathlt_prot_uploadoffset++; |
| 269 | | printf("dictionary %04x (channel %d)\n", data & 0xffff, channel); |
| 270 | 321 | } |
| 271 | | } |
| 272 | 322 | |
| 273 | | void sega_315_5838_comp_device::write_prot_data(UINT32 data, UINT32 mem_mask, int channel, int rev_words) |
| 274 | | { |
| 275 | | if (mem_mask==0xffff0000) |
| 323 | if (offset>1) |
| 276 | 324 | { |
| 277 | | if (rev_words==0) set_upload_mode(data >> 16, channel); |
| 278 | | else upload_table_data(data >>16, channel); |
| 325 | // logerror("higher offset write\n"); |
| 279 | 326 | } |
| 280 | | else if (mem_mask == 0x0000ffff) |
| 281 | | { |
| 282 | | if (rev_words==0) upload_table_data(data & 0xffff, channel); |
| 283 | | else set_upload_mode(data & 0xffff, channel); |
| 284 | | } |
| 285 | | else |
| 286 | | { |
| 287 | | fatalerror("write_prot_data invalid mem_mask\b"); |
| 288 | | } |
| 327 | |
| 289 | 328 | } |
| 290 | 329 | |
| 330 | WRITE32_MEMBER( sega_315_5838_comp_device::decathlt_prot1_w ) |
| 331 | { |
| 332 | write_prot_data(data,mem_mask, offset, 0); |
| 291 | 333 | |
| 334 | } |
| 292 | 335 | |
| 293 | | WRITE32_MEMBER( sega_315_5838_comp_device::decathlt_prot1_w_doa ) { write_prot_data(data, mem_mask, 0, 1); } |
| 294 | | WRITE32_MEMBER( sega_315_5838_comp_device::decathlt_prot1_w) { write_prot_data(data, mem_mask, 0, 0); } |
| 295 | | WRITE32_MEMBER( sega_315_5838_comp_device::decathlt_prot2_w) { write_prot_data(data, mem_mask, 1, 0); } |
| 336 | WRITE32_MEMBER( sega_315_5838_comp_device::decathlt_prot2_w ) |
| 337 | { |
| 338 | write_prot_data(data,mem_mask, offset, 1); |
| 296 | 339 | |
| 297 | | WRITE32_MEMBER( sega_315_5838_comp_device::decathlt_prot1_srcaddr_w ) { set_prot_addr(data, mem_mask, 0); } |
| 298 | | WRITE32_MEMBER( sega_315_5838_comp_device::decathlt_prot2_srcaddr_w) { set_prot_addr(data, mem_mask, 1); } |
| 299 | 340 | |
| 341 | } |
| 300 | 342 | |
| 301 | 343 | void sega_315_5838_comp_device::install_decathlt_protection() |
| 302 | 344 | { |
| 345 | /* It uploads 2 tables here, then performs what looks like a number of transfers, setting |
| 346 | a source address of some kind (scrambled?) and then making many reads from a single address */ |
| 347 | |
| 303 | 348 | //todo, install these in the driver, they differ between games |
| 304 | 349 | cpu_device* cpu = (cpu_device*)machine().device(":maincpu"); |
| 305 | 350 | |
| 306 | | cpu->space(AS_PROGRAM).install_write_handler(0x37FFFF0, 0x37FFFF3, write32_delegate(FUNC(sega_315_5838_comp_device::decathlt_prot1_srcaddr_w), this)); // set compressed data source address |
| 307 | | cpu->space(AS_PROGRAM).install_write_handler(0x37FFFF4, 0x37FFFF7, write32_delegate(FUNC(sega_315_5838_comp_device::decathlt_prot1_w), this)); // upload tables |
| 308 | | cpu->space(AS_PROGRAM).install_read_handler(0x37FFFF8, 0x37FFFFb, read32_delegate(FUNC(sega_315_5838_comp_device::decathlt_prot1_r), this)); // read decompressed data |
| 309 | 351 | |
| 310 | | // the device is addressed here too, uploading a different set of tables and accessing a different part of ROM |
| 311 | | cpu->space(AS_PROGRAM).install_write_handler(0x27FFFF0, 0x27FFFF3, write32_delegate(FUNC(sega_315_5838_comp_device::decathlt_prot2_srcaddr_w), this)); // set compressed data source address |
| 312 | | cpu->space(AS_PROGRAM).install_write_handler(0x27FFFF4, 0x27FFFF7, write32_delegate(FUNC(sega_315_5838_comp_device::decathlt_prot2_w), this)); // upload tables |
| 313 | | cpu->space(AS_PROGRAM).install_read_handler(0x27FFFF8, 0x27FFFFb, read32_delegate(FUNC(sega_315_5838_comp_device::decathlt_prot2_r), this)); // read decompressed data |
| 352 | cpu->space(AS_PROGRAM).install_readwrite_handler(0x37FFFF0, 0x37FFFFF, read32_delegate(FUNC(sega_315_5838_comp_device::decathlt_prot_r), this), write32_delegate(FUNC(sega_315_5838_comp_device::decathlt_prot1_w), this)); |
| 353 | /* It accesses the device at this address too, with different tables, for the game textures, should it just act like a mirror, or a secondary device? */ |
| 354 | cpu->space(AS_PROGRAM).install_readwrite_handler(0x27FFFF0, 0x27FFFFF, read32_delegate(FUNC(sega_315_5838_comp_device::decathlt_prot_ch2_r), this), write32_delegate(FUNC(sega_315_5838_comp_device::decathlt_prot2_w), this)); |
| 314 | 355 | } |
| 315 | 356 | |
| 316 | 357 | |
| r243230 | r243231 | |
| 346 | 387 | { |
| 347 | 388 | printf("doa_prot_w %08x %08x %08x\n", offset*4, data, mem_mask); |
| 348 | 389 | |
| 349 | | m_protstate = 0; |
| 390 | if (offset == 0x7ff2 / 4) |
| 391 | { |
| 392 | if (data == 0) |
| 393 | { |
| 394 | m_protstate = 0; |
| 395 | strcpy((char *)m_protram, " TECMO LTD. DEAD OR ALIVE 1996.10.22 VER. 1.00"); // this is the single decompressed string DOA needs |
| 396 | } |
| 397 | } |
| 398 | else logerror("Unhandled Protection WRITE %x @ %x mask %x (PC=%x)\n", data, offset, mem_mask, space.device().safe_pc()); |
| 350 | 399 | } |
| 351 | 400 | |
| 352 | 401 | |
| r243230 | r243231 | |
| 354 | 403 | { |
| 355 | 404 | //todo, install these in the driver, they differ between games |
| 356 | 405 | cpu_device* cpu = (cpu_device*)machine().device(":maincpu"); |
| 357 | | |
| 358 | | m_protstate = 0; |
| 359 | | strcpy((char *)m_protram, " TECMO LTD. DEAD OR ALIVE 1996.10.22 VER. 1.00"); // this is the single decompressed string DOA needs, note, 2 spaces at start, might indicate a dummy read like with 5881 on Model 2 |
| 360 | | |
| 361 | 406 | cpu->space(AS_PROGRAM).install_readwrite_handler(0x01d80000, 0x01dfffff, read32_delegate(FUNC(sega_315_5838_comp_device::doa_prot_r), this), write32_delegate(FUNC(sega_315_5838_comp_device::doa_prot_w), this)); |
| 362 | | cpu->space(AS_PROGRAM).install_write_handler(0x01d87ff0, 0x01d87ff3, write32_delegate(FUNC(sega_315_5838_comp_device::decathlt_prot1_srcaddr_w), this)); // set compressed data source address (always set 0, data is in RAM) |
| 363 | | cpu->space(AS_PROGRAM).install_write_handler(0x01d87ff4, 0x01d87ff7, write32_delegate(FUNC(sega_315_5838_comp_device::decathlt_prot1_w_doa), this)); // upload tab |
| 364 | | // cpu->space(AS_PROGRAM).install_read_handler(0x01d87ff8, 0x01d87ffb, read32_delegate(FUNC(sega_315_5838_comp_device::decathlt_prot1_r), this)); // read decompressed data |
| 365 | | |
| 366 | | } |
| 407 | } |
| | No newline at end of file |
trunk/src/mame/machine/315-5881_crypt.c
| r243230 | r243231 | |
| 82 | 82 | { |
| 83 | 83 | if (done_compression == 1) |
| 84 | 84 | enc_start(); |
| 85 | |
| 85 | 86 | |
| 86 | 87 | |
| 87 | | |
| 88 | 88 | line_fill(); |
| 89 | 89 | } |
| 90 | 90 | base = line_buffer + line_buffer_pos; |
| r243230 | r243231 | |
| 148 | 148 | given plaintext word, and the remaining 2 to the next plaintext word. |
| 149 | 149 | |
| 150 | 150 | The underlying block cipher consists of two 4-round Feistel Networks (FN): the first one takes the counter (16 bits), |
| 151 | | the game-key (>=30 bits; probably 64) and the sequence-key (16 bits) and output a middle result (16 bits) which will act |
| 151 | the game-key (>=29 bits; probably 64) and the sequence-key (16 bits) and output a middle result (16 bits) which will act |
| 152 | 152 | as another key for the second one. The second FN will take the encrypted word (16 bits), the game-key, the sequence-key |
| 153 | 153 | and the result from the first FN and will output the decrypted word (16 bits). |
| 154 | 154 | |
| r243230 | r243231 | |
| 176 | 176 | |
| 177 | 177 | void key2label(uint32_t key) |
| 178 | 178 | { |
| 179 | | int bcd0 = ((BIT(key,17)<<3)|(BIT(key,7)<<2)|(BIT(key,14)<<1)|BIT(key,19))^9; |
| 180 | | int bcd1 = ((BIT(key,20)<<3)|(BIT(key,1)<<2)|(BIT(key,4)<<1)|BIT(key,13))^5; |
| 181 | | int bcd2 = (BIT(key,9)<<1)|BIT(key,22); |
| 182 | | int bcd3 = ((BIT(key,9)<<2)|BIT(key,9))^5; |
| 183 | | |
| 184 | | char chiplabel[13]; |
| 185 | | sprintf(chiplabel, "317-%d%d%d%d-%s", bcd3, bcd2, bcd1, bcd0, (BIT(key,5)?"JPN":"COM")); |
| 186 | | |
| 187 | | printf("%s", chiplabel); |
| 179 | int bcd0 = ((BIT(key,17)<<3)|(BIT(key,7)<<2)|(BIT(key,14)<<1)|BIT(key,19))^9; |
| 180 | int bcd1 = ((BIT(key,20)<<3)|(BIT(key,1)<<2)|(BIT(key,4)<<1)|BIT(key,13))^5; |
| 181 | int bcd2 = (BIT(key,9)<<1)|BIT(key,22); |
| 182 | int bcd3 = ((BIT(key,9)<<2)|BIT(key,9))^5; |
| 183 | |
| 184 | char chiplabel[13]; |
| 185 | sprintf(chiplabel, "317-%d%d%d%d-%s", bcd3, bcd2, bcd1, bcd0, (BIT(key,5)?"JPN":"COM")); |
| 186 | |
| 187 | printf("%s", chiplabel); |
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | Given the use of the BCD-encoded security module labels, it's expected that at least other 6 additional bits be present in the |
| r243230 | r243231 | |
| 196 | 196 | |
| 197 | 197 | In the second Feistel Network, every key bit seem to be used at most once (the various uses of current bit #9 are fictitious, as |
| 198 | 198 | that bit really represent various bits in the real key; see comments on the use of the labels above). Given that, it seems probable |
| 199 | | that the real key is 64 bits long, exactly as in the related CPS-2 scheme, and the designers tried to cover all 96 input bits with |
| 199 | that the real key is 64 bits long, exactly as in the related CPS-2 scheme, and the designers tried to cover all 96 input bits with |
| 200 | 200 | the bits provening from the game key, the sequence key and the result from the first feistel network (64+16+16=96). In the first |
| 201 | 201 | Feistel Network, as only 80 bits are available, some bits would be used twice (as can be partially seen in the current implementation). |
| 202 | | The fact that only 30 bits out of the expected 64 have been observed till now would be due to the generation of the key by composing |
| 202 | The fact that only 29 bits out of the expected 64 have been observed till now would be due to the generation of the key by composing |
| 203 | 203 | low-entropy sources. |
| 204 | 204 | |
| 205 | 205 | ****************************************************************************************/ |
| r243230 | r243231 | |
| 453 | 453 | |
| 454 | 454 | { |
| 455 | 455 | { |
| 456 | | 2,2,0,3,0,3,1,0,1,1,2,3,2,3,1,0,0,0,3,2,2,0,2,3,1,3,2,0,3,3,1,3, |
| 456 | 2,2,0,3,0,3,1,0,1,1,2,3,2,3,1,0,0,0,3,2,2,0,2,3,1,3,2,0,3,3,1,3, |
| 457 | 457 | // unused? |
| 458 | 458 | 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, |
| 459 | 459 | }, |
| r243230 | r243231 | |
| 511 | 511 | |
| 512 | 512 | const int sega_315_5881_crypt_device::fn1_game_key_scheduling[FN1GK][2] = { |
| 513 | 513 | {1,29}, {1,71}, {2,4}, {2,54}, {3,8}, {4,56}, {4,73}, {5,11}, |
| 514 | | {6,51}, {7,92}, {8,89}, {9,9}, {9,39}, {9,58}, {10,90}, {11,6}, |
| 515 | | {12,64}, {13,49}, {14,44}, {15,40}, {16,69}, {17,15}, {18,23}, {18,43}, |
| 516 | | {19,82}, {20,81}, {21,32}, {22,5}, {23,66}, {24,13}, {24,45}, {25,12}, |
| 517 | | {25,35}, {26,61}, {27,10}, {27,59}, {28,25}, {29,86} |
| 514 | {6,51}, {7,92}, {8,89}, {9,9}, {9,39}, {9,58}, {9,86}, {10,90}, |
| 515 | {11,6}, {12,64}, {13,49}, {14,44}, {15,40}, {16,69}, {17,15}, {18,23}, |
| 516 | {18,43}, {19,82}, {20,81}, {21,32}, {22,5}, {23,66}, {24,13}, {24,45}, |
| 517 | {25,12}, {25,35}, {26,61}, {27,10}, {27,59}, {28,25} |
| 518 | 518 | }; |
| 519 | 519 | |
| 520 | 520 | const int sega_315_5881_crypt_device::fn2_game_key_scheduling[FN2GK][2] = { |
| 521 | 521 | {0,0}, {1,3}, {2,11}, {3,20}, {4,22}, {5,23}, {6,29}, {7,38}, |
| 522 | | {8,39}, {9,55}, {9,86}, {9,87}, {10,50}, {11,57}, {12,59}, {13,61}, |
| 523 | | {14,63}, {15,67}, {16,72}, {17,83}, {18,88}, {19,94}, {20,35}, {21,17}, |
| 524 | | {22,6}, {23,85}, {24,16}, {25,25}, {26,92}, {27,47}, {28,28}, {29,90} |
| 522 | {8,39}, {9,55}, {9,86}, {9,87}, {9,90}, {10,50}, {11,57}, {12,59}, |
| 523 | {13,61}, {14,63}, {15,67}, {16,72}, {17,83}, {18,88}, {19,94}, {20,35}, |
| 524 | {21,17}, {22,6}, {23,85}, {24,16}, {25,25}, {26,92}, {27,47}, {28,28} |
| 525 | 525 | }; |
| 526 | 526 | |
| 527 | 527 | const int sega_315_5881_crypt_device::fn1_sequence_key_scheduling[20][2] = { |
| r243230 | r243231 | |
| 680 | 680 | |
| 681 | 681 | prot_cur_address ++; |
| 682 | 682 | |
| 683 | | // printf("get_decrypted_16 %04x\n", res); |
| 683 | // printf("get_decrypted_16 %04x\n", res); |
| 684 | 684 | |
| 685 | 685 | return res; |
| 686 | 686 | } |
| r243230 | r243231 | |
| 691 | 691 | block_pos = 0; |
| 692 | 692 | done_compression = 0; |
| 693 | 693 | buffer_pos = BUFFER_SIZE; |
| 694 | | |
| 694 | |
| 695 | 695 | if (buffer_bit2 != 15) // if we have remaining bits in the decompression buffer we shouldn't read the next word yet but should instead use the bits we have?? (twcup98) (might just be because we should be pulling bytes not words?) |
| 696 | 696 | { |
| 697 | | // printf("buffer_bit2 is %d\n", buffer_bit2); |
| 697 | // printf("buffer_bit2 is %d\n", buffer_bit2); |
| 698 | 698 | dec_header = (buffer2a & 0x0003) << 16; |
| 699 | 699 | } |
| 700 | 700 | else |
| r243230 | r243231 | |
| 710 | 710 | // etc. after each block a new header must be read, it looks like compressed and uncompressed blocks |
| 711 | 711 | // can be mixed like this, I don't know if the length is src length of decompressed length. |
| 712 | 712 | // deathcox and others confirm format as 0x20000 bit as compressed bit, 0x1ff00 bits as block size 1, 0x000ff bits as block size 2 |
| 713 | | // for compressed streams the 'line size' is block size 1. |
| 713 | // for compressed streams the 'line size' is block size 1. |
| 714 | 714 | |
| 715 | 715 | block_numlines = ((dec_header & 0x000000ff) >> 0) + 1; |
| 716 | 716 | int blocky = ((dec_header & 0x0001ff00) >> 8) + 1; |
| r243230 | r243231 | |
| 824 | 824 | |
| 825 | 825 | int sega_315_5881_crypt_device::get_compressed_bit() |
| 826 | 826 | { |
| 827 | | // if(buffer_pos == BUFFER_SIZE) |
| 828 | | // enc_fill(); |
| 827 | // if(buffer_pos == BUFFER_SIZE) |
| 828 | // enc_fill(); |
| 829 | 829 | |
| 830 | 830 | if (buffer_bit2 == 15) |
| 831 | 831 | { |
| r243230 | r243231 | |
| 833 | 833 | buffer2a = get_decrypted_16(); |
| 834 | 834 | buffer2[0] = buffer2a; |
| 835 | 835 | buffer2[1] = buffer2a >> 8; |
| 836 | | // block_pos+=2; |
| 836 | // block_pos+=2; |
| 837 | 837 | buffer_pos = 0; |
| 838 | 838 | |
| 839 | 839 | } |
| r243230 | r243231 | |
| 842 | 842 | buffer_bit2++; |
| 843 | 843 | } |
| 844 | 844 | |
| 845 | | // if (buffer_bit ==7) printf("using byte %02x\n", buffer2[(buffer_pos&1) ^ 1]); |
| 845 | // if (buffer_bit ==7) printf("using byte %02x\n", buffer2[(buffer_pos&1) ^ 1]); |
| 846 | 846 | |
| 847 | 847 | int res = (buffer2[(buffer_pos&1)^1] >> buffer_bit) & 1; |
| 848 | 848 | buffer_bit--; |
trunk/src/mess/drivers/c65.c
| r243230 | r243231 | |
| 1 | | // license: MAME |
| 2 | | // copyright-holders: Angelo Salese |
| 3 | 1 | /*************************************************************************** |
| 4 | 2 | |
| 5 | | C=65 / C=64DX (c) 1991 Commodore |
| 3 | commodore c65 home computer |
| 4 | PeT mess@utanet.at |
| 6 | 5 | |
| 7 | | Attempt at rewriting the driver ... |
| 6 | documention |
| 7 | www.funet.fi |
| 8 | 8 | |
| 9 | | TODO: |
| 10 | | - I need to subtract border color to -1 in order to get blue color (-> register is 6 and blue color is 5 in palette array). |
| 11 | | Also top-left logo seems to draw wrong palette for entries 4,5,6,7. CPU core bug? |
| 9 | ***************************************************************************/ |
| 12 | 10 | |
| 13 | | Note: |
| 14 | | - VIC-4567 will be eventually be added via compile switch, once that I |
| 15 | | get the hang of the system (and checking where the old code fails |
| 16 | | eventually) |
| 11 | /* |
| 17 | 12 | |
| 18 | | ***************************************************************************/ |
| 13 | 2008 - Driver Updates |
| 14 | --------------------- |
| 19 | 15 | |
| 16 | (most of the informations are taken from http://www.zimmers.net/cbmpics/ ) |
| 20 | 17 | |
| 21 | | #include "emu.h" |
| 22 | | #include "cpu/m6502/m4510.h" |
| 23 | 18 | |
| 24 | | #define MAIN_CLOCK XTAL_3_5MHz |
| 19 | [CBM systems which belong to this driver] |
| 25 | 20 | |
| 26 | | class c65_state : public driver_device |
| 27 | | { |
| 28 | | public: |
| 29 | | c65_state(const machine_config &mconfig, device_type type, const char *tag) |
| 30 | | : driver_device(mconfig, type, tag), |
| 31 | | m_maincpu(*this, "maincpu"), |
| 32 | | m_screen(*this, "screen"), |
| 33 | | m_palette(*this, "palette"), |
| 34 | | m_workram(*this, "wram"), |
| 35 | | m_palred(*this, "redpal"), |
| 36 | | m_palgreen(*this, "greenpal"), |
| 37 | | m_palblue(*this, "bluepal"), |
| 38 | | m_dmalist(*this, "dmalist"), |
| 39 | | m_cram(*this, "cram"), |
| 40 | | m_gfxdecode(*this, "gfxdecode") |
| 41 | | { } |
| 21 | * Commodore 65 (1989) |
| 42 | 22 | |
| 43 | | // devices |
| 44 | | required_device<m4510_device> m_maincpu; |
| 45 | | required_device<screen_device> m_screen; |
| 46 | | required_device<palette_device> m_palette; |
| 47 | | required_shared_ptr<UINT8> m_workram; |
| 48 | | required_shared_ptr<UINT8> m_palred; |
| 49 | | required_shared_ptr<UINT8> m_palgreen; |
| 50 | | required_shared_ptr<UINT8> m_palblue; |
| 51 | | required_shared_ptr<UINT8> m_dmalist; |
| 52 | | required_shared_ptr<UINT8> m_cram; |
| 53 | | required_device<gfxdecode_device> m_gfxdecode; |
| 23 | Also known as C64 DX at early stages of the project. It was cancelled |
| 24 | around 1990-1991. Only few units survive (they were sold after Commodore |
| 25 | liquidation in 1994). |
| 54 | 26 | |
| 55 | | UINT8 *m_iplrom; |
| 27 | CPU: CSG 4510 (3.54 MHz) |
| 28 | RAM: 128 kilobytes, expandable to 8 megabytes |
| 29 | ROM: 128 kilobytes |
| 30 | Video: CSG 4569 "VIC-III" (6 Video modes; Resolutions from 320x200 to |
| 31 | 1280x400; 80 columns text; Palette of 4096 colors) |
| 32 | Sound: CSG 8580 "SID" x2 (6 voice stereo synthesizer/digital sound |
| 33 | capabilities) |
| 34 | Ports: CSG 4510 (2 Joystick/Mouse ports; CBM Serial port; CBM 'USER' |
| 35 | port; CBM Monitor port; Power and reset switches; C65 bus drive |
| 36 | port; RGBI video port; 2 RCA audio ports; RAM expansion port; C65 |
| 37 | expansion port) |
| 38 | Keyboard: Full-sized 77 key QWERTY (12 programmable function keys; |
| 39 | 4 direction cursor-pad) |
| 40 | Additional Hardware: Built in 3.5" DD disk drive (1581 compatible) |
| 41 | Miscellaneous: Partially implemented Commodore 64 emulation |
| 56 | 42 | |
| 57 | | |
| 58 | | DECLARE_READ8_MEMBER(vic4567_dummy_r); |
| 59 | | DECLARE_WRITE8_MEMBER(vic4567_dummy_w); |
| 60 | | DECLARE_WRITE8_MEMBER(PalRed_w); |
| 61 | | DECLARE_WRITE8_MEMBER(PalGreen_w); |
| 62 | | DECLARE_WRITE8_MEMBER(PalBlue_w); |
| 63 | | DECLARE_WRITE8_MEMBER(DMAgic_w); |
| 64 | | DECLARE_READ8_MEMBER(CIASelect_r); |
| 65 | | DECLARE_WRITE8_MEMBER(CIASelect_w); |
| 66 | | |
| 67 | | DECLARE_READ8_MEMBER(dummy_r); |
| 68 | | |
| 69 | | // screen updates |
| 70 | | UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); |
| 71 | | DECLARE_PALETTE_INIT(c65); |
| 72 | | DECLARE_DRIVER_INIT(c65); |
| 73 | | DECLARE_DRIVER_INIT(c65pal); |
| 74 | | |
| 75 | | INTERRUPT_GEN_MEMBER(vic3_vblank_irq); |
| 76 | | protected: |
| 77 | | // driver_device overrides |
| 78 | | virtual void machine_start(); |
| 79 | | virtual void machine_reset(); |
| 43 | [Notes] |
| 80 | 44 | |
| 81 | | virtual void video_start(); |
| 82 | | private: |
| 83 | | UINT8 m_VIC2_IRQPend, m_VIC2_IRQMask; |
| 84 | | /* 0x20: border color (TODO: different thread?) */ |
| 85 | | UINT8 m_VIC2_EXTColor; |
| 86 | | /* 0x30: banking + PAL + EXT SYNC */ |
| 87 | | UINT8 m_VIC3_ControlA; |
| 88 | | /* 0x31: video modes */ |
| 89 | | UINT8 m_VIC3_ControlB; |
| 90 | | void PalEntryFlush(UINT8 offset); |
| 91 | | void DMAgicExecute(address_space &space,UINT32 address); |
| 92 | | int inner_x_char(int xoffs); |
| 93 | | int inner_y_char(int yoffs); |
| 94 | | }; |
| 45 | The datasette port was removed here. C65 supports an additional "dumb" |
| 46 | drive externally. It also features, in addition to the standard CBM |
| 47 | bus serial (available in all modes), a Fast and a Burst serial bus |
| 48 | (both available in C65 mode only) |
| 95 | 49 | |
| 96 | | void c65_state::video_start() |
| 97 | | { |
| 98 | | } |
| 50 | */ |
| 99 | 51 | |
| 100 | | // TODO: inline? |
| 101 | | int c65_state::inner_x_char(int xoffs) |
| 52 | |
| 53 | #include "emu.h" |
| 54 | #include "cpu/m6502/m4510.h" |
| 55 | #include "machine/mos6526.h" |
| 56 | #include "machine/cbm_snqk.h" |
| 57 | #include "includes/c65.h" |
| 58 | #include "bus/cbmiec/cbmiec.h" |
| 59 | #include "machine/ram.h" |
| 60 | |
| 61 | static void cbm_c65_quick_sethiaddress( address_space &space, UINT16 hiaddress ) |
| 102 | 62 | { |
| 103 | | return xoffs>>3; |
| 63 | space.write_byte(0x82, hiaddress & 0xff); |
| 64 | space.write_byte(0x83, hiaddress >> 8); |
| 104 | 65 | } |
| 105 | 66 | |
| 106 | | int c65_state::inner_y_char(int yoffs) |
| 67 | QUICKLOAD_LOAD_MEMBER( c65_state, cbm_c65 ) |
| 107 | 68 | { |
| 108 | | return yoffs>>3; |
| 69 | return general_cbm_loadsnap(image, file_type, quickload_size, m_maincpu->space(AS_PROGRAM), 0, cbm_c65_quick_sethiaddress); |
| 109 | 70 | } |
| 110 | 71 | |
| 111 | | UINT32 c65_state::screen_update( screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect ) |
| 112 | | { |
| 113 | | int y,x; |
| 114 | | int border_color = m_VIC2_EXTColor & 0xf; |
| 115 | | |
| 116 | | // TODO: border area |
| 117 | | for(y=0;y<m_screen->height();y++) |
| 118 | | { |
| 119 | | for(x=0;x<m_screen->width();x++) |
| 120 | | { |
| 121 | | //int, xi,yi,xm,ym,dot_x; |
| 122 | | int xi = inner_x_char(x); |
| 123 | | int yi = inner_y_char(y); |
| 124 | | int xm = 7 - (x & 7); |
| 125 | | int ym = (y & 7); |
| 126 | | UINT8 tile = m_workram[xi+yi*80+0x800]; |
| 127 | | UINT8 attr = m_cram[xi+yi*80]; |
| 128 | | if(attr & 0xf0) |
| 129 | | attr = machine().rand() & 0xf; |
| 130 | | |
| 131 | | int enable_dot = ((m_iplrom[(tile<<3)+ym+0xd000] >> xm) & 1); |
| 132 | | |
| 133 | | //if(cliprect.contains(x, y)) |
| 134 | | bitmap.pix16(y, x) = m_palette->pen((enable_dot) ? attr & 0xf : border_color); |
| 72 | /************************************* |
| 73 | * |
| 74 | * Main CPU memory handlers |
| 75 | * |
| 76 | *************************************/ |
| 135 | 77 | |
| 136 | | |
| 137 | | //gfx->opaque(bitmap,cliprect,tile,0,0,0,x*8,y*8); |
| 138 | | } |
| 139 | | } |
| 78 | static ADDRESS_MAP_START( c65_mem , AS_PROGRAM, 8, c65_state ) |
| 79 | AM_RANGE(0x00000, 0x07fff) AM_RAMBANK("bank11") |
| 80 | AM_RANGE(0x08000, 0x09fff) AM_READ_BANK("bank1") AM_WRITE_BANK("bank12") |
| 81 | AM_RANGE(0x0a000, 0x0bfff) AM_READ_BANK("bank2") AM_WRITE_BANK("bank13") |
| 82 | AM_RANGE(0x0c000, 0x0cfff) AM_READ_BANK("bank3") AM_WRITE_BANK("bank14") |
| 83 | AM_RANGE(0x0d000, 0x0d7ff) AM_READ_BANK("bank4") AM_WRITE_BANK("bank5") |
| 84 | AM_RANGE(0x0d800, 0x0dbff) AM_READ_BANK("bank6") AM_WRITE_BANK("bank7") |
| 85 | AM_RANGE(0x0dc00, 0x0dfff) AM_READ_BANK("bank8") AM_WRITE_BANK("bank9") |
| 86 | AM_RANGE(0x0e000, 0x0ffff) AM_READ_BANK("bank10") AM_WRITE_BANK("bank15") |
| 87 | AM_RANGE(0x10000, 0x1f7ff) AM_RAM |
| 88 | AM_RANGE(0x1f800, 0x1ffff) AM_RAM AM_SHARE("colorram") |
| 140 | 89 | |
| 141 | | return 0; |
| 142 | | } |
| 90 | AM_RANGE(0x20000, 0x23fff) AM_ROM /* &c65_dos, maps to 0x8000 */ |
| 91 | AM_RANGE(0x24000, 0x28fff) AM_ROM /* reserved */ |
| 92 | AM_RANGE(0x29000, 0x29fff) AM_ROM AM_SHARE("c65_chargen") |
| 93 | AM_RANGE(0x2a000, 0x2bfff) AM_ROM AM_SHARE("basic") |
| 94 | AM_RANGE(0x2c000, 0x2cfff) AM_ROM AM_SHARE("interface") |
| 95 | AM_RANGE(0x2d000, 0x2dfff) AM_ROM AM_SHARE("chargen") |
| 96 | AM_RANGE(0x2e000, 0x2ffff) AM_ROM AM_SHARE("kernal") |
| 143 | 97 | |
| 144 | | READ8_MEMBER(c65_state::vic4567_dummy_r) |
| 145 | | { |
| 146 | | UINT8 res; |
| 98 | AM_RANGE(0x30000, 0x31fff) AM_ROM /*&c65_monitor, monitor maps to 0x6000 */ |
| 99 | AM_RANGE(0x32000, 0x37fff) AM_ROM /*&c65_basic, */ |
| 100 | AM_RANGE(0x38000, 0x3bfff) AM_ROM /*&c65_graphics, */ |
| 101 | AM_RANGE(0x3c000, 0x3dfff) AM_ROM /* reserved */ |
| 102 | AM_RANGE(0x3e000, 0x3ffff) AM_ROM /* &c65_kernal, */ |
| 147 | 103 | |
| 148 | | res=0xff; |
| 149 | | switch(offset) |
| 150 | | { |
| 151 | | case 0x11: |
| 152 | | res = (m_screen->vpos() & 0x100) >> 1; |
| 153 | | return res; |
| 154 | | case 0x12: |
| 155 | | res = (m_screen->vpos() & 0xff); |
| 156 | | return res; |
| 157 | | case 0x20: |
| 158 | | return m_VIC2_EXTColor; |
| 159 | | case 0x19: |
| 160 | | return m_VIC2_IRQPend; |
| 161 | | case 0x30: |
| 162 | | return m_VIC3_ControlA; |
| 163 | | case 0x31: |
| 164 | | return m_VIC3_ControlB; |
| 165 | | } |
| 166 | | |
| 167 | | if(!space.debugger_access()) |
| 168 | | printf("%02x\n",offset); // TODO: PC |
| 169 | | return res; |
| 170 | | } |
| 104 | AM_RANGE(0x40000, 0x7ffff) AM_NOP |
| 105 | /* 8 megabyte full address space! */ |
| 106 | ADDRESS_MAP_END |
| 171 | 107 | |
| 172 | | WRITE8_MEMBER(c65_state::vic4567_dummy_w) |
| 108 | |
| 109 | /************************************* |
| 110 | * |
| 111 | * Input Ports |
| 112 | * |
| 113 | *************************************/ |
| 114 | |
| 115 | static INPUT_PORTS_START( c65 ) |
| 116 | PORT_START( "ROW0" ) |
| 117 | PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Crsr Down Up") PORT_CODE(KEYCODE_RALT) PORT_CHAR(UCHAR_MAMEKEY(DOWN)) PORT_CHAR(UCHAR_MAMEKEY(UP)) |
| 118 | PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F3) PORT_CHAR(UCHAR_MAMEKEY(F5)) |
| 119 | PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F2) PORT_CHAR(UCHAR_MAMEKEY(F3)) |
| 120 | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F1) PORT_CHAR(UCHAR_MAMEKEY(F1)) |
| 121 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F4) PORT_CHAR(UCHAR_MAMEKEY(F7)) |
| 122 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Crsr Right Left") PORT_CODE(KEYCODE_RCONTROL) PORT_CHAR(UCHAR_MAMEKEY(RIGHT)) PORT_CHAR(UCHAR_MAMEKEY(LEFT)) |
| 123 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Return") PORT_CODE(KEYCODE_ENTER) PORT_CHAR(13) |
| 124 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("INST DEL") PORT_CODE(KEYCODE_BACKSPACE) PORT_CHAR(8) PORT_CHAR(UCHAR_MAMEKEY(INSERT)) |
| 125 | |
| 126 | PORT_START( "ROW1" ) |
| 127 | PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Shift (Left)") PORT_CODE(KEYCODE_LSHIFT) PORT_CHAR(UCHAR_SHIFT_1) |
| 128 | PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_E) PORT_CHAR('E') |
| 129 | PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_S) PORT_CHAR('S') |
| 130 | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_Z) PORT_CHAR('Z') |
| 131 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_4) PORT_CHAR('4') PORT_CHAR('$') |
| 132 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_A) PORT_CHAR('A') |
| 133 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_W) PORT_CHAR('W') |
| 134 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_3) PORT_CHAR('3') PORT_CHAR('#') |
| 135 | |
| 136 | PORT_START( "ROW2" ) |
| 137 | PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_X) PORT_CHAR('X') |
| 138 | PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_T) PORT_CHAR('T') |
| 139 | PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F) PORT_CHAR('F') |
| 140 | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_C) PORT_CHAR('C') |
| 141 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_6) PORT_CHAR('6') PORT_CHAR('&') |
| 142 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_D) PORT_CHAR('D') |
| 143 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_R) PORT_CHAR('R') |
| 144 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_5) PORT_CHAR('5') PORT_CHAR('%') |
| 145 | |
| 146 | PORT_START( "ROW3" ) |
| 147 | PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_V) PORT_CHAR('V') |
| 148 | PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_U) PORT_CHAR('U') |
| 149 | PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_H) PORT_CHAR('H') |
| 150 | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_B) PORT_CHAR('B') |
| 151 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_8) PORT_CHAR('8') PORT_CHAR('(') |
| 152 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_G) PORT_CHAR('G') |
| 153 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_Y) PORT_CHAR('Y') |
| 154 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_7) PORT_CHAR('7') PORT_CHAR('\'') |
| 155 | |
| 156 | PORT_START( "ROW4" ) |
| 157 | PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_N) PORT_CHAR('N') |
| 158 | PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_O) PORT_CHAR('O') |
| 159 | PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_K) PORT_CHAR('K') |
| 160 | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_M) PORT_CHAR('M') |
| 161 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_0) PORT_CHAR('0') |
| 162 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_J) PORT_CHAR('J') |
| 163 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_I) PORT_CHAR('I') |
| 164 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_9) PORT_CHAR('9') PORT_CHAR(')') |
| 165 | |
| 166 | PORT_START( "ROW5" ) |
| 167 | PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_COMMA) PORT_CHAR(',') PORT_CHAR('<') |
| 168 | PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_OPENBRACE) PORT_CHAR('@') |
| 169 | PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_COLON) PORT_CHAR(':') PORT_CHAR('[') |
| 170 | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_STOP) PORT_CHAR('.') PORT_CHAR('>') |
| 171 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_EQUALS) PORT_CHAR('-') |
| 172 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_L) PORT_CHAR('L') |
| 173 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_P) PORT_CHAR('P') |
| 174 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_MINUS) PORT_CHAR('+') |
| 175 | |
| 176 | PORT_START( "ROW6" ) |
| 177 | PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_SLASH) PORT_CHAR('/') PORT_CHAR('?') |
| 178 | PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("\xE2\x86\x91 Pi") PORT_CODE(KEYCODE_DEL) PORT_CHAR(0x2191) PORT_CHAR(0x03C0) |
| 179 | PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_BACKSLASH) PORT_CHAR('=') |
| 180 | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Shift (Right)") PORT_CODE(KEYCODE_RSHIFT) PORT_CHAR(UCHAR_SHIFT_1) |
| 181 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("CLR HOME") PORT_CODE(KEYCODE_INSERT) PORT_CHAR(UCHAR_MAMEKEY(HOME)) |
| 182 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_QUOTE) PORT_CHAR(';') PORT_CHAR(']') |
| 183 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_CLOSEBRACE) PORT_CHAR('*') |
| 184 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_BACKSLASH2) PORT_CHAR('\xA3') |
| 185 | |
| 186 | PORT_START( "ROW7" ) |
| 187 | PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("RUN STOP") PORT_CODE(KEYCODE_HOME) |
| 188 | PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_Q) PORT_CHAR('Q') |
| 189 | PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("CBM") PORT_CODE(KEYCODE_LALT) |
| 190 | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_SPACE) PORT_CHAR(' ') |
| 191 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_2) PORT_CHAR('2') PORT_CHAR('"') |
| 192 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_TAB) PORT_CHAR(UCHAR_SHIFT_2) |
| 193 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("\xE2\x86\x90") PORT_CODE(KEYCODE_TILDE) PORT_CHAR(0x2190) |
| 194 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_1) PORT_CHAR('1') PORT_CHAR('!') |
| 195 | PORT_START("FUNCT") |
| 196 | PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("ESC") PORT_CODE(KEYCODE_F1) |
| 197 | PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("F13 F14") PORT_CODE(KEYCODE_F11) |
| 198 | PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("F11 F12") PORT_CODE(KEYCODE_F10) |
| 199 | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("F9 F10") PORT_CODE(KEYCODE_F9) |
| 200 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("HELP") PORT_CODE(KEYCODE_F12) |
| 201 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("ALT") PORT_CODE(KEYCODE_F2) /* non blocking */ |
| 202 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("TAB") PORT_CODE(KEYCODE_TAB) |
| 203 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("NO SCRL") PORT_CODE(KEYCODE_F4) |
| 204 | |
| 205 | PORT_START( "SPECIAL" ) /* special keys */ |
| 206 | PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Restore") PORT_CODE(KEYCODE_PRTSCR) |
| 207 | PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Shift Lock (switch)") PORT_CODE(KEYCODE_CAPSLOCK) PORT_TOGGLE PORT_CHAR(UCHAR_MAMEKEY(CAPSLOCK)) |
| 208 | PORT_CONFNAME( 0x20, 0x00, "(C65) Caps Lock (switch)") PORT_CODE(KEYCODE_F3) |
| 209 | PORT_CONFSETTING( 0x00, DEF_STR( Off ) ) |
| 210 | PORT_CONFSETTING( 0x20, DEF_STR( On ) ) |
| 211 | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| 212 | |
| 213 | PORT_START("CTRLSEL") /* Controller selection */ |
| 214 | PORT_CONFNAME( 0x07, 0x00, "Gameport A" ) |
| 215 | PORT_CONFSETTING( 0x00, DEF_STR( Joystick ) ) |
| 216 | PORT_CONFSETTING( 0x01, "Paddles 1 & 2" ) |
| 217 | PORT_CONFSETTING( 0x02, "Mouse 1351" ) |
| 218 | PORT_CONFSETTING( 0x03, "Mouse (Non Proportional) 1350" ) |
| 219 | PORT_CONFSETTING( 0x04, "Lightpen" ) |
| 220 | // PORT_CONFSETTING( 0x05, "Koala Pad" ) |
| 221 | PORT_CONFSETTING( 0x06, "Lightgun" ) |
| 222 | PORT_CONFSETTING( 0x07, "No Device Connected" ) |
| 223 | PORT_CONFNAME( 0x70, 0x00, "Gameport B" ) |
| 224 | PORT_CONFSETTING( 0x00, DEF_STR( Joystick ) ) |
| 225 | PORT_CONFSETTING( 0x10, "Paddles 3 & 4" ) |
| 226 | // PORT_CONFSETTING( 0x20, "Mouse 1351" ) |
| 227 | // PORT_CONFSETTING( 0x30, "Mouse (Non Proportional) 1350" ) |
| 228 | PORT_CONFSETTING( 0x70, "No Device Connected" ) |
| 229 | PORT_CONFNAME( 0x80, 0x00, "Swap Gameport A and B") PORT_CODE(KEYCODE_F1) PORT_TOGGLE |
| 230 | PORT_CONFSETTING( 0x00, DEF_STR( No ) ) |
| 231 | PORT_CONFSETTING( 0x80, DEF_STR( Yes ) ) |
| 232 | |
| 233 | PORT_START("JOY1_1B") |
| 234 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x00) |
| 235 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x00) |
| 236 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x00) |
| 237 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x00) |
| 238 | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x00) |
| 239 | PORT_BIT( 0xe0, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| 240 | |
| 241 | PORT_START("JOY2_1B") |
| 242 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(2) PORT_CODE(KEYCODE_HOME) PORT_CODE(JOYCODE_Y_UP_SWITCH) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x00) |
| 243 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(2) PORT_CODE(KEYCODE_END) PORT_CODE(JOYCODE_Y_DOWN_SWITCH) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x00) |
| 244 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(2) PORT_CODE(KEYCODE_DEL) PORT_CODE(JOYCODE_X_LEFT_SWITCH) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x00) |
| 245 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(2) PORT_CODE(KEYCODE_PGDN) PORT_CODE(JOYCODE_X_RIGHT_SWITCH) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x00) |
| 246 | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_PLAYER(2) PORT_CODE(KEYCODE_INSERT) PORT_CODE(JOYCODE_BUTTON1) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x00) |
| 247 | PORT_BIT( 0xe0, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| 248 | |
| 249 | /* Mouse Commodore 1350 was basically working as a Joystick */ |
| 250 | PORT_START("JOY1_2B") |
| 251 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(1) PORT_NAME("Mouse 1350 Up") PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x03) |
| 252 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(1) PORT_NAME("Mouse 1350 Down") PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x03) |
| 253 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(1) PORT_NAME("Mouse 1350 Left") PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x03) |
| 254 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(1) PORT_NAME("Mouse 1350 Right") PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x03) |
| 255 | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_PLAYER(1) PORT_NAME("Mouse 1350 Button 1") PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x03) |
| 256 | PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_PLAYER(1) PORT_NAME("Mouse 1350 Button 2") PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x03) |
| 257 | PORT_BIT( 0xc0, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| 258 | |
| 259 | /* Still to verify how many mices you were able to plug into a c64 */ |
| 260 | /* Only one, for now */ |
| 261 | PORT_START("JOY2_2B") |
| 262 | PORT_BIT( 0xff, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| 263 | /* PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(2) PORT_CODE(KEYCODE_HOME) PORT_CODE(JOYCODE_Y_UP_SWITCH) |
| 264 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(2) PORT_CODE(KEYCODE_END) PORT_CODE(JOYCODE_Y_DOWN_SWITCH) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x30) |
| 265 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(2) PORT_CODE(KEYCODE_DEL) PORT_CODE(JOYCODE_X_LEFT_SWITCH) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x30) |
| 266 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(2) PORT_CODE(KEYCODE_PGDN) PORT_CODE(JOYCODE_X_RIGHT_SWITCH) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x30) |
| 267 | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_PLAYER(2) PORT_CODE(KEYCODE_INSERT) PORT_CODE(JOYCODE_BUTTON1) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x30) |
| 268 | PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_PLAYER(2) PORT_CODE(KEYCODE_PGUP) PORT_CODE(JOYCODE_BUTTON2) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x30) |
| 269 | PORT_BIT( 0xc0, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| 270 | */ |
| 271 | PORT_START("PADDLE1") |
| 272 | PORT_BIT( 0xff, 128, IPT_PADDLE) PORT_SENSITIVITY(30) PORT_KEYDELTA(20) PORT_MINMAX(0,255) PORT_CENTERDELTA(0) PORT_CODE_DEC(KEYCODE_LEFT) PORT_CODE_INC(KEYCODE_RIGHT) PORT_CODE_DEC(JOYCODE_X_LEFT_SWITCH) PORT_CODE_INC(JOYCODE_X_RIGHT_SWITCH) PORT_PLAYER(1) PORT_REVERSE PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x01) |
| 273 | |
| 274 | PORT_START("PADDLE2") |
| 275 | PORT_BIT( 0xff, 128, IPT_PADDLE) PORT_SENSITIVITY(30) PORT_KEYDELTA(20) PORT_MINMAX(0,255) PORT_CENTERDELTA(0) PORT_CODE_DEC(KEYCODE_DOWN) PORT_CODE_INC(KEYCODE_UP) PORT_CODE_DEC(JOYCODE_Y_UP_SWITCH) PORT_CODE_INC(JOYCODE_Y_DOWN_SWITCH) PORT_PLAYER(2) PORT_REVERSE PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x01) |
| 276 | |
| 277 | PORT_START("PADDLE3") |
| 278 | PORT_BIT( 0xff, 128, IPT_PADDLE) PORT_SENSITIVITY(30) PORT_KEYDELTA(20) PORT_MINMAX(0,255) PORT_CENTERDELTA(0) PORT_CODE_DEC(KEYCODE_HOME) PORT_CODE_INC(KEYCODE_PGUP) PORT_PLAYER(3) PORT_REVERSE PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x10) |
| 279 | |
| 280 | PORT_START("PADDLE4") |
| 281 | PORT_BIT( 0xff, 128, IPT_PADDLE) PORT_SENSITIVITY(30) PORT_KEYDELTA(20) PORT_MINMAX(0,255) PORT_CENTERDELTA(0) PORT_CODE_DEC(KEYCODE_END) PORT_CODE_INC(KEYCODE_PGDN) PORT_PLAYER(4) PORT_REVERSE PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x10) |
| 282 | |
| 283 | PORT_START("TRACKX") |
| 284 | PORT_BIT( 0x7e, 0x00, IPT_TRACKBALL_X) PORT_SENSITIVITY(100) PORT_KEYDELTA(0) PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x02) |
| 285 | |
| 286 | PORT_START("TRACKY") |
| 287 | PORT_BIT( 0x7e, 0x00, IPT_TRACKBALL_Y) PORT_SENSITIVITY(100) PORT_KEYDELTA(0) PORT_PLAYER(1) PORT_REVERSE PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x02) |
| 288 | |
| 289 | PORT_START("LIGHTX") |
| 290 | PORT_BIT( 0xff, 0x00, IPT_TRACKBALL_X) PORT_NAME("Lightpen X Axis") PORT_CROSSHAIR(X, 1.0, 0.0, 0) PORT_SENSITIVITY(30) PORT_KEYDELTA(20) PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x04) |
| 291 | |
| 292 | PORT_START("LIGHTY") |
| 293 | PORT_BIT( 0xff, 0x00, IPT_TRACKBALL_Y) PORT_NAME("Lightpen Y Axis") PORT_CROSSHAIR(Y, 1.0, 0.0, 0) PORT_SENSITIVITY(30) PORT_KEYDELTA(20) PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x04) |
| 294 | |
| 295 | PORT_START("OTHER") |
| 296 | PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_BUTTON1) PORT_NAME("Paddle 1 Button") PORT_CODE(KEYCODE_LCONTROL) PORT_CODE(JOYCODE_BUTTON1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x01) |
| 297 | PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_BUTTON2) PORT_NAME("Paddle 2 Button") PORT_CODE(KEYCODE_LALT) PORT_CODE(JOYCODE_BUTTON2) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x01) |
| 298 | PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_BUTTON3) PORT_NAME("Paddle 3 Button") PORT_CODE(KEYCODE_INSERT) PORT_CODE(JOYCODE_BUTTON1) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x10) |
| 299 | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON4) PORT_NAME("Paddle 4 Button") PORT_CODE(KEYCODE_DEL) PORT_CODE(JOYCODE_BUTTON2) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x10) |
| 300 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_BUTTON1) PORT_NAME("Lightpen Signal") PORT_CODE(KEYCODE_LCONTROL) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x04) |
| 301 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON1) PORT_NAME("Mouse Button Left") PORT_CODE(KEYCODE_LCONTROL) PORT_CODE(JOYCODE_BUTTON1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x02) |
| 302 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON2) PORT_NAME("Mouse Button Right") PORT_CODE(KEYCODE_LALT) PORT_CODE(JOYCODE_BUTTON2) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x02)INPUT_PORTS_END |
| 303 | |
| 304 | |
| 305 | static INPUT_PORTS_START( c65ger ) |
| 306 | PORT_INCLUDE( c65 ) |
| 307 | |
| 308 | PORT_MODIFY( "ROW1" ) |
| 309 | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Z { Y }") PORT_CODE(KEYCODE_Z) PORT_CHAR('Z') |
| 310 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("3 # { 3 Paragraph }") PORT_CODE(KEYCODE_3) PORT_CHAR('3') PORT_CHAR('#') |
| 311 | |
| 312 | PORT_MODIFY( "ROW3" ) |
| 313 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Y { Z }") PORT_CODE(KEYCODE_Y) PORT_CHAR('Y') |
| 314 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("7 ' { 7 / }") PORT_CODE(KEYCODE_7) PORT_CHAR('7') PORT_CHAR('\'') |
| 315 | |
| 316 | PORT_MODIFY( "ROW4" ) |
| 317 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("0 { = }") PORT_CODE(KEYCODE_0) PORT_CHAR('0') |
| 318 | |
| 319 | PORT_MODIFY( "ROW5" ) |
| 320 | PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME(", < { ; }") PORT_CODE(KEYCODE_COMMA) PORT_CHAR(',') PORT_CHAR('<') |
| 321 | PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Paragraph \xE2\x86\x91 { \xc3\xbc }") PORT_CODE(KEYCODE_OPENBRACE) PORT_CHAR(0x00A7) PORT_CHAR(0x2191) |
| 322 | PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME(": [ { \xc3\xa4 }") PORT_CODE(KEYCODE_COLON) PORT_CHAR(':') PORT_CHAR('[') |
| 323 | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME(". > { : }") PORT_CODE(KEYCODE_STOP) PORT_CHAR('.') PORT_CHAR('>') |
| 324 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("- { ' ` }") PORT_CODE(KEYCODE_EQUALS) PORT_CHAR('-') |
| 325 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("+ { \xc3\x9f ? }") PORT_CODE(KEYCODE_MINUS) PORT_CHAR('+') |
| 326 | |
| 327 | PORT_MODIFY( "ROW6" ) |
| 328 | PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("/ ? { - _ }") PORT_CODE(KEYCODE_SLASH) PORT_CHAR('/') PORT_CHAR('?') |
| 329 | PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Sum Pi { ] \\ }") PORT_CODE(KEYCODE_DEL) PORT_CHAR(0x03A3) PORT_CHAR(0x03C0) |
| 330 | PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("= { # ' }") PORT_CODE(KEYCODE_BACKSLASH) PORT_CHAR('=') |
| 331 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("; ] { \xc3\xb6 }") PORT_CODE(KEYCODE_QUOTE) PORT_CHAR(';') PORT_CHAR(']') |
| 332 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("* ` { + * }") PORT_CODE(KEYCODE_CLOSEBRACE) PORT_CHAR('*') PORT_CHAR('`') |
| 333 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("\\ { [ \xE2\x86\x91 }") PORT_CODE(KEYCODE_BACKSLASH2) PORT_CHAR('\xa3') |
| 334 | |
| 335 | PORT_MODIFY( "ROW7" ) |
| 336 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("_ { < > }") PORT_CODE(KEYCODE_TILDE) PORT_CHAR('_') |
| 337 | |
| 338 | PORT_MODIFY("SPECIAL") /* special keys */ |
| 339 | PORT_DIPNAME( 0x20, 0x00, "(C65) DIN ASC (switch)") PORT_CODE(KEYCODE_F3) |
| 340 | PORT_DIPSETTING( 0x00, "ASC" ) |
| 341 | PORT_DIPSETTING( 0x20, "DIN" ) |
| 342 | INPUT_PORTS_END |
| 343 | |
| 344 | |
| 345 | |
| 346 | /************************************* |
| 347 | * |
| 348 | * Sound definitions |
| 349 | * |
| 350 | *************************************/ |
| 351 | |
| 352 | int c65_state::c64_paddle_read( device_t *device, address_space &space, int which ) |
| 173 | 353 | { |
| 174 | | switch(offset) |
| 354 | int pot1 = 0xff, pot2 = 0xff, pot3 = 0xff, pot4 = 0xff, temp; |
| 355 | UINT8 cia0porta = machine().device<mos6526_device>("cia_0")->pa_r(space, 0); |
| 356 | int controller1 = ioport("CTRLSEL")->read() & 0x07; |
| 357 | int controller2 = ioport("CTRLSEL")->read() & 0x70; |
| 358 | /* Notice that only a single input is defined for Mouse & Lightpen in both ports */ |
| 359 | switch (controller1) |
| 175 | 360 | { |
| 176 | | case 0x19: |
| 177 | | m_VIC2_IRQPend = data & 0x8f; |
| 361 | case 0x01: |
| 362 | if (which) |
| 363 | pot2 = ioport("PADDLE2")->read(); |
| 364 | else |
| 365 | pot1 = ioport("PADDLE1")->read(); |
| 178 | 366 | break; |
| 179 | | case 0x1a: |
| 180 | | m_VIC2_IRQMask = data & 0xf; |
| 367 | |
| 368 | case 0x02: |
| 369 | if (which) |
| 370 | pot2 = ioport("TRACKY")->read(); |
| 371 | else |
| 372 | pot1 = ioport("TRACKX")->read(); |
| 181 | 373 | break; |
| 182 | | case 0x20: |
| 183 | | m_VIC2_EXTColor = data & 0xf; |
| 374 | |
| 375 | case 0x03: |
| 376 | if (which && (ioport("JOY1_2B")->read() & 0x20)) /* Joy1 Button 2 */ |
| 377 | pot1 = 0x00; |
| 184 | 378 | break; |
| 185 | | /* KEY register, handles vic-iii and vic-ii modes via two consecutive writes |
| 186 | | 0xa5 -> 0x96 vic-iii mode |
| 187 | | any other write vic-ii mode |
| 188 | | */ |
| 189 | | //case 0x2f: break; |
| 190 | | case 0x30: |
| 191 | | if((data & 0xfe) != 0x64) |
| 192 | | printf("CONTROL A %02x\n",data); |
| 193 | | m_VIC3_ControlA = data; |
| 379 | |
| 380 | case 0x04: |
| 381 | if (which) |
| 382 | pot2 = ioport("LIGHTY")->read(); |
| 383 | else |
| 384 | pot1 = ioport("LIGHTX")->read(); |
| 194 | 385 | break; |
| 195 | | case 0x31: |
| 196 | | printf("CONTROL B %02x\n",data); |
| 197 | | m_VIC3_ControlB = data; |
| 386 | |
| 387 | case 0x06: |
| 388 | if (which && (ioport("OTHER")->read() & 0x04)) /* Lightpen Signal */ |
| 389 | pot2 = 0x00; |
| 198 | 390 | break; |
| 391 | |
| 392 | case 0x00: |
| 393 | case 0x07: |
| 394 | break; |
| 395 | |
| 199 | 396 | default: |
| 200 | | if(!space.debugger_access()) |
| 201 | | printf("%02x %02x\n",offset,data); |
| 397 | logerror("Invalid Controller Setting %d\n", controller1); |
| 202 | 398 | break; |
| 203 | 399 | } |
| 204 | 400 | |
| 205 | | } |
| 401 | switch (controller2) |
| 402 | { |
| 403 | case 0x10: |
| 404 | if (which) |
| 405 | pot4 = ioport("PADDLE4")->read(); |
| 406 | else |
| 407 | pot3 = ioport("PADDLE3")->read(); |
| 408 | break; |
| 206 | 409 | |
| 207 | | void c65_state::PalEntryFlush(UINT8 offset) |
| 208 | | { |
| 209 | | m_palette->set_pen_color(offset, pal4bit(m_palred[offset]), pal4bit(m_palgreen[offset]), pal4bit(m_palblue[offset])); |
| 210 | | } |
| 410 | case 0x20: |
| 411 | if (which) |
| 412 | pot4 = ioport("TRACKY")->read(); |
| 413 | else |
| 414 | pot3 = ioport("TRACKX")->read(); |
| 415 | break; |
| 211 | 416 | |
| 212 | | WRITE8_MEMBER(c65_state::PalRed_w) |
| 213 | | { |
| 214 | | m_palred[offset] = data; |
| 215 | | PalEntryFlush(offset); |
| 216 | | } |
| 417 | case 0x30: |
| 418 | if (which && (ioport("JOY2_2B")->read() & 0x20)) /* Joy2 Button 2 */ |
| 419 | pot4 = 0x00; |
| 420 | break; |
| 217 | 421 | |
| 218 | | WRITE8_MEMBER(c65_state::PalGreen_w) |
| 219 | | { |
| 220 | | m_palgreen[offset] = data; |
| 221 | | PalEntryFlush(offset); |
| 222 | | } |
| 422 | case 0x40: |
| 423 | if (which) |
| 424 | pot4 = ioport("LIGHTY")->read(); |
| 425 | else |
| 426 | pot3 = ioport("LIGHTX")->read(); |
| 427 | break; |
| 223 | 428 | |
| 224 | | WRITE8_MEMBER(c65_state::PalBlue_w) |
| 225 | | { |
| 226 | | m_palblue[offset] = data; |
| 227 | | PalEntryFlush(offset); |
| 228 | | } |
| 429 | case 0x60: |
| 430 | if (which && (ioport("OTHER")->read() & 0x04)) /* Lightpen Signal */ |
| 431 | pot4 = 0x00; |
| 432 | break; |
| 229 | 433 | |
| 230 | | void c65_state::DMAgicExecute(address_space &space,UINT32 address) |
| 231 | | { |
| 232 | | UINT8 cmd;// = space.read_byte(address++); |
| 233 | | UINT16 length; //= space.read_byte(address++); |
| 234 | | UINT32 src, dst; |
| 235 | | static const char *const dma_cmd_string[] = |
| 434 | case 0x00: |
| 435 | case 0x70: |
| 436 | break; |
| 437 | |
| 438 | default: |
| 439 | logerror("Invalid Controller Setting %d\n", controller1); |
| 440 | break; |
| 441 | } |
| 442 | |
| 443 | if (ioport("CTRLSEL")->read() & 0x80) /* Swap */ |
| 236 | 444 | { |
| 237 | | "COPY", // 0 |
| 238 | | "MIX", |
| 239 | | "SWAP", |
| 240 | | "FILL" |
| 241 | | }; |
| 242 | | cmd = space.read_byte(address++); |
| 243 | | length = space.read_byte(address++); |
| 244 | | length|=(space.read_byte(address++)<<8); |
| 245 | | src = space.read_byte(address++); |
| 246 | | src|=(space.read_byte(address++)<<8); |
| 247 | | src|=(space.read_byte(address++)<<16); |
| 248 | | dst = space.read_byte(address++); |
| 249 | | dst|=(space.read_byte(address++)<<8); |
| 250 | | dst|=(space.read_byte(address++)<<16); |
| 445 | temp = pot1; pot1 = pot3; pot3 = temp; |
| 446 | temp = pot2; pot2 = pot4; pot4 = temp; |
| 447 | } |
| 251 | 448 | |
| 252 | | if(cmd & 0xfc) |
| 253 | | printf("%02x\n",cmd & 0xfc); |
| 254 | | switch(cmd & 3) |
| 449 | switch (cia0porta & 0xc0) |
| 255 | 450 | { |
| 256 | | case 0: // copy - TODO: untested |
| 257 | | { |
| 258 | | if(length != 1) |
| 259 | | printf("DMAgic %s %02x -> %08x %04x (CHAIN=%s)\n",dma_cmd_string[cmd & 3],src,dst,length,cmd & 4 ? "yes" : "no"); |
| 260 | | UINT32 SourceIndex; |
| 261 | | UINT32 DestIndex; |
| 262 | | UINT16 SizeIndex; |
| 263 | | SourceIndex = src & 0xfffff; |
| 264 | | DestIndex = dst & 0xfffff; |
| 265 | | SizeIndex = length; |
| 266 | | do |
| 267 | | { |
| 268 | | space.write_byte(DestIndex++,space.read_byte(SourceIndex++)); |
| 269 | | SizeIndex--; |
| 270 | | }while(SizeIndex != 0); |
| 451 | case 0x40: |
| 452 | return which ? pot2 : pot1; |
| 271 | 453 | |
| 272 | | return; |
| 273 | | } |
| 274 | | case 3: // fill |
| 275 | | { |
| 276 | | /* TODO: upper bits of source */ |
| 277 | | printf("DMAgic %s %02x -> %08x %04x (CHAIN=%s)\n",dma_cmd_string[cmd & 3],src & 0xff,dst,length,cmd & 4 ? "yes" : "no"); |
| 278 | | UINT8 FillValue; |
| 279 | | UINT32 DestIndex; |
| 280 | | UINT16 SizeIndex; |
| 281 | | FillValue = src & 0xff; |
| 282 | | DestIndex = dst & 0xfffff; |
| 283 | | SizeIndex = length; |
| 284 | | do |
| 285 | | { |
| 286 | | space.write_byte(DestIndex++,FillValue); |
| 287 | | SizeIndex--; |
| 288 | | }while(SizeIndex != 0); |
| 289 | | } |
| 290 | | return; |
| 291 | | } |
| 292 | | printf("DMAgic %s %08x %08x %04x (CHAIN=%s)\n",dma_cmd_string[cmd & 3],src,dst,length,cmd & 4 ? "yes" : "no"); |
| 293 | | } |
| 454 | case 0x80: |
| 455 | return which ? pot4 : pot3; |
| 294 | 456 | |
| 457 | case 0xc0: |
| 458 | return which ? pot2 : pot1; |
| 295 | 459 | |
| 296 | | WRITE8_MEMBER(c65_state::DMAgic_w) |
| 297 | | { |
| 298 | | m_dmalist[offset] = data; |
| 299 | | if(offset == 0) |
| 300 | | DMAgicExecute(space,(m_dmalist[0])|(m_dmalist[1]<<8)|(m_dmalist[2]<<16)); |
| 460 | default: |
| 461 | return 0; |
| 462 | } |
| 301 | 463 | } |
| 302 | 464 | |
| 303 | | READ8_MEMBER(c65_state::CIASelect_r) |
| 465 | READ8_MEMBER( c65_state::sid_potx_r ) |
| 304 | 466 | { |
| 305 | | if(m_VIC3_ControlA & 1) |
| 306 | | return m_cram[offset]; |
| 307 | | else |
| 308 | | { |
| 309 | | // CIA at 0xdc00 |
| 310 | | } |
| 311 | | |
| 312 | | return 0xff; |
| 467 | return c64_paddle_read(m_sid_r, space, 0); |
| 313 | 468 | } |
| 314 | 469 | |
| 315 | | WRITE8_MEMBER(c65_state::CIASelect_w) |
| 470 | READ8_MEMBER( c65_state::sid_poty_r ) |
| 316 | 471 | { |
| 317 | | if(m_VIC3_ControlA & 1) |
| 318 | | m_cram[offset] = data; |
| 319 | | else |
| 320 | | { |
| 321 | | // CIA at 0xdc00 |
| 322 | | } |
| 323 | | |
| 472 | return c64_paddle_read(m_sid_r, space, 1); |
| 324 | 473 | } |
| 325 | 474 | |
| 326 | | READ8_MEMBER(c65_state::dummy_r) |
| 475 | |
| 476 | /************************************* |
| 477 | * |
| 478 | * VIC III interfaces |
| 479 | * |
| 480 | *************************************/ |
| 481 | |
| 482 | UINT32 c65_state::screen_update_c65(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 327 | 483 | { |
| 484 | m_vic->video_update(bitmap, cliprect); |
| 328 | 485 | return 0; |
| 329 | 486 | } |
| 330 | 487 | |
| 331 | | static ADDRESS_MAP_START( c65_map, AS_PROGRAM, 8, c65_state ) |
| 332 | | AM_RANGE(0x00000, 0x07fff) AM_RAM AM_SHARE("wram") // TODO: bank |
| 333 | | AM_RANGE(0x0c800, 0x0cfff) AM_ROM AM_REGION("maincpu", 0xc800) |
| 334 | | AM_RANGE(0x0d000, 0x0d07f) AM_READWRITE(vic4567_dummy_r,vic4567_dummy_w) // 0x0d000, 0x0d07f VIC-4567 |
| 335 | | AM_RANGE(0x0d080, 0x0d081) AM_READ(dummy_r) // 0x0d080, 0x0d09f FDC |
| 336 | | // 0x0d0a0, 0x0d0ff Ram Expansion Control (REC) |
| 337 | | AM_RANGE(0x0d100, 0x0d1ff) AM_RAM_WRITE(PalRed_w) AM_SHARE("redpal")// 0x0d100, 0x0d1ff Red Palette |
| 338 | | AM_RANGE(0x0d200, 0x0d2ff) AM_RAM_WRITE(PalGreen_w) AM_SHARE("greenpal") // 0x0d200, 0x0d2ff Green Palette |
| 339 | | AM_RANGE(0x0d300, 0x0d3ff) AM_RAM_WRITE(PalBlue_w) AM_SHARE("bluepal") // 0x0d300, 0x0d3ff Blue Palette |
| 340 | | // 0x0d400, 0x0d4*f Right SID |
| 341 | | // 0x0d440, 0x0d4*f Left SID |
| 342 | | // 0x0d600, 0x0d6** UART |
| 343 | | AM_RANGE(0x0d700, 0x0d702) AM_WRITE(DMAgic_w) AM_SHARE("dmalist") // 0x0d700, 0x0d7** DMAgic |
| 344 | | //AM_RANGE(0x0d703, 0x0d703) AM_READ(DMAgic_r) |
| 345 | | // 0x0d800, 0x0d8** Color matrix |
| 346 | | AM_RANGE(0x0d800, 0x0dfff) AM_READWRITE(CIASelect_r,CIASelect_w) AM_SHARE("cram") |
| 347 | | // 0x0dc00, 0x0dc** CIA-1 |
| 348 | | // 0x0dd00, 0x0dd** CIA-2 |
| 349 | | // 0x0de00, 0x0de** Ext I/O Select 1 |
| 350 | | // 0x0df00, 0x0df** Ext I/O Select 2 (RAM window?) |
| 351 | | AM_RANGE(0x0e000, 0x0ffff) AM_ROM AM_REGION("maincpu",0x0e000) |
| 352 | | AM_RANGE(0x10000, 0x1f7ff) AM_RAM |
| 353 | | AM_RANGE(0x1f800, 0x1ffff) AM_RAM // VRAM attributes |
| 354 | | AM_RANGE(0x20000, 0x3ffff) AM_ROM AM_REGION("maincpu",0) |
| 355 | | ADDRESS_MAP_END |
| 356 | | |
| 357 | | |
| 358 | | |
| 359 | | static INPUT_PORTS_START( c65 ) |
| 360 | | /* dummy active high structure */ |
| 361 | | PORT_START("SYSA") |
| 362 | | PORT_DIPNAME( 0x01, 0x00, "SYSA" ) |
| 363 | | PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) |
| 364 | | PORT_DIPSETTING( 0x01, DEF_STR( On ) ) |
| 365 | | PORT_DIPNAME( 0x02, 0x00, DEF_STR( Unknown ) ) |
| 366 | | PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) |
| 367 | | PORT_DIPSETTING( 0x02, DEF_STR( On ) ) |
| 368 | | PORT_DIPNAME( 0x04, 0x00, DEF_STR( Unknown ) ) |
| 369 | | PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) |
| 370 | | PORT_DIPSETTING( 0x04, DEF_STR( On ) ) |
| 371 | | PORT_DIPNAME( 0x08, 0x00, DEF_STR( Unknown ) ) |
| 372 | | PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) |
| 373 | | PORT_DIPSETTING( 0x08, DEF_STR( On ) ) |
| 374 | | PORT_DIPNAME( 0x10, 0x00, DEF_STR( Unknown ) ) |
| 375 | | PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) |
| 376 | | PORT_DIPSETTING( 0x10, DEF_STR( On ) ) |
| 377 | | PORT_DIPNAME( 0x20, 0x00, DEF_STR( Unknown ) ) |
| 378 | | PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) |
| 379 | | PORT_DIPSETTING( 0x20, DEF_STR( On ) ) |
| 380 | | PORT_DIPNAME( 0x40, 0x00, DEF_STR( Unknown ) ) |
| 381 | | PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) |
| 382 | | PORT_DIPSETTING( 0x40, DEF_STR( On ) ) |
| 383 | | PORT_DIPNAME( 0x80, 0x00, DEF_STR( Unknown ) ) |
| 384 | | PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) |
| 385 | | PORT_DIPSETTING( 0x80, DEF_STR( On ) ) |
| 386 | | |
| 387 | | /* dummy active low structure */ |
| 388 | | PORT_START("DSWA") |
| 389 | | PORT_DIPNAME( 0x01, 0x01, "DSWA" ) |
| 390 | | PORT_DIPSETTING( 0x01, DEF_STR( Off ) ) |
| 391 | | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) |
| 392 | | PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unknown ) ) |
| 393 | | PORT_DIPSETTING( 0x02, DEF_STR( Off ) ) |
| 394 | | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) |
| 395 | | PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unknown ) ) |
| 396 | | PORT_DIPSETTING( 0x04, DEF_STR( Off ) ) |
| 397 | | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) |
| 398 | | PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) ) |
| 399 | | PORT_DIPSETTING( 0x08, DEF_STR( Off ) ) |
| 400 | | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) |
| 401 | | PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) ) |
| 402 | | PORT_DIPSETTING( 0x10, DEF_STR( Off ) ) |
| 403 | | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) |
| 404 | | PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) ) |
| 405 | | PORT_DIPSETTING( 0x20, DEF_STR( Off ) ) |
| 406 | | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) |
| 407 | | PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) ) |
| 408 | | PORT_DIPSETTING( 0x40, DEF_STR( Off ) ) |
| 409 | | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) |
| 410 | | PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) ) |
| 411 | | PORT_DIPSETTING( 0x80, DEF_STR( Off ) ) |
| 412 | | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) |
| 413 | | INPUT_PORTS_END |
| 414 | | |
| 415 | | |
| 416 | | void c65_state::machine_start() |
| 488 | READ8_MEMBER(c65_state::c65_lightpen_x_cb) |
| 417 | 489 | { |
| 418 | | m_iplrom = memregion("maincpu")->base(); |
| 419 | | |
| 420 | | save_pointer(NAME(m_cram.target()), 0x800); |
| 490 | return ioport("LIGHTX")->read() & ~0x01; |
| 421 | 491 | } |
| 422 | 492 | |
| 423 | | void c65_state::machine_reset() |
| 493 | READ8_MEMBER(c65_state::c65_lightpen_y_cb) |
| 424 | 494 | { |
| 495 | return ioport("LIGHTY")->read() & ~0x01; |
| 425 | 496 | } |
| 426 | 497 | |
| 427 | | |
| 428 | | PALETTE_INIT_MEMBER(c65_state, c65) |
| 498 | READ8_MEMBER(c65_state::c65_lightpen_button_cb) |
| 429 | 499 | { |
| 430 | | // TODO: initial state? |
| 500 | return ioport("OTHER")->read() & 0x04; |
| 431 | 501 | } |
| 432 | 502 | |
| 433 | | static const gfx_layout charlayout = |
| 503 | READ8_MEMBER(c65_state::c65_c64_mem_r) |
| 434 | 504 | { |
| 435 | | 8,8, |
| 436 | | 0x1000/8, |
| 437 | | 1, |
| 438 | | { RGN_FRAC(0,1) }, |
| 439 | | { 0, 1, 2, 3, 4, 5, 6, 7 }, |
| 440 | | { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 }, |
| 441 | | 8*8 |
| 442 | | }; |
| 505 | return m_memory[offset]; |
| 506 | } |
| 443 | 507 | |
| 444 | | static GFXDECODE_START( c65 ) |
| 445 | | GFXDECODE_ENTRY( "maincpu", 0xd000, charlayout, 0, 16 ) // another identical copy is at 0x9000 |
| 446 | | GFXDECODE_END |
| 447 | | |
| 448 | | INTERRUPT_GEN_MEMBER(c65_state::vic3_vblank_irq) |
| 508 | INTERRUPT_GEN_MEMBER(c65_state::vic3_raster_irq) |
| 449 | 509 | { |
| 450 | | //if(m_VIC2_IRQMask & 1) |
| 451 | | // m_maincpu->set_input_line(M4510_IRQ_LINE,HOLD_LINE); |
| 510 | m_vic->raster_interrupt_gen(); |
| 452 | 511 | } |
| 453 | 512 | |
| 513 | /************************************* |
| 514 | * |
| 515 | * Machine driver |
| 516 | * |
| 517 | *************************************/ |
| 518 | |
| 454 | 519 | static MACHINE_CONFIG_START( c65, c65_state ) |
| 455 | | |
| 456 | 520 | /* basic machine hardware */ |
| 457 | | MCFG_CPU_ADD("maincpu",M4510,MAIN_CLOCK) |
| 458 | | MCFG_CPU_PROGRAM_MAP(c65_map) |
| 459 | | MCFG_CPU_VBLANK_INT_DRIVER("screen",c65_state,vic3_vblank_irq) |
| 521 | MCFG_CPU_ADD("maincpu", M4510, 3500000) /* or VIC6567_CLOCK, */ |
| 522 | MCFG_CPU_PROGRAM_MAP(c65_mem) |
| 523 | MCFG_CPU_VBLANK_INT_DRIVER("screen", c65_state, c65_frame_interrupt) |
| 524 | MCFG_CPU_PERIODIC_INT_DRIVER(c65_state, vic3_raster_irq, VIC6567_HRETRACERATE) |
| 460 | 525 | |
| 526 | MCFG_MACHINE_START_OVERRIDE(c65_state, c65 ) |
| 527 | |
| 461 | 528 | /* video hardware */ |
| 462 | 529 | MCFG_SCREEN_ADD("screen", RASTER) |
| 463 | | // MCFG_SCREEN_REFRESH_RATE(60) |
| 464 | | // MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) |
| 465 | | MCFG_SCREEN_UPDATE_DRIVER(c65_state, screen_update) |
| 466 | | // MCFG_SCREEN_SIZE(32*8, 32*8) |
| 467 | | // MCFG_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 0*8, 32*8-1) |
| 468 | | MCFG_SCREEN_RAW_PARAMS(MAIN_CLOCK, 910, 0, 640, 525, 0, 200) // mods needed |
| 469 | | MCFG_SCREEN_PALETTE("palette") |
| 530 | MCFG_SCREEN_REFRESH_RATE(VIC6567_VRETRACERATE) |
| 531 | MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) /* not accurate */ |
| 532 | MCFG_SCREEN_SIZE(525 * 2, 520 * 2) |
| 533 | MCFG_SCREEN_VISIBLE_AREA(VIC6567_STARTVISIBLECOLUMNS ,(VIC6567_STARTVISIBLECOLUMNS + VIC6567_VISIBLECOLUMNS - 1) * 2, VIC6567_STARTVISIBLELINES, VIC6567_STARTVISIBLELINES + VIC6567_VISIBLELINES - 1) |
| 534 | MCFG_SCREEN_UPDATE_DRIVER(c65_state, screen_update_c65) |
| 535 | MCFG_SCREEN_PALETTE("vic3:palette") |
| 470 | 536 | |
| 471 | | MCFG_GFXDECODE_ADD("gfxdecode", "palette", c65) |
| 537 | MCFG_DEVICE_ADD("vic3", VIC3, 0) |
| 538 | MCFG_VIC3_CPU("maincpu") |
| 539 | MCFG_VIC3_TYPE(VIC4567_NTSC) |
| 540 | MCFG_VIC3_LIGHTPEN_X_CB(READ8(c65_state, c65_lightpen_x_cb)) |
| 541 | MCFG_VIC3_LIGHTPEN_Y_CB(READ8(c65_state, c65_lightpen_y_cb)) |
| 542 | MCFG_VIC3_LIGHTPEN_BUTTON_CB(READ8(c65_state, c65_lightpen_button_cb)) |
| 543 | MCFG_VIC3_DMA_READ_CB(READ8(c65_state, c65_dma_read)) |
| 544 | MCFG_VIC3_DMA_READ_COLOR_CB(READ8(c65_state, c65_dma_read_color)) |
| 545 | MCFG_VIC3_INTERRUPT_CB(WRITELINE(c65_state, c65_vic_interrupt)) |
| 546 | MCFG_VIC3_PORT_CHANGED_CB(WRITE8(c65_state, c65_bankswitch_interface)) |
| 547 | MCFG_VIC3_C64_MEM_R_CB(READ8(c65_state, c65_c64_mem_r)) |
| 472 | 548 | |
| 473 | | MCFG_PALETTE_ADD("palette", 0x100) |
| 474 | | MCFG_PALETTE_INIT_OWNER(c65_state, c65) |
| 549 | /* sound hardware */ |
| 550 | MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker") |
| 551 | MCFG_SOUND_ADD("sid_r", MOS8580, 985248) |
| 552 | MCFG_MOS6581_POTX_CALLBACK(READ8(c65_state, sid_potx_r)) |
| 553 | MCFG_MOS6581_POTY_CALLBACK(READ8(c65_state, sid_poty_r)) |
| 554 | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.50) |
| 555 | MCFG_SOUND_ADD("sid_l", MOS8580, 985248) |
| 556 | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.50) |
| 475 | 557 | |
| 558 | /* quickload */ |
| 559 | MCFG_QUICKLOAD_ADD("quickload", c65_state, cbm_c65, "p00,prg", CBM_QUICKLOAD_DELAY_SECONDS) |
| 560 | |
| 561 | /* cia */ |
| 562 | MCFG_DEVICE_ADD("cia_0", MOS6526, 3500000) |
| 563 | MCFG_MOS6526_TOD(60) |
| 564 | MCFG_MOS6526_IRQ_CALLBACK(WRITELINE(c65_state, c65_cia0_interrupt)) |
| 565 | MCFG_MOS6526_PA_INPUT_CALLBACK(READ8(c65_state, c65_cia0_port_a_r)) |
| 566 | MCFG_MOS6526_PB_INPUT_CALLBACK(READ8(c65_state, c65_cia0_port_b_r)) |
| 567 | MCFG_MOS6526_PB_OUTPUT_CALLBACK(WRITE8(c65_state, c65_cia0_port_b_w)) |
| 568 | |
| 569 | MCFG_DEVICE_ADD("cia_1", MOS6526, 3500000) |
| 570 | MCFG_MOS6526_TOD(60) |
| 571 | MCFG_MOS6526_IRQ_CALLBACK(WRITELINE(c65_state, c65_cia1_interrupt)) |
| 572 | MCFG_MOS6526_PA_INPUT_CALLBACK(READ8(c65_state, c65_cia1_port_a_r)) |
| 573 | MCFG_MOS6526_PA_OUTPUT_CALLBACK(WRITE8(c65_state, c65_cia1_port_a_w)) |
| 574 | |
| 575 | /* floppy from serial bus */ |
| 576 | MCFG_CBM_IEC_ADD(NULL) |
| 577 | |
| 578 | /* internal ram */ |
| 579 | MCFG_RAM_ADD(RAM_TAG) |
| 580 | MCFG_RAM_DEFAULT_SIZE("128K") |
| 581 | MCFG_RAM_EXTRA_OPTIONS("640K,4224K") |
| 582 | MACHINE_CONFIG_END |
| 583 | |
| 584 | static MACHINE_CONFIG_DERIVED( c65pal, c65 ) |
| 585 | MCFG_SCREEN_MODIFY("screen") |
| 586 | MCFG_SCREEN_REFRESH_RATE(VIC6569_VRETRACERATE) |
| 587 | MCFG_SCREEN_SIZE(625 * 2, 520 * 2) |
| 588 | MCFG_SCREEN_VISIBLE_AREA(VIC6569_STARTVISIBLECOLUMNS, (VIC6569_STARTVISIBLECOLUMNS + VIC6569_VISIBLECOLUMNS - 1) * 2, VIC6569_STARTVISIBLELINES, VIC6569_STARTVISIBLELINES + VIC6569_VISIBLELINES - 1) |
| 589 | MCFG_SCREEN_PALETTE("vic3:palette") |
| 590 | |
| 591 | MCFG_DEVICE_MODIFY("vic3") |
| 592 | MCFG_VIC3_TYPE(VIC4567_PAL) |
| 593 | |
| 476 | 594 | /* sound hardware */ |
| 477 | | MCFG_SPEAKER_STANDARD_MONO("mono") |
| 478 | | // MCFG_SOUND_ADD("aysnd", AY8910, MAIN_CLOCK/4) |
| 479 | | // MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.30) |
| 595 | MCFG_SOUND_REPLACE("sid_r", MOS8580, 1022727) |
| 596 | MCFG_MOS6581_POTX_CALLBACK(READ8(c65_state, sid_potx_r)) |
| 597 | MCFG_MOS6581_POTY_CALLBACK(READ8(c65_state, sid_poty_r)) |
| 598 | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.50) |
| 599 | MCFG_SOUND_REPLACE("sid_l", MOS8580, 1022727) |
| 600 | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.50) |
| 601 | |
| 602 | /* cia */ |
| 603 | MCFG_DEVICE_MODIFY("cia_0") |
| 604 | MCFG_MOS6526_TOD(50) |
| 605 | |
| 606 | MCFG_DEVICE_MODIFY("cia_1") |
| 607 | MCFG_MOS6526_TOD(50) |
| 480 | 608 | MACHINE_CONFIG_END |
| 481 | 609 | |
| 482 | 610 | |
| 483 | | /*************************************************************************** |
| 611 | /************************************* |
| 612 | * |
| 613 | * ROM definition(s) |
| 614 | * |
| 615 | *************************************/ |
| 484 | 616 | |
| 485 | | Game driver(s) |
| 486 | 617 | |
| 487 | | ***************************************************************************/ |
| 488 | | |
| 489 | 618 | ROM_START( c65 ) |
| 490 | | ROM_REGION( 0x20000, "maincpu", 0 ) |
| 619 | ROM_REGION( 0x400000, "maincpu", 0 ) |
| 491 | 620 | ROM_SYSTEM_BIOS( 0, "910111", "V0.9.910111" ) |
| 492 | | ROMX_LOAD( "910111.bin", 0x0000, 0x20000, CRC(c5d8d32e) SHA1(71c05f098eff29d306b0170e2c1cdeadb1a5f206), ROM_BIOS(1) ) |
| 621 | ROMX_LOAD( "910111.bin", 0x20000, 0x20000, CRC(c5d8d32e) SHA1(71c05f098eff29d306b0170e2c1cdeadb1a5f206), ROM_BIOS(1) ) |
| 493 | 622 | ROM_SYSTEM_BIOS( 1, "910523", "V0.9.910523" ) |
| 494 | | ROMX_LOAD( "910523.bin", 0x0000, 0x20000, CRC(e8235dd4) SHA1(e453a8e7e5b95de65a70952e9d48012191e1b3e7), ROM_BIOS(2) ) |
| 623 | ROMX_LOAD( "910523.bin", 0x20000, 0x20000, CRC(e8235dd4) SHA1(e453a8e7e5b95de65a70952e9d48012191e1b3e7), ROM_BIOS(2) ) |
| 495 | 624 | ROM_SYSTEM_BIOS( 2, "910626", "V0.9.910626" ) |
| 496 | | ROMX_LOAD( "910626.bin", 0x0000, 0x20000, CRC(12527742) SHA1(07c185b3bc58410183422f7ac13a37ddd330881b), ROM_BIOS(3) ) |
| 625 | ROMX_LOAD( "910626.bin", 0x20000, 0x20000, CRC(12527742) SHA1(07c185b3bc58410183422f7ac13a37ddd330881b), ROM_BIOS(3) ) |
| 497 | 626 | ROM_SYSTEM_BIOS( 3, "910828", "V0.9.910828" ) |
| 498 | | ROMX_LOAD( "910828.bin", 0x0000, 0x20000, CRC(3ee40b06) SHA1(b63d970727a2b8da72a0a8e234f3c30a20cbcb26), ROM_BIOS(4) ) |
| 627 | ROMX_LOAD( "910828.bin", 0x20000, 0x20000, CRC(3ee40b06) SHA1(b63d970727a2b8da72a0a8e234f3c30a20cbcb26), ROM_BIOS(4) ) |
| 499 | 628 | ROM_SYSTEM_BIOS( 4, "911001", "V0.9.911001" ) |
| 500 | | ROMX_LOAD( "911001.bin", 0x0000, 0x20000, CRC(0888b50f) SHA1(129b9a2611edaebaa028ac3e3f444927c8b1fc5d), ROM_BIOS(5) ) |
| 629 | ROMX_LOAD( "911001.bin", 0x20000, 0x20000, CRC(0888b50f) SHA1(129b9a2611edaebaa028ac3e3f444927c8b1fc5d), ROM_BIOS(5) ) |
| 501 | 630 | ROM_END |
| 502 | 631 | |
| 503 | 632 | ROM_START( c64dx ) |
| 504 | | ROM_REGION( 0x20000, "maincpu", 0 ) |
| 505 | | ROM_LOAD( "910429.bin", 0x0000, 0x20000, CRC(b025805c) SHA1(c3b05665684f74adbe33052a2d10170a1063ee7d) ) |
| 633 | ROM_REGION( 0x400000, "maincpu", 0 ) |
| 634 | ROM_LOAD( "910429.bin", 0x20000, 0x20000, CRC(b025805c) SHA1(c3b05665684f74adbe33052a2d10170a1063ee7d) ) |
| 506 | 635 | ROM_END |
| 507 | 636 | |
| 508 | | DRIVER_INIT_MEMBER(c65_state,c65) |
| 509 | | { |
| 510 | | // m_dma.version = 2; |
| 511 | | // c65_common_driver_init(); |
| 512 | | } |
| 637 | /*************************************************************************** |
| 513 | 638 | |
| 514 | | DRIVER_INIT_MEMBER(c65_state,c65pal) |
| 515 | | { |
| 516 | | // m_dma.version = 1; |
| 517 | | // c65_common_driver_init(); |
| 518 | | // m_pal = 1; |
| 519 | | } |
| 639 | Game driver(s) |
| 520 | 640 | |
| 521 | | COMP( 1991, c65, 0, 0, c65, c65, c65_state, c65, "Commodore Business Machines", "Commodore 65 Development System (Prototype, NTSC)", GAME_NOT_WORKING ) |
| 522 | | COMP( 1991, c64dx, c65, 0, c65, c65, c65_state, c65pal, "Commodore Business Machines", "Commodore 64DX Development System (Prototype, PAL, German)", GAME_NOT_WORKING ) |
| 641 | ***************************************************************************/ |
| 642 | |
| 643 | /* YEAR NAME PARENT COMPAT MACHINE INPUT INIT COMPANY FULLNAME FLAGS */ |
| 644 | |
| 645 | COMP( 1991, c65, 0, 0, c65, c65, c65_state, c65, "Commodore Business Machines", "Commodore 65 Development System (Prototype, NTSC)", GAME_NOT_WORKING ) |
| 646 | COMP( 1991, c64dx, c65, 0, c65pal, c65ger, c65_state, c65pal, "Commodore Business Machines", "Commodore 64DX Development System (Prototype, PAL, German)", GAME_NOT_WORKING ) |
trunk/src/mess/drivers/c65_old.c
| r243230 | r243231 | |
| 1 | | /*************************************************************************** |
| 2 | | |
| 3 | | commodore c65 home computer |
| 4 | | PeT mess@utanet.at |
| 5 | | |
| 6 | | documention |
| 7 | | www.funet.fi |
| 8 | | |
| 9 | | ***************************************************************************/ |
| 10 | | |
| 11 | | /* |
| 12 | | |
| 13 | | 2008 - Driver Updates |
| 14 | | --------------------- |
| 15 | | |
| 16 | | (most of the informations are taken from http://www.zimmers.net/cbmpics/ ) |
| 17 | | |
| 18 | | |
| 19 | | [CBM systems which belong to this driver] |
| 20 | | |
| 21 | | * Commodore 65 (1989) |
| 22 | | |
| 23 | | Also known as C64 DX at early stages of the project. It was cancelled |
| 24 | | around 1990-1991. Only few units survive (they were sold after Commodore |
| 25 | | liquidation in 1994). |
| 26 | | |
| 27 | | CPU: CSG 4510 (3.54 MHz) |
| 28 | | RAM: 128 kilobytes, expandable to 8 megabytes |
| 29 | | ROM: 128 kilobytes |
| 30 | | Video: CSG 4569 "VIC-III" (6 Video modes; Resolutions from 320x200 to |
| 31 | | 1280x400; 80 columns text; Palette of 4096 colors) |
| 32 | | Sound: CSG 8580 "SID" x2 (6 voice stereo synthesizer/digital sound |
| 33 | | capabilities) |
| 34 | | Ports: CSG 4510 (2 Joystick/Mouse ports; CBM Serial port; CBM 'USER' |
| 35 | | port; CBM Monitor port; Power and reset switches; C65 bus drive |
| 36 | | port; RGBI video port; 2 RCA audio ports; RAM expansion port; C65 |
| 37 | | expansion port) |
| 38 | | Keyboard: Full-sized 77 key QWERTY (12 programmable function keys; |
| 39 | | 4 direction cursor-pad) |
| 40 | | Additional Hardware: Built in 3.5" DD disk drive (1581 compatible) |
| 41 | | Miscellaneous: Partially implemented Commodore 64 emulation |
| 42 | | |
| 43 | | [Notes] |
| 44 | | |
| 45 | | The datasette port was removed here. C65 supports an additional "dumb" |
| 46 | | drive externally. It also features, in addition to the standard CBM |
| 47 | | bus serial (available in all modes), a Fast and a Burst serial bus |
| 48 | | (both available in C65 mode only) |
| 49 | | |
| 50 | | */ |
| 51 | | |
| 52 | | |
| 53 | | #include "emu.h" |
| 54 | | #include "cpu/m6502/m4510.h" |
| 55 | | #include "machine/mos6526.h" |
| 56 | | #include "machine/cbm_snqk.h" |
| 57 | | #include "includes/c65.h" |
| 58 | | #include "bus/cbmiec/cbmiec.h" |
| 59 | | #include "machine/ram.h" |
| 60 | | |
| 61 | | static void cbm_c65_quick_sethiaddress( address_space &space, UINT16 hiaddress ) |
| 62 | | { |
| 63 | | space.write_byte(0x82, hiaddress & 0xff); |
| 64 | | space.write_byte(0x83, hiaddress >> 8); |
| 65 | | } |
| 66 | | |
| 67 | | QUICKLOAD_LOAD_MEMBER( c65_state, cbm_c65 ) |
| 68 | | { |
| 69 | | return general_cbm_loadsnap(image, file_type, quickload_size, m_maincpu->space(AS_PROGRAM), 0, cbm_c65_quick_sethiaddress); |
| 70 | | } |
| 71 | | |
| 72 | | /************************************* |
| 73 | | * |
| 74 | | * Main CPU memory handlers |
| 75 | | * |
| 76 | | *************************************/ |
| 77 | | |
| 78 | | static ADDRESS_MAP_START( c65_mem , AS_PROGRAM, 8, c65_state ) |
| 79 | | AM_RANGE(0x00000, 0x07fff) AM_RAMBANK("bank11") |
| 80 | | AM_RANGE(0x08000, 0x09fff) AM_READ_BANK("bank1") AM_WRITE_BANK("bank12") |
| 81 | | AM_RANGE(0x0a000, 0x0bfff) AM_READ_BANK("bank2") AM_WRITE_BANK("bank13") |
| 82 | | AM_RANGE(0x0c000, 0x0cfff) AM_READ_BANK("bank3") AM_WRITE_BANK("bank14") |
| 83 | | AM_RANGE(0x0d000, 0x0d7ff) AM_READ_BANK("bank4") AM_WRITE_BANK("bank5") |
| 84 | | AM_RANGE(0x0d800, 0x0dbff) AM_READ_BANK("bank6") AM_WRITE_BANK("bank7") |
| 85 | | AM_RANGE(0x0dc00, 0x0dfff) AM_READ_BANK("bank8") AM_WRITE_BANK("bank9") |
| 86 | | AM_RANGE(0x0e000, 0x0ffff) AM_READ_BANK("bank10") AM_WRITE_BANK("bank15") |
| 87 | | AM_RANGE(0x10000, 0x1f7ff) AM_RAM |
| 88 | | AM_RANGE(0x1f800, 0x1ffff) AM_RAM AM_SHARE("colorram") |
| 89 | | |
| 90 | | AM_RANGE(0x20000, 0x23fff) AM_ROM /* &c65_dos, maps to 0x8000 */ |
| 91 | | AM_RANGE(0x24000, 0x28fff) AM_ROM /* reserved */ |
| 92 | | AM_RANGE(0x29000, 0x29fff) AM_ROM AM_SHARE("c65_chargen") |
| 93 | | AM_RANGE(0x2a000, 0x2bfff) AM_ROM AM_SHARE("basic") |
| 94 | | AM_RANGE(0x2c000, 0x2cfff) AM_ROM AM_SHARE("interface") |
| 95 | | AM_RANGE(0x2d000, 0x2dfff) AM_ROM AM_SHARE("chargen") |
| 96 | | AM_RANGE(0x2e000, 0x2ffff) AM_ROM AM_SHARE("kernal") |
| 97 | | |
| 98 | | AM_RANGE(0x30000, 0x31fff) AM_ROM /*&c65_monitor, monitor maps to 0x6000 */ |
| 99 | | AM_RANGE(0x32000, 0x37fff) AM_ROM /*&c65_basic, */ |
| 100 | | AM_RANGE(0x38000, 0x3bfff) AM_ROM /*&c65_graphics, */ |
| 101 | | AM_RANGE(0x3c000, 0x3dfff) AM_ROM /* reserved */ |
| 102 | | AM_RANGE(0x3e000, 0x3ffff) AM_ROM /* &c65_kernal, */ |
| 103 | | |
| 104 | | AM_RANGE(0x40000, 0x7ffff) AM_NOP |
| 105 | | /* 8 megabyte full address space! */ |
| 106 | | ADDRESS_MAP_END |
| 107 | | |
| 108 | | |
| 109 | | /************************************* |
| 110 | | * |
| 111 | | * Input Ports |
| 112 | | * |
| 113 | | *************************************/ |
| 114 | | |
| 115 | | static INPUT_PORTS_START( c65 ) |
| 116 | | PORT_START( "ROW0" ) |
| 117 | | PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Crsr Down Up") PORT_CODE(KEYCODE_RALT) PORT_CHAR(UCHAR_MAMEKEY(DOWN)) PORT_CHAR(UCHAR_MAMEKEY(UP)) |
| 118 | | PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F3) PORT_CHAR(UCHAR_MAMEKEY(F5)) |
| 119 | | PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F2) PORT_CHAR(UCHAR_MAMEKEY(F3)) |
| 120 | | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F1) PORT_CHAR(UCHAR_MAMEKEY(F1)) |
| 121 | | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F4) PORT_CHAR(UCHAR_MAMEKEY(F7)) |
| 122 | | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Crsr Right Left") PORT_CODE(KEYCODE_RCONTROL) PORT_CHAR(UCHAR_MAMEKEY(RIGHT)) PORT_CHAR(UCHAR_MAMEKEY(LEFT)) |
| 123 | | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Return") PORT_CODE(KEYCODE_ENTER) PORT_CHAR(13) |
| 124 | | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("INST DEL") PORT_CODE(KEYCODE_BACKSPACE) PORT_CHAR(8) PORT_CHAR(UCHAR_MAMEKEY(INSERT)) |
| 125 | | |
| 126 | | PORT_START( "ROW1" ) |
| 127 | | PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Shift (Left)") PORT_CODE(KEYCODE_LSHIFT) PORT_CHAR(UCHAR_SHIFT_1) |
| 128 | | PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_E) PORT_CHAR('E') |
| 129 | | PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_S) PORT_CHAR('S') |
| 130 | | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_Z) PORT_CHAR('Z') |
| 131 | | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_4) PORT_CHAR('4') PORT_CHAR('$') |
| 132 | | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_A) PORT_CHAR('A') |
| 133 | | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_W) PORT_CHAR('W') |
| 134 | | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_3) PORT_CHAR('3') PORT_CHAR('#') |
| 135 | | |
| 136 | | PORT_START( "ROW2" ) |
| 137 | | PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_X) PORT_CHAR('X') |
| 138 | | PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_T) PORT_CHAR('T') |
| 139 | | PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F) PORT_CHAR('F') |
| 140 | | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_C) PORT_CHAR('C') |
| 141 | | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_6) PORT_CHAR('6') PORT_CHAR('&') |
| 142 | | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_D) PORT_CHAR('D') |
| 143 | | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_R) PORT_CHAR('R') |
| 144 | | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_5) PORT_CHAR('5') PORT_CHAR('%') |
| 145 | | |
| 146 | | PORT_START( "ROW3" ) |
| 147 | | PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_V) PORT_CHAR('V') |
| 148 | | PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_U) PORT_CHAR('U') |
| 149 | | PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_H) PORT_CHAR('H') |
| 150 | | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_B) PORT_CHAR('B') |
| 151 | | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_8) PORT_CHAR('8') PORT_CHAR('(') |
| 152 | | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_G) PORT_CHAR('G') |
| 153 | | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_Y) PORT_CHAR('Y') |
| 154 | | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_7) PORT_CHAR('7') PORT_CHAR('\'') |
| 155 | | |
| 156 | | PORT_START( "ROW4" ) |
| 157 | | PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_N) PORT_CHAR('N') |
| 158 | | PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_O) PORT_CHAR('O') |
| 159 | | PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_K) PORT_CHAR('K') |
| 160 | | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_M) PORT_CHAR('M') |
| 161 | | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_0) PORT_CHAR('0') |
| 162 | | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_J) PORT_CHAR('J') |
| 163 | | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_I) PORT_CHAR('I') |
| 164 | | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_9) PORT_CHAR('9') PORT_CHAR(')') |
| 165 | | |
| 166 | | PORT_START( "ROW5" ) |
| 167 | | PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_COMMA) PORT_CHAR(',') PORT_CHAR('<') |
| 168 | | PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_OPENBRACE) PORT_CHAR('@') |
| 169 | | PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_COLON) PORT_CHAR(':') PORT_CHAR('[') |
| 170 | | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_STOP) PORT_CHAR('.') PORT_CHAR('>') |
| 171 | | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_EQUALS) PORT_CHAR('-') |
| 172 | | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_L) PORT_CHAR('L') |
| 173 | | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_P) PORT_CHAR('P') |
| 174 | | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_MINUS) PORT_CHAR('+') |
| 175 | | |
| 176 | | PORT_START( "ROW6" ) |
| 177 | | PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_SLASH) PORT_CHAR('/') PORT_CHAR('?') |
| 178 | | PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("\xE2\x86\x91 Pi") PORT_CODE(KEYCODE_DEL) PORT_CHAR(0x2191) PORT_CHAR(0x03C0) |
| 179 | | PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_BACKSLASH) PORT_CHAR('=') |
| 180 | | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Shift (Right)") PORT_CODE(KEYCODE_RSHIFT) PORT_CHAR(UCHAR_SHIFT_1) |
| 181 | | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("CLR HOME") PORT_CODE(KEYCODE_INSERT) PORT_CHAR(UCHAR_MAMEKEY(HOME)) |
| 182 | | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_QUOTE) PORT_CHAR(';') PORT_CHAR(']') |
| 183 | | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_CLOSEBRACE) PORT_CHAR('*') |
| 184 | | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_BACKSLASH2) PORT_CHAR('\xA3') |
| 185 | | |
| 186 | | PORT_START( "ROW7" ) |
| 187 | | PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("RUN STOP") PORT_CODE(KEYCODE_HOME) |
| 188 | | PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_Q) PORT_CHAR('Q') |
| 189 | | PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("CBM") PORT_CODE(KEYCODE_LALT) |
| 190 | | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_SPACE) PORT_CHAR(' ') |
| 191 | | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_2) PORT_CHAR('2') PORT_CHAR('"') |
| 192 | | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_TAB) PORT_CHAR(UCHAR_SHIFT_2) |
| 193 | | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("\xE2\x86\x90") PORT_CODE(KEYCODE_TILDE) PORT_CHAR(0x2190) |
| 194 | | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_1) PORT_CHAR('1') PORT_CHAR('!') |
| 195 | | PORT_START("FUNCT") |
| 196 | | PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("ESC") PORT_CODE(KEYCODE_F1) |
| 197 | | PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("F13 F14") PORT_CODE(KEYCODE_F11) |
| 198 | | PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("F11 F12") PORT_CODE(KEYCODE_F10) |
| 199 | | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("F9 F10") PORT_CODE(KEYCODE_F9) |
| 200 | | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("HELP") PORT_CODE(KEYCODE_F12) |
| 201 | | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("ALT") PORT_CODE(KEYCODE_F2) /* non blocking */ |
| 202 | | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("TAB") PORT_CODE(KEYCODE_TAB) |
| 203 | | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("NO SCRL") PORT_CODE(KEYCODE_F4) |
| 204 | | |
| 205 | | PORT_START( "SPECIAL" ) /* special keys */ |
| 206 | | PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Restore") PORT_CODE(KEYCODE_PRTSCR) |
| 207 | | PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Shift Lock (switch)") PORT_CODE(KEYCODE_CAPSLOCK) PORT_TOGGLE PORT_CHAR(UCHAR_MAMEKEY(CAPSLOCK)) |
| 208 | | PORT_CONFNAME( 0x20, 0x00, "(C65) Caps Lock (switch)") PORT_CODE(KEYCODE_F3) |
| 209 | | PORT_CONFSETTING( 0x00, DEF_STR( Off ) ) |
| 210 | | PORT_CONFSETTING( 0x20, DEF_STR( On ) ) |
| 211 | | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| 212 | | |
| 213 | | PORT_START("CTRLSEL") /* Controller selection */ |
| 214 | | PORT_CONFNAME( 0x07, 0x00, "Gameport A" ) |
| 215 | | PORT_CONFSETTING( 0x00, DEF_STR( Joystick ) ) |
| 216 | | PORT_CONFSETTING( 0x01, "Paddles 1 & 2" ) |
| 217 | | PORT_CONFSETTING( 0x02, "Mouse 1351" ) |
| 218 | | PORT_CONFSETTING( 0x03, "Mouse (Non Proportional) 1350" ) |
| 219 | | PORT_CONFSETTING( 0x04, "Lightpen" ) |
| 220 | | // PORT_CONFSETTING( 0x05, "Koala Pad" ) |
| 221 | | PORT_CONFSETTING( 0x06, "Lightgun" ) |
| 222 | | PORT_CONFSETTING( 0x07, "No Device Connected" ) |
| 223 | | PORT_CONFNAME( 0x70, 0x00, "Gameport B" ) |
| 224 | | PORT_CONFSETTING( 0x00, DEF_STR( Joystick ) ) |
| 225 | | PORT_CONFSETTING( 0x10, "Paddles 3 & 4" ) |
| 226 | | // PORT_CONFSETTING( 0x20, "Mouse 1351" ) |
| 227 | | // PORT_CONFSETTING( 0x30, "Mouse (Non Proportional) 1350" ) |
| 228 | | PORT_CONFSETTING( 0x70, "No Device Connected" ) |
| 229 | | PORT_CONFNAME( 0x80, 0x00, "Swap Gameport A and B") PORT_CODE(KEYCODE_F1) PORT_TOGGLE |
| 230 | | PORT_CONFSETTING( 0x00, DEF_STR( No ) ) |
| 231 | | PORT_CONFSETTING( 0x80, DEF_STR( Yes ) ) |
| 232 | | |
| 233 | | PORT_START("JOY1_1B") |
| 234 | | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x00) |
| 235 | | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x00) |
| 236 | | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x00) |
| 237 | | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x00) |
| 238 | | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x00) |
| 239 | | PORT_BIT( 0xe0, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| 240 | | |
| 241 | | PORT_START("JOY2_1B") |
| 242 | | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(2) PORT_CODE(KEYCODE_HOME) PORT_CODE(JOYCODE_Y_UP_SWITCH) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x00) |
| 243 | | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(2) PORT_CODE(KEYCODE_END) PORT_CODE(JOYCODE_Y_DOWN_SWITCH) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x00) |
| 244 | | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(2) PORT_CODE(KEYCODE_DEL) PORT_CODE(JOYCODE_X_LEFT_SWITCH) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x00) |
| 245 | | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(2) PORT_CODE(KEYCODE_PGDN) PORT_CODE(JOYCODE_X_RIGHT_SWITCH) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x00) |
| 246 | | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_PLAYER(2) PORT_CODE(KEYCODE_INSERT) PORT_CODE(JOYCODE_BUTTON1) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x00) |
| 247 | | PORT_BIT( 0xe0, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| 248 | | |
| 249 | | /* Mouse Commodore 1350 was basically working as a Joystick */ |
| 250 | | PORT_START("JOY1_2B") |
| 251 | | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(1) PORT_NAME("Mouse 1350 Up") PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x03) |
| 252 | | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(1) PORT_NAME("Mouse 1350 Down") PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x03) |
| 253 | | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(1) PORT_NAME("Mouse 1350 Left") PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x03) |
| 254 | | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(1) PORT_NAME("Mouse 1350 Right") PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x03) |
| 255 | | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_PLAYER(1) PORT_NAME("Mouse 1350 Button 1") PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x03) |
| 256 | | PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_PLAYER(1) PORT_NAME("Mouse 1350 Button 2") PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x03) |
| 257 | | PORT_BIT( 0xc0, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| 258 | | |
| 259 | | /* Still to verify how many mices you were able to plug into a c64 */ |
| 260 | | /* Only one, for now */ |
| 261 | | PORT_START("JOY2_2B") |
| 262 | | PORT_BIT( 0xff, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| 263 | | /* PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(2) PORT_CODE(KEYCODE_HOME) PORT_CODE(JOYCODE_Y_UP_SWITCH) |
| 264 | | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(2) PORT_CODE(KEYCODE_END) PORT_CODE(JOYCODE_Y_DOWN_SWITCH) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x30) |
| 265 | | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(2) PORT_CODE(KEYCODE_DEL) PORT_CODE(JOYCODE_X_LEFT_SWITCH) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x30) |
| 266 | | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(2) PORT_CODE(KEYCODE_PGDN) PORT_CODE(JOYCODE_X_RIGHT_SWITCH) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x30) |
| 267 | | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_PLAYER(2) PORT_CODE(KEYCODE_INSERT) PORT_CODE(JOYCODE_BUTTON1) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x30) |
| 268 | | PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_PLAYER(2) PORT_CODE(KEYCODE_PGUP) PORT_CODE(JOYCODE_BUTTON2) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x30) |
| 269 | | PORT_BIT( 0xc0, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| 270 | | */ |
| 271 | | PORT_START("PADDLE1") |
| 272 | | PORT_BIT( 0xff, 128, IPT_PADDLE) PORT_SENSITIVITY(30) PORT_KEYDELTA(20) PORT_MINMAX(0,255) PORT_CENTERDELTA(0) PORT_CODE_DEC(KEYCODE_LEFT) PORT_CODE_INC(KEYCODE_RIGHT) PORT_CODE_DEC(JOYCODE_X_LEFT_SWITCH) PORT_CODE_INC(JOYCODE_X_RIGHT_SWITCH) PORT_PLAYER(1) PORT_REVERSE PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x01) |
| 273 | | |
| 274 | | PORT_START("PADDLE2") |
| 275 | | PORT_BIT( 0xff, 128, IPT_PADDLE) PORT_SENSITIVITY(30) PORT_KEYDELTA(20) PORT_MINMAX(0,255) PORT_CENTERDELTA(0) PORT_CODE_DEC(KEYCODE_DOWN) PORT_CODE_INC(KEYCODE_UP) PORT_CODE_DEC(JOYCODE_Y_UP_SWITCH) PORT_CODE_INC(JOYCODE_Y_DOWN_SWITCH) PORT_PLAYER(2) PORT_REVERSE PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x01) |
| 276 | | |
| 277 | | PORT_START("PADDLE3") |
| 278 | | PORT_BIT( 0xff, 128, IPT_PADDLE) PORT_SENSITIVITY(30) PORT_KEYDELTA(20) PORT_MINMAX(0,255) PORT_CENTERDELTA(0) PORT_CODE_DEC(KEYCODE_HOME) PORT_CODE_INC(KEYCODE_PGUP) PORT_PLAYER(3) PORT_REVERSE PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x10) |
| 279 | | |
| 280 | | PORT_START("PADDLE4") |
| 281 | | PORT_BIT( 0xff, 128, IPT_PADDLE) PORT_SENSITIVITY(30) PORT_KEYDELTA(20) PORT_MINMAX(0,255) PORT_CENTERDELTA(0) PORT_CODE_DEC(KEYCODE_END) PORT_CODE_INC(KEYCODE_PGDN) PORT_PLAYER(4) PORT_REVERSE PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x10) |
| 282 | | |
| 283 | | PORT_START("TRACKX") |
| 284 | | PORT_BIT( 0x7e, 0x00, IPT_TRACKBALL_X) PORT_SENSITIVITY(100) PORT_KEYDELTA(0) PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x02) |
| 285 | | |
| 286 | | PORT_START("TRACKY") |
| 287 | | PORT_BIT( 0x7e, 0x00, IPT_TRACKBALL_Y) PORT_SENSITIVITY(100) PORT_KEYDELTA(0) PORT_PLAYER(1) PORT_REVERSE PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x02) |
| 288 | | |
| 289 | | PORT_START("LIGHTX") |
| 290 | | PORT_BIT( 0xff, 0x00, IPT_TRACKBALL_X) PORT_NAME("Lightpen X Axis") PORT_CROSSHAIR(X, 1.0, 0.0, 0) PORT_SENSITIVITY(30) PORT_KEYDELTA(20) PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x04) |
| 291 | | |
| 292 | | PORT_START("LIGHTY") |
| 293 | | PORT_BIT( 0xff, 0x00, IPT_TRACKBALL_Y) PORT_NAME("Lightpen Y Axis") PORT_CROSSHAIR(Y, 1.0, 0.0, 0) PORT_SENSITIVITY(30) PORT_KEYDELTA(20) PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x04) |
| 294 | | |
| 295 | | PORT_START("OTHER") |
| 296 | | PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_BUTTON1) PORT_NAME("Paddle 1 Button") PORT_CODE(KEYCODE_LCONTROL) PORT_CODE(JOYCODE_BUTTON1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x01) |
| 297 | | PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_BUTTON2) PORT_NAME("Paddle 2 Button") PORT_CODE(KEYCODE_LALT) PORT_CODE(JOYCODE_BUTTON2) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x01) |
| 298 | | PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_BUTTON3) PORT_NAME("Paddle 3 Button") PORT_CODE(KEYCODE_INSERT) PORT_CODE(JOYCODE_BUTTON1) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x10) |
| 299 | | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON4) PORT_NAME("Paddle 4 Button") PORT_CODE(KEYCODE_DEL) PORT_CODE(JOYCODE_BUTTON2) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x10) |
| 300 | | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_BUTTON1) PORT_NAME("Lightpen Signal") PORT_CODE(KEYCODE_LCONTROL) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x04) |
| 301 | | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON1) PORT_NAME("Mouse Button Left") PORT_CODE(KEYCODE_LCONTROL) PORT_CODE(JOYCODE_BUTTON1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x02) |
| 302 | | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON2) PORT_NAME("Mouse Button Right") PORT_CODE(KEYCODE_LALT) PORT_CODE(JOYCODE_BUTTON2) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x02)INPUT_PORTS_END |
| 303 | | |
| 304 | | |
| 305 | | static INPUT_PORTS_START( c65ger ) |
| 306 | | PORT_INCLUDE( c65 ) |
| 307 | | |
| 308 | | PORT_MODIFY( "ROW1" ) |
| 309 | | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Z { Y }") PORT_CODE(KEYCODE_Z) PORT_CHAR('Z') |
| 310 | | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("3 # { 3 Paragraph }") PORT_CODE(KEYCODE_3) PORT_CHAR('3') PORT_CHAR('#') |
| 311 | | |
| 312 | | PORT_MODIFY( "ROW3" ) |
| 313 | | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Y { Z }") PORT_CODE(KEYCODE_Y) PORT_CHAR('Y') |
| 314 | | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("7 ' { 7 / }") PORT_CODE(KEYCODE_7) PORT_CHAR('7') PORT_CHAR('\'') |
| 315 | | |
| 316 | | PORT_MODIFY( "ROW4" ) |
| 317 | | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("0 { = }") PORT_CODE(KEYCODE_0) PORT_CHAR('0') |
| 318 | | |
| 319 | | PORT_MODIFY( "ROW5" ) |
| 320 | | PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME(", < { ; }") PORT_CODE(KEYCODE_COMMA) PORT_CHAR(',') PORT_CHAR('<') |
| 321 | | PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Paragraph \xE2\x86\x91 { \xc3\xbc }") PORT_CODE(KEYCODE_OPENBRACE) PORT_CHAR(0x00A7) PORT_CHAR(0x2191) |
| 322 | | PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME(": [ { \xc3\xa4 }") PORT_CODE(KEYCODE_COLON) PORT_CHAR(':') PORT_CHAR('[') |
| 323 | | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME(". > { : }") PORT_CODE(KEYCODE_STOP) PORT_CHAR('.') PORT_CHAR('>') |
| 324 | | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("- { ' ` }") PORT_CODE(KEYCODE_EQUALS) PORT_CHAR('-') |
| 325 | | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("+ { \xc3\x9f ? }") PORT_CODE(KEYCODE_MINUS) PORT_CHAR('+') |
| 326 | | |
| 327 | | PORT_MODIFY( "ROW6" ) |
| 328 | | PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("/ ? { - _ }") PORT_CODE(KEYCODE_SLASH) PORT_CHAR('/') PORT_CHAR('?') |
| 329 | | PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Sum Pi { ] \\ }") PORT_CODE(KEYCODE_DEL) PORT_CHAR(0x03A3) PORT_CHAR(0x03C0) |
| 330 | | PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("= { # ' }") PORT_CODE(KEYCODE_BACKSLASH) PORT_CHAR('=') |
| 331 | | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("; ] { \xc3\xb6 }") PORT_CODE(KEYCODE_QUOTE) PORT_CHAR(';') PORT_CHAR(']') |
| 332 | | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("* ` { + * }") PORT_CODE(KEYCODE_CLOSEBRACE) PORT_CHAR('*') PORT_CHAR('`') |
| 333 | | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("\\ { [ \xE2\x86\x91 }") PORT_CODE(KEYCODE_BACKSLASH2) PORT_CHAR('\xa3') |
| 334 | | |
| 335 | | PORT_MODIFY( "ROW7" ) |
| 336 | | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("_ { < > }") PORT_CODE(KEYCODE_TILDE) PORT_CHAR('_') |
| 337 | | |
| 338 | | PORT_MODIFY("SPECIAL") /* special keys */ |
| 339 | | PORT_DIPNAME( 0x20, 0x00, "(C65) DIN ASC (switch)") PORT_CODE(KEYCODE_F3) |
| 340 | | PORT_DIPSETTING( 0x00, "ASC" ) |
| 341 | | PORT_DIPSETTING( 0x20, "DIN" ) |
| 342 | | INPUT_PORTS_END |
| 343 | | |
| 344 | | |
| 345 | | |
| 346 | | /************************************* |
| 347 | | * |
| 348 | | * Sound definitions |
| 349 | | * |
| 350 | | *************************************/ |
| 351 | | |
| 352 | | int c65_state::c64_paddle_read( device_t *device, address_space &space, int which ) |
| 353 | | { |
| 354 | | int pot1 = 0xff, pot2 = 0xff, pot3 = 0xff, pot4 = 0xff, temp; |
| 355 | | UINT8 cia0porta = machine().device<mos6526_device>("cia_0")->pa_r(space, 0); |
| 356 | | int controller1 = ioport("CTRLSEL")->read() & 0x07; |
| 357 | | int controller2 = ioport("CTRLSEL")->read() & 0x70; |
| 358 | | /* Notice that only a single input is defined for Mouse & Lightpen in both ports */ |
| 359 | | switch (controller1) |
| 360 | | { |
| 361 | | case 0x01: |
| 362 | | if (which) |
| 363 | | pot2 = ioport("PADDLE2")->read(); |
| 364 | | else |
| 365 | | pot1 = ioport("PADDLE1")->read(); |
| 366 | | break; |
| 367 | | |
| 368 | | case 0x02: |
| 369 | | if (which) |
| 370 | | pot2 = ioport("TRACKY")->read(); |
| 371 | | else |
| 372 | | pot1 = ioport("TRACKX")->read(); |
| 373 | | break; |
| 374 | | |
| 375 | | case 0x03: |
| 376 | | if (which && (ioport("JOY1_2B")->read() & 0x20)) /* Joy1 Button 2 */ |
| 377 | | pot1 = 0x00; |
| 378 | | break; |
| 379 | | |
| 380 | | case 0x04: |
| 381 | | if (which) |
| 382 | | pot2 = ioport("LIGHTY")->read(); |
| 383 | | else |
| 384 | | pot1 = ioport("LIGHTX")->read(); |
| 385 | | break; |
| 386 | | |
| 387 | | case 0x06: |
| 388 | | if (which && (ioport("OTHER")->read() & 0x04)) /* Lightpen Signal */ |
| 389 | | pot2 = 0x00; |
| 390 | | break; |
| 391 | | |
| 392 | | case 0x00: |
| 393 | | case 0x07: |
| 394 | | break; |
| 395 | | |
| 396 | | default: |
| 397 | | logerror("Invalid Controller Setting %d\n", controller1); |
| 398 | | break; |
| 399 | | } |
| 400 | | |
| 401 | | switch (controller2) |
| 402 | | { |
| 403 | | case 0x10: |
| 404 | | if (which) |
| 405 | | pot4 = ioport("PADDLE4")->read(); |
| 406 | | else |
| 407 | | pot3 = ioport("PADDLE3")->read(); |
| 408 | | break; |
| 409 | | |
| 410 | | case 0x20: |
| 411 | | if (which) |
| 412 | | pot4 = ioport("TRACKY")->read(); |
| 413 | | else |
| 414 | | pot3 = ioport("TRACKX")->read(); |
| 415 | | break; |
| 416 | | |
| 417 | | case 0x30: |
| 418 | | if (which && (ioport("JOY2_2B")->read() & 0x20)) /* Joy2 Button 2 */ |
| 419 | | pot4 = 0x00; |
| 420 | | break; |
| 421 | | |
| 422 | | case 0x40: |
| 423 | | if (which) |
| 424 | | pot4 = ioport("LIGHTY")->read(); |
| 425 | | else |
| 426 | | pot3 = ioport("LIGHTX")->read(); |
| 427 | | break; |
| 428 | | |
| 429 | | case 0x60: |
| 430 | | if (which && (ioport("OTHER")->read() & 0x04)) /* Lightpen Signal */ |
| 431 | | pot4 = 0x00; |
| 432 | | break; |
| 433 | | |
| 434 | | case 0x00: |
| 435 | | case 0x70: |
| 436 | | break; |
| 437 | | |
| 438 | | default: |
| 439 | | logerror("Invalid Controller Setting %d\n", controller1); |
| 440 | | break; |
| 441 | | } |
| 442 | | |
| 443 | | if (ioport("CTRLSEL")->read() & 0x80) /* Swap */ |
| 444 | | { |
| 445 | | temp = pot1; pot1 = pot3; pot3 = temp; |
| 446 | | temp = pot2; pot2 = pot4; pot4 = temp; |
| 447 | | } |
| 448 | | |
| 449 | | switch (cia0porta & 0xc0) |
| 450 | | { |
| 451 | | case 0x40: |
| 452 | | return which ? pot2 : pot1; |
| 453 | | |
| 454 | | case 0x80: |
| 455 | | return which ? pot4 : pot3; |
| 456 | | |
| 457 | | case 0xc0: |
| 458 | | return which ? pot2 : pot1; |
| 459 | | |
| 460 | | default: |
| 461 | | return 0; |
| 462 | | } |
| 463 | | } |
| 464 | | |
| 465 | | READ8_MEMBER( c65_state::sid_potx_r ) |
| 466 | | { |
| 467 | | return c64_paddle_read(m_sid_r, space, 0); |
| 468 | | } |
| 469 | | |
| 470 | | READ8_MEMBER( c65_state::sid_poty_r ) |
| 471 | | { |
| 472 | | return c64_paddle_read(m_sid_r, space, 1); |
| 473 | | } |
| 474 | | |
| 475 | | |
| 476 | | /************************************* |
| 477 | | * |
| 478 | | * VIC III interfaces |
| 479 | | * |
| 480 | | *************************************/ |
| 481 | | |
| 482 | | UINT32 c65_state::screen_update_c65(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 483 | | { |
| 484 | | m_vic->video_update(bitmap, cliprect); |
| 485 | | return 0; |
| 486 | | } |
| 487 | | |
| 488 | | READ8_MEMBER(c65_state::c65_lightpen_x_cb) |
| 489 | | { |
| 490 | | return ioport("LIGHTX")->read() & ~0x01; |
| 491 | | } |
| 492 | | |
| 493 | | READ8_MEMBER(c65_state::c65_lightpen_y_cb) |
| 494 | | { |
| 495 | | return ioport("LIGHTY")->read() & ~0x01; |
| 496 | | } |
| 497 | | |
| 498 | | READ8_MEMBER(c65_state::c65_lightpen_button_cb) |
| 499 | | { |
| 500 | | return ioport("OTHER")->read() & 0x04; |
| 501 | | } |
| 502 | | |
| 503 | | READ8_MEMBER(c65_state::c65_c64_mem_r) |
| 504 | | { |
| 505 | | return m_memory[offset]; |
| 506 | | } |
| 507 | | |
| 508 | | INTERRUPT_GEN_MEMBER(c65_state::vic3_raster_irq) |
| 509 | | { |
| 510 | | m_vic->raster_interrupt_gen(); |
| 511 | | } |
| 512 | | |
| 513 | | /************************************* |
| 514 | | * |
| 515 | | * Machine driver |
| 516 | | * |
| 517 | | *************************************/ |
| 518 | | |
| 519 | | static MACHINE_CONFIG_START( c65, c65_state ) |
| 520 | | /* basic machine hardware */ |
| 521 | | MCFG_CPU_ADD("maincpu", M4510, 3500000) /* or VIC6567_CLOCK, */ |
| 522 | | MCFG_CPU_PROGRAM_MAP(c65_mem) |
| 523 | | MCFG_CPU_VBLANK_INT_DRIVER("screen", c65_state, c65_frame_interrupt) |
| 524 | | MCFG_CPU_PERIODIC_INT_DRIVER(c65_state, vic3_raster_irq, VIC6567_HRETRACERATE) |
| 525 | | |
| 526 | | MCFG_MACHINE_START_OVERRIDE(c65_state, c65 ) |
| 527 | | |
| 528 | | /* video hardware */ |
| 529 | | MCFG_SCREEN_ADD("screen", RASTER) |
| 530 | | MCFG_SCREEN_REFRESH_RATE(VIC6567_VRETRACERATE) |
| 531 | | MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) /* not accurate */ |
| 532 | | MCFG_SCREEN_SIZE(525 * 2, 520 * 2) |
| 533 | | MCFG_SCREEN_VISIBLE_AREA(VIC6567_STARTVISIBLECOLUMNS ,(VIC6567_STARTVISIBLECOLUMNS + VIC6567_VISIBLECOLUMNS - 1) * 2, VIC6567_STARTVISIBLELINES, VIC6567_STARTVISIBLELINES + VIC6567_VISIBLELINES - 1) |
| 534 | | MCFG_SCREEN_UPDATE_DRIVER(c65_state, screen_update_c65) |
| 535 | | MCFG_SCREEN_PALETTE("vic3:palette") |
| 536 | | |
| 537 | | MCFG_DEVICE_ADD("vic3", VIC3, 0) |
| 538 | | MCFG_VIC3_CPU("maincpu") |
| 539 | | MCFG_VIC3_TYPE(VIC4567_NTSC) |
| 540 | | MCFG_VIC3_LIGHTPEN_X_CB(READ8(c65_state, c65_lightpen_x_cb)) |
| 541 | | MCFG_VIC3_LIGHTPEN_Y_CB(READ8(c65_state, c65_lightpen_y_cb)) |
| 542 | | MCFG_VIC3_LIGHTPEN_BUTTON_CB(READ8(c65_state, c65_lightpen_button_cb)) |
| 543 | | MCFG_VIC3_DMA_READ_CB(READ8(c65_state, c65_dma_read)) |
| 544 | | MCFG_VIC3_DMA_READ_COLOR_CB(READ8(c65_state, c65_dma_read_color)) |
| 545 | | MCFG_VIC3_INTERRUPT_CB(WRITELINE(c65_state, c65_vic_interrupt)) |
| 546 | | MCFG_VIC3_PORT_CHANGED_CB(WRITE8(c65_state, c65_bankswitch_interface)) |
| 547 | | MCFG_VIC3_C64_MEM_R_CB(READ8(c65_state, c65_c64_mem_r)) |
| 548 | | |
| 549 | | /* sound hardware */ |
| 550 | | MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker") |
| 551 | | MCFG_SOUND_ADD("sid_r", MOS8580, 985248) |
| 552 | | MCFG_MOS6581_POTX_CALLBACK(READ8(c65_state, sid_potx_r)) |
| 553 | | MCFG_MOS6581_POTY_CALLBACK(READ8(c65_state, sid_poty_r)) |
| 554 | | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.50) |
| 555 | | MCFG_SOUND_ADD("sid_l", MOS8580, 985248) |
| 556 | | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.50) |
| 557 | | |
| 558 | | /* quickload */ |
| 559 | | MCFG_QUICKLOAD_ADD("quickload", c65_state, cbm_c65, "p00,prg", CBM_QUICKLOAD_DELAY_SECONDS) |
| 560 | | |
| 561 | | /* cia */ |
| 562 | | MCFG_DEVICE_ADD("cia_0", MOS6526, 3500000) |
| 563 | | MCFG_MOS6526_TOD(60) |
| 564 | | MCFG_MOS6526_IRQ_CALLBACK(WRITELINE(c65_state, c65_cia0_interrupt)) |
| 565 | | MCFG_MOS6526_PA_INPUT_CALLBACK(READ8(c65_state, c65_cia0_port_a_r)) |
| 566 | | MCFG_MOS6526_PB_INPUT_CALLBACK(READ8(c65_state, c65_cia0_port_b_r)) |
| 567 | | MCFG_MOS6526_PB_OUTPUT_CALLBACK(WRITE8(c65_state, c65_cia0_port_b_w)) |
| 568 | | |
| 569 | | MCFG_DEVICE_ADD("cia_1", MOS6526, 3500000) |
| 570 | | MCFG_MOS6526_TOD(60) |
| 571 | | MCFG_MOS6526_IRQ_CALLBACK(WRITELINE(c65_state, c65_cia1_interrupt)) |
| 572 | | MCFG_MOS6526_PA_INPUT_CALLBACK(READ8(c65_state, c65_cia1_port_a_r)) |
| 573 | | MCFG_MOS6526_PA_OUTPUT_CALLBACK(WRITE8(c65_state, c65_cia1_port_a_w)) |
| 574 | | |
| 575 | | /* floppy from serial bus */ |
| 576 | | MCFG_CBM_IEC_ADD(NULL) |
| 577 | | |
| 578 | | /* internal ram */ |
| 579 | | MCFG_RAM_ADD(RAM_TAG) |
| 580 | | MCFG_RAM_DEFAULT_SIZE("128K") |
| 581 | | MCFG_RAM_EXTRA_OPTIONS("640K,4224K") |
| 582 | | MACHINE_CONFIG_END |
| 583 | | |
| 584 | | static MACHINE_CONFIG_DERIVED( c65pal, c65 ) |
| 585 | | MCFG_SCREEN_MODIFY("screen") |
| 586 | | MCFG_SCREEN_REFRESH_RATE(VIC6569_VRETRACERATE) |
| 587 | | MCFG_SCREEN_SIZE(625 * 2, 520 * 2) |
| 588 | | MCFG_SCREEN_VISIBLE_AREA(VIC6569_STARTVISIBLECOLUMNS, (VIC6569_STARTVISIBLECOLUMNS + VIC6569_VISIBLECOLUMNS - 1) * 2, VIC6569_STARTVISIBLELINES, VIC6569_STARTVISIBLELINES + VIC6569_VISIBLELINES - 1) |
| 589 | | MCFG_SCREEN_PALETTE("vic3:palette") |
| 590 | | |
| 591 | | MCFG_DEVICE_MODIFY("vic3") |
| 592 | | MCFG_VIC3_TYPE(VIC4567_PAL) |
| 593 | | |
| 594 | | /* sound hardware */ |
| 595 | | MCFG_SOUND_REPLACE("sid_r", MOS8580, 1022727) |
| 596 | | MCFG_MOS6581_POTX_CALLBACK(READ8(c65_state, sid_potx_r)) |
| 597 | | MCFG_MOS6581_POTY_CALLBACK(READ8(c65_state, sid_poty_r)) |
| 598 | | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.50) |
| 599 | | MCFG_SOUND_REPLACE("sid_l", MOS8580, 1022727) |
| 600 | | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.50) |
| 601 | | |
| 602 | | /* cia */ |
| 603 | | MCFG_DEVICE_MODIFY("cia_0") |
| 604 | | MCFG_MOS6526_TOD(50) |
| 605 | | |
| 606 | | MCFG_DEVICE_MODIFY("cia_1") |
| 607 | | MCFG_MOS6526_TOD(50) |
| 608 | | MACHINE_CONFIG_END |
| 609 | | |
| 610 | | |
| 611 | | /************************************* |
| 612 | | * |
| 613 | | * ROM definition(s) |
| 614 | | * |
| 615 | | *************************************/ |
| 616 | | |
| 617 | | |
| 618 | | ROM_START( c65 ) |
| 619 | | ROM_REGION( 0x400000, "maincpu", 0 ) |
| 620 | | ROM_SYSTEM_BIOS( 0, "910111", "V0.9.910111" ) |
| 621 | | ROMX_LOAD( "910111.bin", 0x20000, 0x20000, CRC(c5d8d32e) SHA1(71c05f098eff29d306b0170e2c1cdeadb1a5f206), ROM_BIOS(1) ) |
| 622 | | ROM_SYSTEM_BIOS( 1, "910523", "V0.9.910523" ) |
| 623 | | ROMX_LOAD( "910523.bin", 0x20000, 0x20000, CRC(e8235dd4) SHA1(e453a8e7e5b95de65a70952e9d48012191e1b3e7), ROM_BIOS(2) ) |
| 624 | | ROM_SYSTEM_BIOS( 2, "910626", "V0.9.910626" ) |
| 625 | | ROMX_LOAD( "910626.bin", 0x20000, 0x20000, CRC(12527742) SHA1(07c185b3bc58410183422f7ac13a37ddd330881b), ROM_BIOS(3) ) |
| 626 | | ROM_SYSTEM_BIOS( 3, "910828", "V0.9.910828" ) |
| 627 | | ROMX_LOAD( "910828.bin", 0x20000, 0x20000, CRC(3ee40b06) SHA1(b63d970727a2b8da72a0a8e234f3c30a20cbcb26), ROM_BIOS(4) ) |
| 628 | | ROM_SYSTEM_BIOS( 4, "911001", "V0.9.911001" ) |
| 629 | | ROMX_LOAD( "911001.bin", 0x20000, 0x20000, CRC(0888b50f) SHA1(129b9a2611edaebaa028ac3e3f444927c8b1fc5d), ROM_BIOS(5) ) |
| 630 | | ROM_END |
| 631 | | |
| 632 | | ROM_START( c64dx ) |
| 633 | | ROM_REGION( 0x400000, "maincpu", 0 ) |
| 634 | | ROM_LOAD( "910429.bin", 0x20000, 0x20000, CRC(b025805c) SHA1(c3b05665684f74adbe33052a2d10170a1063ee7d) ) |
| 635 | | ROM_END |
| 636 | | |
| 637 | | /*************************************************************************** |
| 638 | | |
| 639 | | Game driver(s) |
| 640 | | |
| 641 | | ***************************************************************************/ |
| 642 | | |
| 643 | | /* YEAR NAME PARENT COMPAT MACHINE INPUT INIT COMPANY FULLNAME FLAGS */ |
| 644 | | |
| 645 | | COMP( 1991, c65, 0, 0, c65, c65, c65_state, c65, "Commodore Business Machines", "Commodore 65 Development System (Prototype, NTSC)", GAME_NOT_WORKING ) |
| 646 | | COMP( 1991, c64dx, c65, 0, c65pal, c65ger, c65_state, c65pal, "Commodore Business Machines", "Commodore 64DX Development System (Prototype, PAL, German)", GAME_NOT_WORKING ) |
| 647 | | |
| 648 | | |
trunk/src/mess/drivers/gamate.c
| r243230 | r243231 | |
| 20 | 20 | : driver_device(mconfig, type, tag) |
| 21 | 21 | , m_maincpu(*this, "maincpu") |
| 22 | 22 | , m_cart(*this, "cartslot") |
| 23 | | #ifdef USE_GFX |
| 23 | #ifdef USE_GFX |
| 24 | 24 | , m_gfxdecode(*this, "gfxdecode") |
| 25 | 25 | #endif |
| 26 | 26 | , m_io_joy(*this, "JOY") |
| r243230 | r243231 | |
| 53 | 53 | |
| 54 | 54 | struct |
| 55 | 55 | { |
| 56 | | UINT8 reg[8]; |
| 57 | | struct { |
| 58 | | bool write; |
| 59 | | bool page2; // else page1 |
| 56 | UINT8 reg[8]; |
| 57 | struct { |
| 58 | bool write; |
| 59 | bool page2; // else page1 |
| 60 | 60 | UINT8 ypos, xpos/*tennis*/; |
| 61 | | UINT8 data[2][0x100][0x20]; |
| 62 | | } bitmap; |
| 63 | | UINT8 x, y; |
| 61 | UINT8 data[2][0x100][0x20]; |
| 62 | } bitmap; |
| 63 | UINT8 x, y; |
| 64 | 64 | bool y_increment; |
| 65 | 65 | } video; |
| 66 | 66 | |
| 67 | 67 | struct { |
| 68 | | bool set; |
| 68 | bool set; |
| 69 | 69 | int bit_shifter; |
| 70 | 70 | UINT8 cartridge_byte; |
| 71 | 71 | UINT16 address; // in reality something more like short local cartridge address offset |
| 72 | 72 | bool unprotected; |
| 73 | 73 | bool failed; |
| 74 | | |
| 74 | |
| 75 | 75 | } card_protection; |
| 76 | 76 | |
| 77 | 77 | required_device<cpu_device> m_maincpu; |
| r243230 | r243231 | |
| 84 | 84 | required_shared_ptr<UINT8> m_bios; |
| 85 | 85 | emu_timer *timer1; |
| 86 | 86 | emu_timer *timer2; |
| 87 | | UINT8 bank_multi; |
| 87 | UINT8 bank_multi; |
| 88 | 88 | UINT8 *m_cart_ptr; |
| 89 | 89 | }; |
| 90 | 90 | |
| 91 | 91 | WRITE8_MEMBER( gamate_state::gamate_cart_protection_w ) |
| 92 | 92 | { |
| 93 | | logerror("%.6f protection write %x %x address:%x data:%x shift:%d\n",machine().time().as_double(), offset, data, card_protection.address, card_protection.cartridge_byte, card_protection.bit_shifter); |
| 94 | | |
| 93 | logerror("%.6f protection write %x %x address:%x data:%x shift:%d\n",machine().time().as_double(), offset, data, card_protection.address, card_protection.cartridge_byte, card_protection.bit_shifter); |
| 94 | |
| 95 | 95 | switch (offset) { |
| 96 | 96 | case 0: |
| 97 | 97 | card_protection.failed= card_protection.failed || ((card_protection.cartridge_byte&0x80)!=0) != ((data&4)!=0); |
| r243230 | r243231 | |
| 105 | 105 | } |
| 106 | 106 | READ8_MEMBER( gamate_state::gamate_cart_protection_r ) |
| 107 | 107 | { |
| 108 | | UINT8 ret=1; |
| 109 | | if (card_protection.bit_shifter==7 && card_protection.unprotected) { |
| 110 | | ret=m_cart_ptr[bank_multi*0x4000]; |
| 111 | | } else { |
| 108 | |
| 109 | UINT8 ret=1; |
| 110 | if (card_protection.bit_shifter==7 && card_protection.unprotected) { |
| 111 | ret=m_cart_ptr[bank_multi*0x4000]; |
| 112 | } else { |
| 112 | 113 | card_protection.bit_shifter++; |
| 113 | 114 | if (card_protection.bit_shifter==8) { |
| 114 | 115 | card_protection.bit_shifter=0; |
| r243230 | r243231 | |
| 117 | 118 | } |
| 118 | 119 | ret=(card_protection.cartridge_byte&0x80)?2:0; |
| 119 | 120 | if (card_protection.bit_shifter==7 && !card_protection.failed) { // now protection chip on cartridge activates cartridge chip select on cpu accesses |
| 120 | | // m_maincpu->space(AS_PROGRAM).install_read_handler(0x6000, 0x6000, READ8_DELEGATE(gamate_state, gamate_cart_protection_r)); // next time I will try to get this working |
| 121 | // m_maincpu->space(AS_PROGRAM).install_read_handler(0x6000, 0x6000, READ8_DELEGATE(gamate_state, gamate_cart_protection_r)); // next time I will try to get this working |
| 121 | 122 | } |
| 122 | 123 | card_protection.cartridge_byte<<=1; |
| 123 | | } |
| 124 | | logerror("%.6f protection read %x %x address:%x data:%x shift:%d\n",machine().time().as_double(), offset, ret, card_protection.address, card_protection.cartridge_byte, card_protection.bit_shifter); |
| 125 | | return ret; |
| 124 | } |
| 125 | logerror("%.6f protection read %x %x address:%x data:%x shift:%d\n",machine().time().as_double(), offset, ret, card_protection.address, card_protection.cartridge_byte, card_protection.bit_shifter); |
| 126 | return ret; |
| 126 | 127 | } |
| 127 | 128 | |
| 128 | 129 | READ8_MEMBER( gamate_state::protection_r ) { return card_protection.set? 3: 1; } // bits 0 and 1 checked |
| 129 | 130 | |
| 130 | 131 | WRITE8_MEMBER( gamate_state::protection_reset ) |
| 131 | 132 | { |
| 132 | | // writes 0x20 |
| 133 | | card_protection.address=0x6005-0x6001; |
| 134 | | card_protection.bit_shifter=0; |
| 135 | | card_protection.cartridge_byte=m_cart_ptr[card_protection.address++];//m_cart_rom[card_protection.address++]; |
| 136 | | card_protection.failed=false; |
| 137 | | card_protection.unprotected=false; |
| 133 | // writes 0x20 |
| 134 | card_protection.address=0x6005-0x6001; |
| 135 | card_protection.bit_shifter=0; |
| 136 | card_protection.cartridge_byte=m_cart_ptr[card_protection.address++];//m_cart_rom[card_protection.address++]; |
| 137 | card_protection.failed=false; |
| 138 | card_protection.unprotected=false; |
| 138 | 139 | } |
| 139 | 140 | |
| 140 | 141 | READ8_MEMBER( gamate_state::newer_protection_set ) |
| 141 | 142 | { |
| 142 | | card_protection.set=true; |
| 143 | | return 0; |
| 143 | card_protection.set=true; |
| 144 | return 0; |
| 144 | 145 | } |
| 145 | 146 | |
| 146 | 147 | |
| 147 | 148 | WRITE8_MEMBER( gamate_state::gamate_video_w ) |
| 148 | 149 | { |
| 149 | | video.reg[offset]=data; |
| 150 | | switch (offset) { |
| 151 | | case 1: video.bitmap.write=data&0xc0; // more addressing mode |
| 150 | video.reg[offset]=data; |
| 151 | switch (offset) { |
| 152 | case 1: video.bitmap.write=data&0xc0; // more addressing mode |
| 152 | 153 | video.y_increment=data&0x40; |
| 153 | 154 | break; |
| 154 | 155 | case 2: video.bitmap.xpos=data;break; // at least 7 bits |
| 155 | 156 | case 3: video.bitmap.ypos=data;break; // at least 7 bits |
| 156 | | case 4: video.bitmap.page2=data&0x80;video.x=data&0x7f;break; |
| 157 | | case 5: video.y=data;break; |
| 158 | | case 7: |
| 159 | | if (video.bitmap.write) { |
| 160 | | if (video.x<ARRAY_LENGTH(video.bitmap.data[0][0]) /*&& video.y<ARRAY_LENGTH(video.bitmap.data[0])*/) |
| 161 | | video.bitmap.data[video.bitmap.page2][video.y][video.x]=data; |
| 162 | | else |
| 163 | | logerror("%.6f %04x video bitmap x %x invalid\n",machine().time().as_double(), m_maincpu->pc(), video.x); |
| 164 | | } else { |
| 165 | | video.bitmap.data[0][video.y][video.x&(ARRAY_LENGTH(video.bitmap.data[0][0])-1)]=data; |
| 166 | | } |
| 167 | | if (video.y_increment) video.y++; |
| 157 | case 4: video.bitmap.page2=data&0x80;video.x=data&0x7f;break; |
| 158 | case 5: video.y=data;break; |
| 159 | case 7: |
| 160 | if (video.bitmap.write) { |
| 161 | if (video.x<ARRAY_LENGTH(video.bitmap.data[0][0]) /*&& video.y<ARRAY_LENGTH(video.bitmap.data[0])*/) |
| 162 | video.bitmap.data[video.bitmap.page2][video.y][video.x]=data; |
| 163 | else |
| 164 | logerror("%.6f %04x video bitmap x %x invalid\n",machine().time().as_double(), m_maincpu->pc(), video.x); |
| 165 | } else { |
| 166 | video.bitmap.data[0][video.y][video.x&(ARRAY_LENGTH(video.bitmap.data[0][0])-1)]=data; |
| 167 | } |
| 168 | if (video.y_increment) video.y++; |
| 168 | 169 | else video.x++; |
| 169 | | } |
| 170 | } |
| 170 | 171 | } |
| 171 | 172 | |
| 172 | 173 | WRITE8_MEMBER( gamate_state::cart_bankswitchmulti_w ) |
| 173 | 174 | { |
| 174 | | bank_multi=data; |
| 175 | | membank("bankmulti")->set_base(m_cart_ptr+0x4000*data+1); |
| 175 | bank_multi=data; |
| 176 | membank("bankmulti")->set_base(m_cart_ptr+0x4000*data+1); |
| 176 | 177 | } |
| 177 | 178 | |
| 178 | 179 | WRITE8_MEMBER( gamate_state::cart_bankswitch_w ) |
| r243230 | r243231 | |
| 183 | 184 | READ8_MEMBER( gamate_state::gamate_video_r ) |
| 184 | 185 | { |
| 185 | 186 | if (offset!=6) return 0; |
| 186 | | UINT8 data=0; |
| 187 | | if (video.bitmap.write) { |
| 188 | | if (video.x<ARRAY_LENGTH(video.bitmap.data[0][0]) /*&& video.y<ARRAY_LENGTH(video.bitmap.data[0])*/) |
| 189 | | data=video.bitmap.data[video.bitmap.page2][video.y][video.x]; |
| 190 | | else |
| 191 | | logerror("%.6f video bitmap x %x invalid\n",machine().time().as_double(),video.x); |
| 192 | | } else { |
| 193 | | data=video.bitmap.data[0][video.y][video.x&(ARRAY_LENGTH(video.bitmap.data[0][0])-1)]; |
| 194 | | } |
| 195 | | if (m_maincpu->pc()<0xf000) |
| 196 | | logerror("%.6f video read %04x %02x\n",machine().time().as_double(),offset, data); |
| 197 | | return data; |
| 187 | UINT8 data=0; |
| 188 | if (video.bitmap.write) { |
| 189 | if (video.x<ARRAY_LENGTH(video.bitmap.data[0][0]) /*&& video.y<ARRAY_LENGTH(video.bitmap.data[0])*/) |
| 190 | data=video.bitmap.data[video.bitmap.page2][video.y][video.x]; |
| 191 | else |
| 192 | logerror("%.6f video bitmap x %x invalid\n",machine().time().as_double(),video.x); |
| 193 | } else { |
| 194 | data=video.bitmap.data[0][video.y][video.x&(ARRAY_LENGTH(video.bitmap.data[0][0])-1)]; |
| 195 | } |
| 196 | if (m_maincpu->pc()<0xf000) |
| 197 | logerror("%.6f video read %04x %02x\n",machine().time().as_double(),offset, data); |
| 198 | return data; |
| 198 | 199 | } |
| 199 | 200 | |
| 200 | 201 | WRITE8_MEMBER( gamate_state::gamate_audio_w ) |
| 201 | 202 | { |
| 202 | | logerror("%.6f %04x audio write %04x %02x\n",machine().time().as_double(),m_maincpu->pc(),offset,data); |
| 203 | logerror("%.6f %04x audio write %04x %02x\n",machine().time().as_double(),m_maincpu->pc(),offset,data); |
| 203 | 204 | } |
| 204 | 205 | |
| 205 | 206 | READ8_MEMBER( gamate_state::gamate_audio_r ) |
| 206 | 207 | { |
| 207 | | logerror("%.6f %04x audio read %04x \n",machine().time().as_double(),m_maincpu->pc(),offset); |
| 208 | logerror("%.6f %04x audio read %04x \n",machine().time().as_double(),m_maincpu->pc(),offset); |
| 208 | 209 | return 0; |
| 209 | 210 | } |
| 210 | 211 | |
| 211 | 212 | |
| 212 | 213 | READ8_MEMBER( gamate_state::gamate_pad_r ) |
| 213 | 214 | { |
| 214 | | UINT8 data=m_io_joy->read(); |
| 215 | | return data; |
| 215 | UINT8 data=m_io_joy->read(); |
| 216 | return data; |
| 216 | 217 | } |
| 217 | 218 | |
| 218 | 219 | static ADDRESS_MAP_START( gamate_mem, AS_PROGRAM, 8, gamate_state ) |
| 219 | | AM_RANGE(0x0000, 0x03ff) AM_RAM |
| 220 | | AM_RANGE(0x4000, 0x400d) AM_READWRITE(gamate_audio_r, gamate_audio_w) |
| 221 | | AM_RANGE(0x4400, 0x4400) AM_READ(gamate_pad_r) |
| 222 | | AM_RANGE(0x5000, 0x5007) AM_READWRITE(gamate_video_r, gamate_video_w) |
| 223 | | AM_RANGE(0x5800, 0x5800) AM_READ(newer_protection_set) |
| 224 | | AM_RANGE(0x5900, 0x5900) AM_WRITE(protection_reset) |
| 225 | | AM_RANGE(0x5a00, 0x5a00) AM_READ(protection_r) |
| 220 | AM_RANGE(0x0000, 0x03ff) AM_RAM |
| 221 | AM_RANGE(0x4000, 0x400d) AM_READWRITE(gamate_audio_r, gamate_audio_w) |
| 222 | AM_RANGE(0x4400, 0x4400) AM_READ(gamate_pad_r) |
| 223 | AM_RANGE(0x5000, 0x5007) AM_READWRITE(gamate_video_r, gamate_video_w) |
| 224 | AM_RANGE(0x5800, 0x5800) AM_READ(newer_protection_set) |
| 225 | AM_RANGE(0x5900, 0x5900) AM_WRITE(protection_reset) |
| 226 | AM_RANGE(0x5a00, 0x5a00) AM_READ(protection_r) |
| 226 | 227 | |
| 227 | | AM_RANGE(0x6001, 0x9fff) AM_READ_BANK("bankmulti") |
| 228 | | AM_RANGE(0xa000, 0xdfff) AM_READ_BANK("bank") |
| 228 | AM_RANGE(0x6001, 0x9fff) AM_READ_BANK("bankmulti") |
| 229 | AM_RANGE(0xa000, 0xdfff) AM_READ_BANK("bank") |
| 229 | 230 | |
| 230 | 231 | AM_RANGE(0x6000, 0x6000) AM_READWRITE(gamate_cart_protection_r, gamate_cart_protection_w) |
| 231 | 232 | AM_RANGE(0x8000, 0x8000) AM_WRITE(cart_bankswitchmulti_w) |
| 232 | 233 | AM_RANGE(0xc000, 0xc000) AM_WRITE(cart_bankswitch_w) |
| 233 | 234 | |
| 234 | | AM_RANGE(0xf000, 0xffff) AM_ROM AM_SHARE("bios") |
| 235 | AM_RANGE(0xf000, 0xffff) AM_ROM AM_SHARE("bios") |
| 235 | 236 | ADDRESS_MAP_END |
| 236 | 237 | |
| 237 | 238 | |
| r243230 | r243231 | |
| 250 | 251 | #ifdef USE_GFX |
| 251 | 252 | static const struct gfx_layout gamate_charlayout = |
| 252 | 253 | { |
| 253 | | 4, /* width of object */ |
| 254 | | 1, /* height of object */ |
| 255 | | 256,/* 256 characters */ |
| 256 | | 2, /* bits per pixel */ |
| 257 | | { 0,4 }, /* no bitplanes */ |
| 258 | | /* x offsets */ |
| 259 | | { 0,1,2,3 }, |
| 260 | | /* y offsets */ |
| 261 | | { 0 }, |
| 262 | | 8*1 /* size of 1 object in bits */ |
| 254 | 4, /* width of object */ |
| 255 | 1, /* height of object */ |
| 256 | 256,/* 256 characters */ |
| 257 | 2, /* bits per pixel */ |
| 258 | { 0,4 }, /* no bitplanes */ |
| 259 | /* x offsets */ |
| 260 | { 0,1,2,3 }, |
| 261 | /* y offsets */ |
| 262 | { 0 }, |
| 263 | 8*1 /* size of 1 object in bits */ |
| 263 | 264 | }; |
| 264 | 265 | |
| 265 | 266 | static GFXDECODE_START( gamate ) |
| 266 | | GFXDECODE_ENTRY( "gfx1", 0x0000, gamate_charlayout, 0, 0x100 ) |
| 267 | GFXDECODE_ENTRY( "gfx1", 0x0000, gamate_charlayout, 0, 0x100 ) |
| 267 | 268 | GFXDECODE_END |
| 268 | 269 | #endif |
| 269 | 270 | |
| 270 | 271 | /* palette in red, green, blue tribles */ |
| 271 | 272 | static const unsigned char gamate_colors[4][3] = |
| 272 | 273 | { |
| 273 | | { 255,255,255 }, |
| 274 | | { 0xa0, 0xa0, 0xa0 }, |
| 275 | | { 0x60, 0x60, 0x60 }, |
| 276 | | { 0, 0, 0 } |
| 274 | { 255,255,255 }, |
| 275 | { 0xa0, 0xa0, 0xa0 }, |
| 276 | { 0x60, 0x60, 0x60 }, |
| 277 | { 0, 0, 0 } |
| 277 | 278 | }; |
| 278 | 279 | |
| 279 | 280 | PALETTE_INIT_MEMBER(gamate_state, gamate) |
| r243230 | r243231 | |
| 298 | 299 | |
| 299 | 300 | UINT32 gamate_state::screen_update_gamate(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 300 | 301 | { |
| 301 | | int x, y, j; |
| 302 | | for (y=0;y<152;y++) { |
| 303 | | for (x=-(video.bitmap.xpos&7), j=0;x<160;x+=8, j++) { |
| 304 | | UINT8 d1=video.bitmap.data[0][(y+video.bitmap.ypos)&0xff][(j+video.bitmap.xpos/8)&0x1f]; |
| 305 | | UINT8 d2=video.bitmap.data[1][(y+video.bitmap.ypos)&0xff][(j+video.bitmap.xpos/8)&0x1f]; |
| 302 | int x, y, j; |
| 303 | for (y=0;y<152;y++) { |
| 304 | for (x=-(video.bitmap.xpos&7), j=0;x<160;x+=8, j++) { |
| 305 | UINT8 d1=video.bitmap.data[0][(y+video.bitmap.ypos)&0xff][(j+video.bitmap.xpos/8)&0x1f]; |
| 306 | UINT8 d2=video.bitmap.data[1][(y+video.bitmap.ypos)&0xff][(j+video.bitmap.xpos/8)&0x1f]; |
| 306 | 307 | #ifdef USE_GFX |
| 307 | | m_gfxdecode->gfx(0)->opaque(bitmap,cliprect, (d1&0xf)|((d2&0xf)<<4), 0,0,0,x+4,y); |
| 308 | m_gfxdecode->gfx(0)->opaque(bitmap,cliprect, (d1&0xf)|((d2&0xf)<<4), 0,0,0,x+4,y); |
| 308 | 309 | m_gfxdecode->gfx(0)->opaque(bitmap,cliprect, (d1>>4)|(d2&0xf0),0,0,0,x,y); |
| 309 | 310 | #else |
| 310 | | BlitPlane(&bitmap.pix16(y, x+4), d1, d2); |
| 311 | | BlitPlane(&bitmap.pix16(y, x), d1>>4, d2>>4); |
| 312 | | #endif |
| 313 | | } |
| 314 | | } |
| 315 | | return 0; |
| 311 | BlitPlane(&bitmap.pix16(y, x+4), d1, d2); |
| 312 | BlitPlane(&bitmap.pix16(y, x), d1>>4, d2>>4); |
| 313 | #endif |
| 314 | } |
| 315 | } |
| 316 | return 0; |
| 316 | 317 | } |
| 317 | 318 | |
| 318 | 319 | DRIVER_INIT_MEMBER(gamate_state,gamate) |
| r243230 | r243231 | |
| 321 | 322 | #ifdef USE_GFX |
| 322 | 323 | UINT8 *gfx=memregion("gfx1")->base(); |
| 323 | 324 | for (int i=0; i<256; i++) gfx[i]=i; |
| 324 | | #endif |
| 325 | #endif |
| 325 | 326 | timer1 = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(gamate_state::gamate_timer),this)); |
| 326 | 327 | timer2 = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(gamate_state::gamate_timer2),this)); |
| 327 | 328 | } |
| r243230 | r243231 | |
| 331 | 332 | { |
| 332 | 333 | m_cart_ptr = memregion("maincpu")->base() + 0x6000; |
| 333 | 334 | if (m_cart->exists()) { |
| 334 | | // m_maincpu->space(AS_PROGRAM).install_read_handler(0x6000, 0x6000, READ8_DELEGATE(gamate_state, gamate_cart_protection_r)); |
| 335 | // m_maincpu->space(AS_PROGRAM).install_read_handler(0x6000, 0x6000, READ8_DELEGATE(gamate_state, gamate_cart_protection_r)); |
| 335 | 336 | m_cart_ptr = m_cart->get_rom_base(); |
| 336 | 337 | membank("bankmulti")->set_base(m_cart->get_rom_base()+1); |
| 337 | 338 | membank("bank")->set_base(m_cart->get_rom_base()+0x4000); // bankswitched games in reality no offset |
| 338 | 339 | } |
| 339 | | // m_bios[0xdf1]=0xea; m_bios[0xdf2]=0xea; // default bios: $47 protection readback |
| 340 | // m_bios[0xdf1]=0xea; m_bios[0xdf2]=0xea; // default bios: $47 protection readback |
| 340 | 341 | card_protection.set=false; |
| 341 | 342 | bank_multi=0; |
| 342 | 343 | card_protection.unprotected=false; |
| r243230 | r243231 | |
| 389 | 390 | |
| 390 | 391 | #ifdef USE_GFX |
| 391 | 392 | MCFG_GFXDECODE_ADD("gfxdecode", "palette", gamate ) |
| 392 | | #endif |
| 393 | #endif |
| 393 | 394 | MCFG_PALETTE_ADD("palette", ARRAY_LENGTH(gamate_colors)) |
| 394 | 395 | MCFG_PALETTE_INIT_OWNER(gamate_state, gamate) |
| 395 | 396 | MCFG_DEFAULT_LAYOUT(layout_lcd) |
| r243230 | r243231 | |
| 407 | 408 | ROMX_LOAD("gamate_bios_umc.bin", 0xf000, 0x1000, CRC(07090415) SHA1(ea449dc607601f9a68d855ad6ab53800d2e99297), ROM_BIOS(1) ) |
| 408 | 409 | ROM_SYSTEM_BIOS(1, "newer", "NEWER") |
| 409 | 410 | ROMX_LOAD("gamate_bios_9130__unknown__bit_icasc00001_9130-bs_r32261.bin", 0xf000, 0x1000, CRC(03a5f3a7) SHA1(4e9dfbfe916ca485530ef4221593ab68738e2217), ROM_BIOS(2) ) |
| 410 | | #ifdef USE_GFX |
| 411 | #ifdef USE_GFX |
| 411 | 412 | ROM_REGION(0x100,"gfx1", ROMREGION_ERASEFF) |
| 412 | | #endif |
| 413 | #endif |
| 413 | 414 | ROM_END |
| 414 | 415 | |
| 415 | 416 | |
| 416 | 417 | /* YEAR NAME PARENT COMPAT MACHINE INPUT CLASS INIT COMPANY FULLNAME */ |
| 417 | 418 | CONS( 19??, gamate, 0, 0, gamate, gamate, gamate_state, gamate, "Bit Corp", "Gamate", GAME_NO_SOUND) |
| 419 | |
| 420 | |
trunk/src/mess/drivers/hp9k_3xx.c
| r243230 | r243231 | |
| 1 | 1 | // license:BSD-3-Clause |
| 2 | 2 | // copyright-holders:R. Belmont |
| 3 | 3 | /*************************************************************************** |
| 4 | | |
| 4 | |
| 5 | 5 | hp9k3xx.c: preliminary driver for HP9000 300 Series (aka HP9000/3xx) |
| 6 | 6 | |
| 7 | 7 | Currently supporting: |
| r243230 | r243231 | |
| 16 | 16 | MC68881 FPU |
| 17 | 17 | |
| 18 | 18 | 330: |
| 19 | | MC68020 CPU @ 16.67 MHz |
| 20 | | MC68851 MMU |
| 21 | | MC68881 FPU |
| 19 | MC68020 CPU @ 16.67 MHz |
| 20 | MC68851 MMU |
| 21 | MC68881 FPU |
| 22 | 22 | |
| 23 | 23 | 340: |
| 24 | 24 | MC68030 CPU @ 16.67 MHz w/built-in MMU |
| 25 | | MC68881 FPU |
| 25 | MC68881 FPU |
| 26 | 26 | |
| 27 | 27 | 380: |
| 28 | 28 | MC68040 CPU @ 25 MHz w/built-in MMU and FPU |
| 29 | 29 | |
| 30 | 30 | 382: |
| 31 | 31 | MC68040 CPU @ 25? MHz w/built-in MMU and FPU |
| 32 | | Built-in VGA compatible video |
| 32 | Built-in VGA compatible video |
| 33 | 33 | |
| 34 | 34 | All models have an MC6840 PIT on IRQ6 clocked at 250 kHz. |
| 35 | 35 | |
| r243230 | r243231 | |
| 132 | 132 | |
| 133 | 133 | // shared mappings for all 9000/3xx systems |
| 134 | 134 | static ADDRESS_MAP_START(hp9k3xx_common, AS_PROGRAM, 32, hp9k3xx_state) |
| 135 | | AM_RANGE(0x00000000, 0x0001ffff) AM_ROM AM_REGION("maincpu",0) AM_WRITENOP // writes to 1fffc are the LED |
| 135 | AM_RANGE(0x00000000, 0x0001ffff) AM_ROM AM_REGION("maincpu",0) AM_WRITENOP // writes to 1fffc are the LED |
| 136 | 136 | |
| 137 | | AM_RANGE(0x00500000, 0x0050000f) AM_RAM // this is sufficient to pass the DMA test for now |
| 137 | AM_RANGE(0x00500000, 0x0050000f) AM_RAM // this is sufficient to pass the DMA test for now |
| 138 | 138 | |
| 139 | | AM_RANGE(0x00510000, 0x00510003) AM_READWRITE(buserror_r, buserror_w) // no "Alpha display" |
| 140 | | AM_RANGE(0x00538000, 0x00538003) AM_READWRITE(buserror_r, buserror_w) // no "Graphics" |
| 141 | | AM_RANGE(0x005c0000, 0x005c0003) AM_READWRITE(buserror_r, buserror_w) // no add-on FP coprocessor |
| 139 | AM_RANGE(0x00510000, 0x00510003) AM_READWRITE(buserror_r, buserror_w) // no "Alpha display" |
| 140 | AM_RANGE(0x00538000, 0x00538003) AM_READWRITE(buserror_r, buserror_w) // no "Graphics" |
| 141 | AM_RANGE(0x005c0000, 0x005c0003) AM_READWRITE(buserror_r, buserror_w) // no add-on FP coprocessor |
| 142 | 142 | AM_RANGE(0x005f8000, 0x005f800f) AM_DEVREADWRITE8(PTM6840_TAG, ptm6840_device, read, write, 0x00ff00ff) |
| 143 | 143 | ADDRESS_MAP_END |
| 144 | 144 | |
| 145 | 145 | // 9000/310 - has onboard video that the graphics card used in other 3xxes conflicts with |
| 146 | 146 | static ADDRESS_MAP_START(hp9k310_map, AS_PROGRAM, 16, hp9k3xx_state) |
| 147 | | AM_RANGE(0x000000, 0x01ffff) AM_ROM AM_REGION("maincpu",0) AM_WRITENOP // writes to 1fffc are the LED |
| 147 | AM_RANGE(0x000000, 0x01ffff) AM_ROM AM_REGION("maincpu",0) AM_WRITENOP // writes to 1fffc are the LED |
| 148 | 148 | |
| 149 | | AM_RANGE(0x510000, 0x510003) AM_READWRITE(buserror16_r, buserror16_w) // no "Alpha display" |
| 150 | | AM_RANGE(0x538000, 0x538003) AM_READWRITE(buserror16_r, buserror16_w) // no "Graphics" |
| 151 | | AM_RANGE(0x5c0000, 0x5c0003) AM_READWRITE(buserror16_r, buserror16_w) // no add-on FP coprocessor |
| 149 | AM_RANGE(0x510000, 0x510003) AM_READWRITE(buserror16_r, buserror16_w) // no "Alpha display" |
| 150 | AM_RANGE(0x538000, 0x538003) AM_READWRITE(buserror16_r, buserror16_w) // no "Graphics" |
| 151 | AM_RANGE(0x5c0000, 0x5c0003) AM_READWRITE(buserror16_r, buserror16_w) // no add-on FP coprocessor |
| 152 | 152 | |
| 153 | 153 | AM_RANGE(0x5f8000, 0x5f800f) AM_DEVREADWRITE8(PTM6840_TAG, ptm6840_device, read, write, 0x00ff) |
| 154 | 154 | |
| 155 | | AM_RANGE(0x200000, 0x2fffff) AM_RAM AM_SHARE("vram16") // 98544 mono framebuffer |
| 156 | | AM_RANGE(0x560000, 0x563fff) AM_ROM AM_REGION("graphics", 0x0000) // 98544 mono ROM |
| 155 | AM_RANGE(0x200000, 0x2fffff) AM_RAM AM_SHARE("vram16") // 98544 mono framebuffer |
| 156 | AM_RANGE(0x560000, 0x563fff) AM_ROM AM_REGION("graphics", 0x0000) // 98544 mono ROM |
| 157 | 157 | |
| 158 | 158 | AM_RANGE(0x700000, 0x7fffff) AM_READWRITE(buserror16_r, buserror16_w) |
| 159 | 159 | AM_RANGE(0x800000, 0xffffff) AM_RAM |
| r243230 | r243231 | |
| 161 | 161 | |
| 162 | 162 | // 9000/320 |
| 163 | 163 | static ADDRESS_MAP_START(hp9k320_map, AS_PROGRAM, 32, hp9k3xx_state) |
| 164 | | AM_RANGE(0x00200000, 0x002fffff) AM_RAM AM_SHARE("vram") // 98544 mono framebuffer |
| 165 | | AM_RANGE(0x00560000, 0x00563fff) AM_ROM AM_REGION("graphics", 0x0000) // 98544 mono ROM |
| 164 | AM_RANGE(0x00200000, 0x002fffff) AM_RAM AM_SHARE("vram") // 98544 mono framebuffer |
| 165 | AM_RANGE(0x00560000, 0x00563fff) AM_ROM AM_REGION("graphics", 0x0000) // 98544 mono ROM |
| 166 | 166 | |
| 167 | 167 | AM_RANGE(0xffe00000, 0xffefffff) AM_READWRITE(buserror_r, buserror_w) |
| 168 | 168 | AM_RANGE(0xfff00000, 0xffffffff) AM_RAM |
| r243230 | r243231 | |
| 172 | 172 | |
| 173 | 173 | // 9000/330 and 9000/340 |
| 174 | 174 | static ADDRESS_MAP_START(hp9k330_map, AS_PROGRAM, 32, hp9k3xx_state) |
| 175 | | AM_RANGE(0x00200000, 0x002fffff) AM_RAM AM_SHARE("vram") // 98544 mono framebuffer |
| 176 | | AM_RANGE(0x00560000, 0x00563fff) AM_ROM AM_REGION("graphics", 0x0000) // 98544 mono ROM |
| 175 | AM_RANGE(0x00200000, 0x002fffff) AM_RAM AM_SHARE("vram") // 98544 mono framebuffer |
| 176 | AM_RANGE(0x00560000, 0x00563fff) AM_ROM AM_REGION("graphics", 0x0000) // 98544 mono ROM |
| 177 | 177 | |
| 178 | 178 | AM_RANGE(0xffb00000, 0xffbfffff) AM_READWRITE(buserror_r, buserror_w) |
| 179 | 179 | AM_RANGE(0xffc00000, 0xffffffff) AM_RAM |
| r243230 | r243231 | |
| 183 | 183 | |
| 184 | 184 | // 9000/370 - 8 MB RAM standard |
| 185 | 185 | static ADDRESS_MAP_START(hp9k370_map, AS_PROGRAM, 32, hp9k3xx_state) |
| 186 | | AM_RANGE(0x00200000, 0x002fffff) AM_RAM AM_SHARE("vram") // 98544 mono framebuffer |
| 187 | | AM_RANGE(0x00560000, 0x00563fff) AM_ROM AM_REGION("graphics", 0x0000) // 98544 mono ROM |
| 186 | AM_RANGE(0x00200000, 0x002fffff) AM_RAM AM_SHARE("vram") // 98544 mono framebuffer |
| 187 | AM_RANGE(0x00560000, 0x00563fff) AM_ROM AM_REGION("graphics", 0x0000) // 98544 mono ROM |
| 188 | 188 | |
| 189 | 189 | AM_RANGE(0xff700000, 0xff7fffff) AM_READWRITE(buserror_r, buserror_w) |
| 190 | 190 | AM_RANGE(0xff800000, 0xffffffff) AM_RAM |
| r243230 | r243231 | |
| 292 | 292 | MCFG_CPU_PROGRAM_MAP(hp9k310_map) |
| 293 | 293 | |
| 294 | 294 | MCFG_DEVICE_ADD(PTM6840_TAG, PTM6840, 0) |
| 295 | | MCFG_PTM6840_INTERNAL_CLOCK(250000.0f) // from oscillator module next to the 6840 |
| 295 | MCFG_PTM6840_INTERNAL_CLOCK(250000.0f) // from oscillator module next to the 6840 |
| 296 | 296 | MCFG_PTM6840_EXTERNAL_CLOCKS(250000.0f, 250000.0f, 250000.0f) |
| 297 | 297 | |
| 298 | 298 | MCFG_SCREEN_ADD( "screen", RASTER) |
| r243230 | r243231 | |
| 308 | 308 | MCFG_CPU_PROGRAM_MAP(hp9k320_map) |
| 309 | 309 | |
| 310 | 310 | MCFG_DEVICE_ADD(PTM6840_TAG, PTM6840, 0) |
| 311 | | MCFG_PTM6840_INTERNAL_CLOCK(250000.0f) // from oscillator module next to the 6840 |
| 311 | MCFG_PTM6840_INTERNAL_CLOCK(250000.0f) // from oscillator module next to the 6840 |
| 312 | 312 | MCFG_PTM6840_EXTERNAL_CLOCKS(250000.0f, 250000.0f, 250000.0f) |
| 313 | 313 | |
| 314 | 314 | MCFG_SCREEN_ADD( "screen", RASTER) |
| r243230 | r243231 | |
| 324 | 324 | MCFG_CPU_PROGRAM_MAP(hp9k330_map) |
| 325 | 325 | |
| 326 | 326 | MCFG_DEVICE_ADD(PTM6840_TAG, PTM6840, 0) |
| 327 | | MCFG_PTM6840_INTERNAL_CLOCK(250000.0f) // from oscillator module next to the 6840 |
| 327 | MCFG_PTM6840_INTERNAL_CLOCK(250000.0f) // from oscillator module next to the 6840 |
| 328 | 328 | MCFG_PTM6840_EXTERNAL_CLOCKS(250000.0f, 250000.0f, 250000.0f) |
| 329 | 329 | |
| 330 | 330 | MCFG_SCREEN_ADD( "screen", RASTER) |
| r243230 | r243231 | |
| 340 | 340 | MCFG_CPU_PROGRAM_MAP(hp9k330_map) |
| 341 | 341 | |
| 342 | 342 | MCFG_DEVICE_ADD(PTM6840_TAG, PTM6840, 0) |
| 343 | | MCFG_PTM6840_INTERNAL_CLOCK(250000.0f) // from oscillator module next to the 6840 |
| 343 | MCFG_PTM6840_INTERNAL_CLOCK(250000.0f) // from oscillator module next to the 6840 |
| 344 | 344 | MCFG_PTM6840_EXTERNAL_CLOCKS(250000.0f, 250000.0f, 250000.0f) |
| 345 | 345 | |
| 346 | 346 | MCFG_SCREEN_ADD( "screen", RASTER) |
| r243230 | r243231 | |
| 356 | 356 | MCFG_CPU_PROGRAM_MAP(hp9k370_map) |
| 357 | 357 | |
| 358 | 358 | MCFG_DEVICE_ADD(PTM6840_TAG, PTM6840, 0) |
| 359 | | MCFG_PTM6840_INTERNAL_CLOCK(250000.0f) // from oscillator module next to the 6840 |
| 359 | MCFG_PTM6840_INTERNAL_CLOCK(250000.0f) // from oscillator module next to the 6840 |
| 360 | 360 | MCFG_PTM6840_EXTERNAL_CLOCKS(250000.0f, 250000.0f, 250000.0f) |
| 361 | 361 | |
| 362 | 362 | MCFG_SCREEN_ADD( "screen", RASTER) |
| r243230 | r243231 | |
| 368 | 368 | |
| 369 | 369 | static MACHINE_CONFIG_START( hp9k380, hp9k3xx_state ) |
| 370 | 370 | /* basic machine hardware */ |
| 371 | | MCFG_CPU_ADD(MAINCPU_TAG, M68040, 25000000) // 25 MHz? 33? |
| 371 | MCFG_CPU_ADD(MAINCPU_TAG, M68040, 25000000) // 25 MHz? 33? |
| 372 | 372 | MCFG_CPU_PROGRAM_MAP(hp9k330_map) |
| 373 | 373 | |
| 374 | 374 | MCFG_DEVICE_ADD(PTM6840_TAG, PTM6840, 0) |
| 375 | | MCFG_PTM6840_INTERNAL_CLOCK(250000.0f) // from oscillator module next to the 6840 |
| 375 | MCFG_PTM6840_INTERNAL_CLOCK(250000.0f) // from oscillator module next to the 6840 |
| 376 | 376 | MCFG_PTM6840_EXTERNAL_CLOCKS(250000.0f, 250000.0f, 250000.0f) |
| 377 | 377 | |
| 378 | 378 | MCFG_SCREEN_ADD( "screen", RASTER) |
| r243230 | r243231 | |
| 384 | 384 | |
| 385 | 385 | static MACHINE_CONFIG_START( hp9k382, hp9k3xx_state ) |
| 386 | 386 | /* basic machine hardware */ |
| 387 | | MCFG_CPU_ADD(MAINCPU_TAG, M68040, 25000000) // 25 MHz? 33? |
| 387 | MCFG_CPU_ADD(MAINCPU_TAG, M68040, 25000000) // 25 MHz? 33? |
| 388 | 388 | MCFG_CPU_PROGRAM_MAP(hp9k382_map) |
| 389 | 389 | |
| 390 | 390 | MCFG_DEVICE_ADD(PTM6840_TAG, PTM6840, 0) |
| 391 | | MCFG_PTM6840_INTERNAL_CLOCK(250000.0f) // from oscillator module next to the 6840 |
| 391 | MCFG_PTM6840_INTERNAL_CLOCK(250000.0f) // from oscillator module next to the 6840 |
| 392 | 392 | MCFG_PTM6840_EXTERNAL_CLOCKS(250000.0f, 250000.0f, 250000.0f) |
| 393 | 393 | |
| 394 | 394 | MCFG_SCREEN_ADD( "screen", RASTER) |
| r243230 | r243231 | |
| 400 | 400 | |
| 401 | 401 | ROM_START( hp9k310 ) |
| 402 | 402 | ROM_REGION( 0x20000, MAINCPU_TAG, 0 ) |
| 403 | | ROM_LOAD16_BYTE( "1818-3771.bin", 0x000001, 0x008000, CRC(b9e4e3ad) SHA1(ed6f1fad94a15d95362701dbe124b52877fc3ec4) ) |
| 404 | | ROM_LOAD16_BYTE( "1818-3772.bin", 0x000000, 0x008000, CRC(a3665919) SHA1(ec1bc7e5b7990a1b09af947a06401e8ed3cb0516) ) |
| 403 | ROM_LOAD16_BYTE( "1818-3771.bin", 0x000001, 0x008000, CRC(b9e4e3ad) SHA1(ed6f1fad94a15d95362701dbe124b52877fc3ec4) ) |
| 404 | ROM_LOAD16_BYTE( "1818-3772.bin", 0x000000, 0x008000, CRC(a3665919) SHA1(ec1bc7e5b7990a1b09af947a06401e8ed3cb0516) ) |
| 405 | 405 | |
| 406 | 406 | ROM_REGION( 0x800, "mcu", 0 ) |
| 407 | | ROM_LOAD( "1820-4784_1.bin", 0x000000, 0x000800, CRC(e929044a) SHA1(90849a10bdb8c6e38e73ce027c9c0ad8b3956b1b) ) |
| 408 | | ROM_LOAD( "1820-4784_2.bin", 0x000000, 0x000800, CRC(8defcf50) SHA1(d3abfea468a43db7c2369500a3e390e77a8e22e6) ) |
| 407 | ROM_LOAD( "1820-4784_1.bin", 0x000000, 0x000800, CRC(e929044a) SHA1(90849a10bdb8c6e38e73ce027c9c0ad8b3956b1b) ) |
| 408 | ROM_LOAD( "1820-4784_2.bin", 0x000000, 0x000800, CRC(8defcf50) SHA1(d3abfea468a43db7c2369500a3e390e77a8e22e6) ) |
| 409 | 409 | |
| 410 | 410 | ROM_REGION( 0x4000, "graphics", ROMREGION_ERASEFF | ROMREGION_BE ) |
| 411 | 411 | ROM_LOAD16_BYTE( "98544_1818-1999.bin", 0x000000, 0x002000, CRC(8c7d6480) SHA1(d2bcfd39452c38bc652df39f84c7041cfdf6bd51) ) |
| r243230 | r243231 | |
| 413 | 413 | |
| 414 | 414 | ROM_START( hp9k320 ) |
| 415 | 415 | ROM_REGION( 0x20000, MAINCPU_TAG, 0 ) |
| 416 | | ROM_LOAD16_BYTE( "5061-6538.bin", 0x000001, 0x004000, CRC(d6aafeb1) SHA1(88c6b0b2f504303cbbac0c496c26b85458ac5d63) ) |
| 417 | | ROM_LOAD16_BYTE( "5061-6539.bin", 0x000000, 0x004000, CRC(a7ff104c) SHA1(c640fe68314654716bd41b04c6a7f4e560036c7e) ) |
| 418 | | ROM_LOAD16_BYTE( "5061-6540.bin", 0x008001, 0x004000, CRC(4f6796d6) SHA1(fd254897ac1afb8628f40ea93213f60a082c8d36) ) |
| 419 | | ROM_LOAD16_BYTE( "5061-6541.bin", 0x008000, 0x004000, CRC(39d32998) SHA1(6de1bda75187b0878c03c074942b807cf2924f0e) ) |
| 416 | ROM_LOAD16_BYTE( "5061-6538.bin", 0x000001, 0x004000, CRC(d6aafeb1) SHA1(88c6b0b2f504303cbbac0c496c26b85458ac5d63) ) |
| 417 | ROM_LOAD16_BYTE( "5061-6539.bin", 0x000000, 0x004000, CRC(a7ff104c) SHA1(c640fe68314654716bd41b04c6a7f4e560036c7e) ) |
| 418 | ROM_LOAD16_BYTE( "5061-6540.bin", 0x008001, 0x004000, CRC(4f6796d6) SHA1(fd254897ac1afb8628f40ea93213f60a082c8d36) ) |
| 419 | ROM_LOAD16_BYTE( "5061-6541.bin", 0x008000, 0x004000, CRC(39d32998) SHA1(6de1bda75187b0878c03c074942b807cf2924f0e) ) |
| 420 | 420 | |
| 421 | 421 | ROM_REGION( 0x4000, "graphics", ROMREGION_ERASEFF | ROMREGION_BE | ROMREGION_32BIT ) |
| 422 | 422 | ROM_LOAD16_BYTE( "98544_1818-1999.bin", 0x000001, 0x002000, CRC(8c7d6480) SHA1(d2bcfd39452c38bc652df39f84c7041cfdf6bd51) ) |
| r243230 | r243231 | |
| 424 | 424 | |
| 425 | 425 | ROM_START( hp9k330 ) |
| 426 | 426 | ROM_REGION( 0x20000, MAINCPU_TAG, 0 ) |
| 427 | | ROM_LOAD16_BYTE( "1818-4416.bin", 0x000000, 0x010000, CRC(cd71e85e) SHA1(3e83a80682f733417fdc3720410e45a2cfdcf869) ) |
| 428 | | ROM_LOAD16_BYTE( "1818-4417.bin", 0x000001, 0x010000, CRC(374d49db) SHA1(a12cbf6c151e2f421da4571000b5dffa3ef403b3) ) |
| 427 | ROM_LOAD16_BYTE( "1818-4416.bin", 0x000000, 0x010000, CRC(cd71e85e) SHA1(3e83a80682f733417fdc3720410e45a2cfdcf869) ) |
| 428 | ROM_LOAD16_BYTE( "1818-4417.bin", 0x000001, 0x010000, CRC(374d49db) SHA1(a12cbf6c151e2f421da4571000b5dffa3ef403b3) ) |
| 429 | 429 | |
| 430 | 430 | ROM_REGION( 0x4000, "graphics", ROMREGION_ERASEFF | ROMREGION_BE | ROMREGION_32BIT ) |
| 431 | 431 | ROM_LOAD16_BYTE( "98544_1818-1999.bin", 0x000001, 0x002000, CRC(8c7d6480) SHA1(d2bcfd39452c38bc652df39f84c7041cfdf6bd51) ) |
| r243230 | r243231 | |
| 433 | 433 | |
| 434 | 434 | ROM_START( hp9k340 ) |
| 435 | 435 | ROM_REGION( 0x20000, MAINCPU_TAG, 0 ) |
| 436 | | ROM_LOAD16_BYTE( "1818-4416.bin", 0x000000, 0x010000, CRC(cd71e85e) SHA1(3e83a80682f733417fdc3720410e45a2cfdcf869) ) |
| 437 | | ROM_LOAD16_BYTE( "1818-4417.bin", 0x000001, 0x010000, CRC(374d49db) SHA1(a12cbf6c151e2f421da4571000b5dffa3ef403b3) ) |
| 436 | ROM_LOAD16_BYTE( "1818-4416.bin", 0x000000, 0x010000, CRC(cd71e85e) SHA1(3e83a80682f733417fdc3720410e45a2cfdcf869) ) |
| 437 | ROM_LOAD16_BYTE( "1818-4417.bin", 0x000001, 0x010000, CRC(374d49db) SHA1(a12cbf6c151e2f421da4571000b5dffa3ef403b3) ) |
| 438 | 438 | |
| 439 | 439 | ROM_REGION( 0x4000, "graphics", ROMREGION_ERASEFF | ROMREGION_BE | ROMREGION_32BIT ) |
| 440 | 440 | ROM_LOAD16_BYTE( "98544_1818-1999.bin", 0x000001, 0x002000, CRC(8c7d6480) SHA1(d2bcfd39452c38bc652df39f84c7041cfdf6bd51) ) |
trunk/src/mess/machine/c65.c
| r0 | r243231 | |
| 1 | /*************************************************************************** |
| 2 | commodore c65 home computer |
| 3 | peter.trauner@jk.uni-linz.ac.at |
| 4 | documention |
| 5 | www.funet.fi |
| 6 | ***************************************************************************/ |
| 7 | |
| 8 | #include "emu.h" |
| 9 | |
| 10 | #include "includes/c65.h" |
| 11 | #include "cpu/m6502/m4510.h" |
| 12 | #include "sound/mos6581.h" |
| 13 | #include "machine/mos6526.h" |
| 14 | #include "bus/cbmiec/cbmiec.h" |
| 15 | #include "machine/ram.h" |
| 16 | #include "video/vic4567.h" |
| 17 | #include "imagedev/cassette.h" |
| 18 | #include "crsshair.h" |
| 19 | #include "formats/cbm_tap.h" |
| 20 | |
| 21 | #define VERBOSE_LEVEL 0 |
| 22 | #define DBG_LOG( MACHINE, N, M, A ) \ |
| 23 | do { \ |
| 24 | if(VERBOSE_LEVEL >= N) \ |
| 25 | { \ |
| 26 | if( M ) \ |
| 27 | logerror("%11.6f: %-24s", MACHINE.time().as_double(), (char*) M ); \ |
| 28 | logerror A; \ |
| 29 | } \ |
| 30 | } while (0) |
| 31 | |
| 32 | |
| 33 | |
| 34 | /*********************************************** |
| 35 | |
| 36 | Input Reading - Common Components |
| 37 | |
| 38 | ***********************************************/ |
| 39 | |
| 40 | /* These are needed by c64, c65 and c128, each machine has also additional specific |
| 41 | components in its INTERRUPT_GEN */ |
| 42 | |
| 43 | /* keyboard lines */ |
| 44 | UINT8 c64_keyline[10]; |
| 45 | |
| 46 | void cbm_common_init(void) |
| 47 | { |
| 48 | int i; |
| 49 | |
| 50 | for (i = 0; i < ARRAY_LENGTH(c64_keyline); i++) |
| 51 | c64_keyline[i] = 0xff; |
| 52 | } |
| 53 | |
| 54 | static TIMER_CALLBACK( lightpen_tick ) |
| 55 | { |
| 56 | if (((machine.root_device().ioport("CTRLSEL")->read() & 0x07) == 0x04) || ((machine.root_device().ioport("CTRLSEL")->read() & 0x07) == 0x06)) |
| 57 | { |
| 58 | /* enable lightpen crosshair */ |
| 59 | crosshair_set_screen(machine, 0, CROSSHAIR_SCREEN_ALL); |
| 60 | } |
| 61 | else |
| 62 | { |
| 63 | /* disable lightpen crosshair */ |
| 64 | crosshair_set_screen(machine, 0, CROSSHAIR_SCREEN_NONE); |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | void cbm_common_interrupt( device_t *device ) |
| 69 | { |
| 70 | int value, i; |
| 71 | int controller1 = device->machine().root_device().ioport("CTRLSEL")->read() & 0x07; |
| 72 | int controller2 = device->machine().root_device().ioport("CTRLSEL")->read() & 0x70; |
| 73 | static const char *const c64ports[] = { "ROW0", "ROW1", "ROW2", "ROW3", "ROW4", "ROW5", "ROW6", "ROW7" }; |
| 74 | |
| 75 | /* Lines 0-7 : common keyboard */ |
| 76 | for (i = 0; i < 8; i++) |
| 77 | { |
| 78 | value = 0xff; |
| 79 | value &= ~device->machine().root_device().ioport(c64ports[i])->read(); |
| 80 | |
| 81 | /* Shift Lock is mapped on Left Shift */ |
| 82 | if ((i == 1) && (device->machine().root_device().ioport("SPECIAL")->read() & 0x40)) |
| 83 | value &= ~0x80; |
| 84 | |
| 85 | c64_keyline[i] = value; |
| 86 | } |
| 87 | |
| 88 | |
| 89 | value = 0xff; |
| 90 | switch(controller1) |
| 91 | { |
| 92 | case 0x00: |
| 93 | value &= ~device->machine().root_device().ioport("JOY1_1B")->read(); /* Joy1 Directions + Button 1 */ |
| 94 | break; |
| 95 | |
| 96 | case 0x01: |
| 97 | if (device->machine().root_device().ioport("OTHER")->read() & 0x40) /* Paddle2 Button */ |
| 98 | value &= ~0x08; |
| 99 | if (device->machine().root_device().ioport("OTHER")->read() & 0x80) /* Paddle1 Button */ |
| 100 | value &= ~0x04; |
| 101 | break; |
| 102 | |
| 103 | case 0x02: |
| 104 | if (device->machine().root_device().ioport("OTHER")->read() & 0x02) /* Mouse Button Left */ |
| 105 | value &= ~0x10; |
| 106 | if (device->machine().root_device().ioport("OTHER")->read() & 0x01) /* Mouse Button Right */ |
| 107 | value &= ~0x01; |
| 108 | break; |
| 109 | |
| 110 | case 0x03: |
| 111 | value &= ~(device->machine().root_device().ioport("JOY1_2B")->read() & 0x1f); /* Joy1 Directions + Button 1 */ |
| 112 | break; |
| 113 | |
| 114 | case 0x04: |
| 115 | /* was there any input on the lightpen? where is it mapped? */ |
| 116 | // if (device->machine().root_device().ioport("OTHER")->read() & 0x04) /* Lightpen Signal */ |
| 117 | // value &= ?? ; |
| 118 | break; |
| 119 | |
| 120 | case 0x07: |
| 121 | break; |
| 122 | |
| 123 | default: |
| 124 | logerror("Invalid Controller 1 Setting %d\n", controller1); |
| 125 | break; |
| 126 | } |
| 127 | |
| 128 | c64_keyline[8] = value; |
| 129 | |
| 130 | |
| 131 | value = 0xff; |
| 132 | switch(controller2) |
| 133 | { |
| 134 | case 0x00: |
| 135 | value &= ~device->machine().root_device().ioport("JOY2_1B")->read(); /* Joy2 Directions + Button 1 */ |
| 136 | break; |
| 137 | |
| 138 | case 0x10: |
| 139 | if (device->machine().root_device().ioport("OTHER")->read() & 0x10) /* Paddle4 Button */ |
| 140 | value &= ~0x08; |
| 141 | if (device->machine().root_device().ioport("OTHER")->read() & 0x20) /* Paddle3 Button */ |
| 142 | value &= ~0x04; |
| 143 | break; |
| 144 | |
| 145 | case 0x20: |
| 146 | if (device->machine().root_device().ioport("OTHER")->read() & 0x02) /* Mouse Button Left */ |
| 147 | value &= ~0x10; |
| 148 | if (device->machine().root_device().ioport("OTHER")->read() & 0x01) /* Mouse Button Right */ |
| 149 | value &= ~0x01; |
| 150 | break; |
| 151 | |
| 152 | case 0x30: |
| 153 | value &= ~(device->machine().root_device().ioport("JOY2_2B")->read() & 0x1f); /* Joy2 Directions + Button 1 */ |
| 154 | break; |
| 155 | |
| 156 | case 0x40: |
| 157 | /* was there any input on the lightpen? where is it mapped? */ |
| 158 | // if (device->machine().root_device().ioport("OTHER")->read() & 0x04) /* Lightpen Signal */ |
| 159 | // value &= ?? ; |
| 160 | break; |
| 161 | |
| 162 | case 0x70: |
| 163 | break; |
| 164 | |
| 165 | default: |
| 166 | logerror("Invalid Controller 2 Setting %d\n", controller2); |
| 167 | break; |
| 168 | } |
| 169 | |
| 170 | c64_keyline[9] = value; |
| 171 | |
| 172 | // vic2_frame_interrupt does nothing so this is not necessary |
| 173 | // vic2_frame_interrupt (device); |
| 174 | |
| 175 | /* check if lightpen has been chosen as input: if so, enable crosshair */ |
| 176 | device->machine().scheduler().timer_set(attotime::zero, FUNC(lightpen_tick)); |
| 177 | |
| 178 | set_led_status (device->machine(), 1, device->machine().root_device().ioport("SPECIAL")->read() & 0x40 ? 1 : 0); /* Shift Lock */ |
| 179 | set_led_status (device->machine(), 0, device->machine().root_device().ioport("CTRLSEL")->read() & 0x80 ? 1 : 0); /* Joystick Swap */ |
| 180 | } |
| 181 | |
| 182 | |
| 183 | /*********************************************** |
| 184 | |
| 185 | CIA Common Handlers |
| 186 | |
| 187 | ***********************************************/ |
| 188 | |
| 189 | /* These are shared by c64, c65 and c128. c65 and c128 also have additional specific |
| 190 | components (to select/read additional keyboard lines) */ |
| 191 | |
| 192 | /* |
| 193 | * CIA 0 - Port A |
| 194 | * bits 7-0 keyboard line select |
| 195 | * bits 7,6: paddle select( 01 port a, 10 port b) |
| 196 | * bit 4: joystick a fire button |
| 197 | * bits 3,2: Paddles port a fire button |
| 198 | * bits 3-0: joystick a direction |
| 199 | * |
| 200 | * CIA 0 - Port B |
| 201 | * bits 7-0: keyboard raw values |
| 202 | * bit 4: joystick b fire button, lightpen select |
| 203 | * bits 3,2: paddle b fire buttons (left,right) |
| 204 | * bits 3-0: joystick b direction |
| 205 | * |
| 206 | * flag cassette read input, serial request in |
| 207 | * irq to irq connected |
| 208 | */ |
| 209 | |
| 210 | UINT8 cbm_common_cia0_port_a_r( device_t *device, UINT8 output_b ) |
| 211 | { |
| 212 | UINT8 value = 0xff; |
| 213 | |
| 214 | if (!(output_b & 0x80)) |
| 215 | { |
| 216 | UINT8 t = 0xff; |
| 217 | if (!(c64_keyline[7] & 0x80)) t &= ~0x80; |
| 218 | if (!(c64_keyline[6] & 0x80)) t &= ~0x40; |
| 219 | if (!(c64_keyline[5] & 0x80)) t &= ~0x20; |
| 220 | if (!(c64_keyline[4] & 0x80)) t &= ~0x10; |
| 221 | if (!(c64_keyline[3] & 0x80)) t &= ~0x08; |
| 222 | if (!(c64_keyline[2] & 0x80)) t &= ~0x04; |
| 223 | if (!(c64_keyline[1] & 0x80)) t &= ~0x02; |
| 224 | if (!(c64_keyline[0] & 0x80)) t &= ~0x01; |
| 225 | value &= t; |
| 226 | } |
| 227 | |
| 228 | if (!(output_b & 0x40)) |
| 229 | { |
| 230 | UINT8 t = 0xff; |
| 231 | if (!(c64_keyline[7] & 0x40)) t &= ~0x80; |
| 232 | if (!(c64_keyline[6] & 0x40)) t &= ~0x40; |
| 233 | if (!(c64_keyline[5] & 0x40)) t &= ~0x20; |
| 234 | if (!(c64_keyline[4] & 0x40)) t &= ~0x10; |
| 235 | if (!(c64_keyline[3] & 0x40)) t &= ~0x08; |
| 236 | if (!(c64_keyline[2] & 0x40)) t &= ~0x04; |
| 237 | if (!(c64_keyline[1] & 0x40)) t &= ~0x02; |
| 238 | if (!(c64_keyline[0] & 0x40)) t &= ~0x01; |
| 239 | value &= t; |
| 240 | } |
| 241 | |
| 242 | if (!(output_b & 0x20)) |
| 243 | { |
| 244 | UINT8 t = 0xff; |
| 245 | if (!(c64_keyline[7] & 0x20)) t &= ~0x80; |
| 246 | if (!(c64_keyline[6] & 0x20)) t &= ~0x40; |
| 247 | if (!(c64_keyline[5] & 0x20)) t &= ~0x20; |
| 248 | if (!(c64_keyline[4] & 0x20)) t &= ~0x10; |
| 249 | if (!(c64_keyline[3] & 0x20)) t &= ~0x08; |
| 250 | if (!(c64_keyline[2] & 0x20)) t &= ~0x04; |
| 251 | if (!(c64_keyline[1] & 0x20)) t &= ~0x02; |
| 252 | if (!(c64_keyline[0] & 0x20)) t &= ~0x01; |
| 253 | value &= t; |
| 254 | } |
| 255 | |
| 256 | if (!(output_b & 0x10)) |
| 257 | { |
| 258 | UINT8 t = 0xff; |
| 259 | if (!(c64_keyline[7] & 0x10)) t &= ~0x80; |
| 260 | if (!(c64_keyline[6] & 0x10)) t &= ~0x40; |
| 261 | if (!(c64_keyline[5] & 0x10)) t &= ~0x20; |
| 262 | if (!(c64_keyline[4] & 0x10)) t &= ~0x10; |
| 263 | if (!(c64_keyline[3] & 0x10)) t &= ~0x08; |
| 264 | if (!(c64_keyline[2] & 0x10)) t &= ~0x04; |
| 265 | if (!(c64_keyline[1] & 0x10)) t &= ~0x02; |
| 266 | if (!(c64_keyline[0] & 0x10)) t &= ~0x01; |
| 267 | value &= t; |
| 268 | } |
| 269 | |
| 270 | if (!(output_b & 0x08)) |
| 271 | { |
| 272 | UINT8 t = 0xff; |
| 273 | if (!(c64_keyline[7] & 0x08)) t &= ~0x80; |
| 274 | if (!(c64_keyline[6] & 0x08)) t &= ~0x40; |
| 275 | if (!(c64_keyline[5] & 0x08)) t &= ~0x20; |
| 276 | if (!(c64_keyline[4] & 0x08)) t &= ~0x10; |
| 277 | if (!(c64_keyline[3] & 0x08)) t &= ~0x08; |
| 278 | if (!(c64_keyline[2] & 0x08)) t &= ~0x04; |
| 279 | if (!(c64_keyline[1] & 0x08)) t &= ~0x02; |
| 280 | if (!(c64_keyline[0] & 0x08)) t &= ~0x01; |
| 281 | value &= t; |
| 282 | } |
| 283 | |
| 284 | if (!(output_b & 0x04)) |
| 285 | { |
| 286 | UINT8 t = 0xff; |
| 287 | if (!(c64_keyline[7] & 0x04)) t &= ~0x80; |
| 288 | if (!(c64_keyline[6] & 0x04)) t &= ~0x40; |
| 289 | if (!(c64_keyline[5] & 0x04)) t &= ~0x20; |
| 290 | if (!(c64_keyline[4] & 0x04)) t &= ~0x10; |
| 291 | if (!(c64_keyline[3] & 0x04)) t &= ~0x08; |
| 292 | if (!(c64_keyline[2] & 0x04)) t &= ~0x04; |
| 293 | if (!(c64_keyline[1] & 0x04)) t &= ~0x02; |
| 294 | if (!(c64_keyline[0] & 0x04)) t &= ~0x01; |
| 295 | value &= t; |
| 296 | } |
| 297 | |
| 298 | if (!(output_b & 0x02)) |
| 299 | { |
| 300 | UINT8 t = 0xff; |
| 301 | if (!(c64_keyline[7] & 0x02)) t &= ~0x80; |
| 302 | if (!(c64_keyline[6] & 0x02)) t &= ~0x40; |
| 303 | if (!(c64_keyline[5] & 0x02)) t &= ~0x20; |
| 304 | if (!(c64_keyline[4] & 0x02)) t &= ~0x10; |
| 305 | if (!(c64_keyline[3] & 0x02)) t &= ~0x08; |
| 306 | if (!(c64_keyline[2] & 0x02)) t &= ~0x04; |
| 307 | if (!(c64_keyline[1] & 0x02)) t &= ~0x02; |
| 308 | if (!(c64_keyline[0] & 0x02)) t &= ~0x01; |
| 309 | value &= t; |
| 310 | } |
| 311 | |
| 312 | if (!(output_b & 0x01)) |
| 313 | { |
| 314 | UINT8 t = 0xff; |
| 315 | if (!(c64_keyline[7] & 0x01)) t &= ~0x80; |
| 316 | if (!(c64_keyline[6] & 0x01)) t &= ~0x40; |
| 317 | if (!(c64_keyline[5] & 0x01)) t &= ~0x20; |
| 318 | if (!(c64_keyline[4] & 0x01)) t &= ~0x10; |
| 319 | if (!(c64_keyline[3] & 0x01)) t &= ~0x08; |
| 320 | if (!(c64_keyline[2] & 0x01)) t &= ~0x04; |
| 321 | if (!(c64_keyline[1] & 0x01)) t &= ~0x02; |
| 322 | if (!(c64_keyline[0] & 0x01)) t &= ~0x01; |
| 323 | value &= t; |
| 324 | } |
| 325 | |
| 326 | if ( device->machine().root_device().ioport("CTRLSEL")->read() & 0x80 ) |
| 327 | value &= c64_keyline[8]; |
| 328 | else |
| 329 | value &= c64_keyline[9]; |
| 330 | |
| 331 | return value; |
| 332 | } |
| 333 | |
| 334 | UINT8 cbm_common_cia0_port_b_r( device_t *device, UINT8 output_a ) |
| 335 | { |
| 336 | UINT8 value = 0xff; |
| 337 | |
| 338 | if (!(output_a & 0x80)) value &= c64_keyline[7]; |
| 339 | if (!(output_a & 0x40)) value &= c64_keyline[6]; |
| 340 | if (!(output_a & 0x20)) value &= c64_keyline[5]; |
| 341 | if (!(output_a & 0x10)) value &= c64_keyline[4]; |
| 342 | if (!(output_a & 0x08)) value &= c64_keyline[3]; |
| 343 | if (!(output_a & 0x04)) value &= c64_keyline[2]; |
| 344 | if (!(output_a & 0x02)) value &= c64_keyline[1]; |
| 345 | if (!(output_a & 0x01)) value &= c64_keyline[0]; |
| 346 | |
| 347 | if ( device->machine().root_device().ioport("CTRLSEL")->read() & 0x80 ) |
| 348 | value &= c64_keyline[9]; |
| 349 | else |
| 350 | value &= c64_keyline[8]; |
| 351 | |
| 352 | return value; |
| 353 | } |
| 354 | |
| 355 | |
| 356 | /*********************************************** |
| 357 | |
| 358 | CBM Cartridges |
| 359 | |
| 360 | ***********************************************/ |
| 361 | |
| 362 | |
| 363 | /* All the cartridge specific code has been moved |
| 364 | to machine/ drivers. Once more informations |
| 365 | surface about the cart expansions for systems |
| 366 | in c65.c, c128.c, cbmb.c and pet.c, the shared |
| 367 | code could be refactored to have here the |
| 368 | common functions */ |
| 369 | |
| 370 | |
| 371 | |
| 372 | /*********************************************** |
| 373 | |
| 374 | CBM Datasette Tapes |
| 375 | |
| 376 | ***********************************************/ |
| 377 | |
| 378 | #if 0 |
| 379 | const cassette_interface cbm_cassette_interface = |
| 380 | { |
| 381 | cbm_cassette_formats, |
| 382 | NULL, |
| 383 | (cassette_state) (CASSETTE_STOPPED | CASSETTE_MOTOR_DISABLED | CASSETTE_SPEAKER_ENABLED), |
| 384 | NULL |
| 385 | }; |
| 386 | #endif |
| 387 | |
| 388 | |
| 389 | /*UINT8 *c65_basic; */ |
| 390 | /*UINT8 *c65_kernal; */ |
| 391 | /*UINT8 *c65_dos; */ |
| 392 | /*UINT8 *c65_monitor; */ |
| 393 | /*UINT8 *c65_graphics; */ |
| 394 | |
| 395 | |
| 396 | void c65_state::c65_nmi( ) |
| 397 | { |
| 398 | if (m_nmilevel != (ioport("SPECIAL")->read() & 0x80) || m_cia1_irq) /* KEY_RESTORE */ |
| 399 | { |
| 400 | m_maincpu->set_input_line(INPUT_LINE_NMI, (ioport("SPECIAL")->read() & 0x80) || m_cia1_irq); |
| 401 | |
| 402 | m_nmilevel = (ioport("SPECIAL")->read() & 0x80) || m_cia1_irq; |
| 403 | } |
| 404 | } |
| 405 | |
| 406 | |
| 407 | /*********************************************** |
| 408 | |
| 409 | CIA Interfaces |
| 410 | |
| 411 | ***********************************************/ |
| 412 | |
| 413 | /* |
| 414 | * CIA 0 - Port A keyboard line select |
| 415 | * CIA 0 - Port B keyboard line read |
| 416 | * |
| 417 | * flag cassette read input, serial request in |
| 418 | * irq to irq connected |
| 419 | * |
| 420 | * see machine/cbm.c |
| 421 | */ |
| 422 | |
| 423 | READ8_MEMBER(c65_state::c65_cia0_port_a_r) |
| 424 | { |
| 425 | UINT8 cia0portb = m_cia0->pb_r(space, 0); |
| 426 | |
| 427 | return cbm_common_cia0_port_a_r(m_cia0, cia0portb); |
| 428 | } |
| 429 | |
| 430 | READ8_MEMBER(c65_state::c65_cia0_port_b_r) |
| 431 | { |
| 432 | UINT8 value = 0xff; |
| 433 | UINT8 cia0porta = m_cia0->pa_r(space, 0); |
| 434 | |
| 435 | value &= cbm_common_cia0_port_b_r(m_cia0, cia0porta); |
| 436 | |
| 437 | if (!(m_6511_port & 0x02)) |
| 438 | value &= m_keyline; |
| 439 | |
| 440 | return value; |
| 441 | } |
| 442 | |
| 443 | WRITE8_MEMBER(c65_state::c65_cia0_port_b_w) |
| 444 | { |
| 445 | // was there lightpen support in c65 video chip? |
| 446 | // vic3_device *vic3 = machine().device<vic3_device>("vic3"); |
| 447 | // vic3->lightpen_write(data & 0x10); |
| 448 | } |
| 449 | |
| 450 | void c65_state::c65_irq( int level ) |
| 451 | { |
| 452 | if (level != m_old_level) |
| 453 | { |
| 454 | DBG_LOG(machine(), 3, "mos4510", ("irq %s\n", level ? "start" : "end")); |
| 455 | m_maincpu->set_input_line(M4510_IRQ_LINE, level); |
| 456 | m_old_level = level; |
| 457 | } |
| 458 | } |
| 459 | |
| 460 | /* is this correct for c65 as well as c64? */ |
| 461 | WRITE_LINE_MEMBER(c65_state::c65_cia0_interrupt) |
| 462 | { |
| 463 | m_cia0_irq = state; |
| 464 | c65_irq(state || m_vicirq); |
| 465 | } |
| 466 | |
| 467 | /* is this correct for c65 as well as c64? */ |
| 468 | WRITE_LINE_MEMBER(c65_state::c65_vic_interrupt) |
| 469 | { |
| 470 | #if 1 |
| 471 | if (state != m_vicirq) |
| 472 | { |
| 473 | c65_irq (state || m_cia0_irq); |
| 474 | m_vicirq = state; |
| 475 | } |
| 476 | #endif |
| 477 | } |
| 478 | |
| 479 | /* |
| 480 | * CIA 1 - Port A |
| 481 | * bit 7 serial bus data input |
| 482 | * bit 6 serial bus clock input |
| 483 | * bit 5 serial bus data output |
| 484 | * bit 4 serial bus clock output |
| 485 | * bit 3 serial bus atn output |
| 486 | * bit 2 rs232 data output |
| 487 | * bits 1-0 vic-chip system memory bank select |
| 488 | * |
| 489 | * CIA 1 - Port B |
| 490 | * bit 7 user rs232 data set ready |
| 491 | * bit 6 user rs232 clear to send |
| 492 | * bit 5 user |
| 493 | * bit 4 user rs232 carrier detect |
| 494 | * bit 3 user rs232 ring indicator |
| 495 | * bit 2 user rs232 data terminal ready |
| 496 | * bit 1 user rs232 request to send |
| 497 | * bit 0 user rs232 received data |
| 498 | * |
| 499 | * flag restore key or rs232 received data input |
| 500 | * irq to nmi connected ? |
| 501 | */ |
| 502 | READ8_MEMBER(c65_state::c65_cia1_port_a_r) |
| 503 | { |
| 504 | UINT8 value = 0xff; |
| 505 | |
| 506 | if (!m_iec->clk_r()) |
| 507 | value &= ~0x40; |
| 508 | |
| 509 | if (!m_iec->data_r()) |
| 510 | value &= ~0x80; |
| 511 | |
| 512 | return value; |
| 513 | } |
| 514 | |
| 515 | WRITE8_MEMBER(c65_state::c65_cia1_port_a_w) |
| 516 | { |
| 517 | static const int helper[4] = {0xc000, 0x8000, 0x4000, 0x0000}; |
| 518 | |
| 519 | m_iec->atn_w(!BIT(data, 3)); |
| 520 | m_iec->clk_w(!BIT(data, 4)); |
| 521 | m_iec->data_w(!BIT(data, 5)); |
| 522 | |
| 523 | m_vicaddr = m_memory + helper[data & 0x03]; |
| 524 | } |
| 525 | |
| 526 | WRITE_LINE_MEMBER(c65_state::c65_cia1_interrupt) |
| 527 | { |
| 528 | m_cia1_irq = state; |
| 529 | c65_nmi(); |
| 530 | } |
| 531 | |
| 532 | /*********************************************** |
| 533 | |
| 534 | Memory Handlers |
| 535 | |
| 536 | ***********************************************/ |
| 537 | |
| 538 | /* processor has only 1 mega address space !? */ |
| 539 | /* and system 8 megabyte */ |
| 540 | /* dma controller and bankswitch hardware ?*/ |
| 541 | READ8_MEMBER( c65_state::c65_read_mem ) |
| 542 | { |
| 543 | UINT8 result; |
| 544 | if (offset <= 0x0ffff) |
| 545 | result = m_memory[offset]; |
| 546 | else |
| 547 | result = space.read_byte(offset); |
| 548 | return result; |
| 549 | } |
| 550 | |
| 551 | WRITE8_MEMBER( c65_state::c65_write_mem ) |
| 552 | { |
| 553 | if (offset <= 0x0ffff) |
| 554 | m_memory[offset] = data; |
| 555 | else |
| 556 | space.write_byte(offset, data); |
| 557 | } |
| 558 | |
| 559 | /* dma chip at 0xd700 |
| 560 | used: |
| 561 | writing banknumber to offset 2 |
| 562 | writing hibyte to offset 1 |
| 563 | writing lobyte to offset 0 |
| 564 | cpu holded, dma transfer(data at address) executed, cpu activated |
| 565 | |
| 566 | command data: |
| 567 | 0 command (0 copy, 3 fill) |
| 568 | 1,2 length |
| 569 | 3,4,5 source |
| 570 | 6,7,8 dest |
| 571 | 9 subcommand |
| 572 | 10 mod |
| 573 | |
| 574 | version 1: |
| 575 | seldom copy (overlapping) from 0x402002 to 0x402008 |
| 576 | (making place for new line in basic area) |
| 577 | for whats this bit 0x400000, or is this really the address? |
| 578 | maybe means add counter to address for access, |
| 579 | so allowing up or down copies, and reordering copies |
| 580 | |
| 581 | version 2: |
| 582 | cmd 0x30 used for this |
| 583 | */ |
| 584 | void c65_state::c65_dma_port_w( int offset, int value ) |
| 585 | { |
| 586 | PAIR pair, src, dst, len; |
| 587 | UINT8 cmd, fill; |
| 588 | int i; |
| 589 | address_space &space = m_maincpu->space(AS_PROGRAM); |
| 590 | |
| 591 | switch (offset & 3) |
| 592 | { |
| 593 | case 2: |
| 594 | case 1: |
| 595 | m_dma.data[offset & 3] = value; |
| 596 | break; |
| 597 | case 0: |
| 598 | pair.b.h3 = 0; |
| 599 | pair.b.h2 = m_dma.data[2]; |
| 600 | pair.b.h = m_dma.data[1]; |
| 601 | pair.b.l = m_dma.data[0]=value; |
| 602 | cmd = c65_read_mem(space, pair.d++); |
| 603 | len.w.h = 0; |
| 604 | len.b.l = c65_read_mem(space, pair.d++); |
| 605 | len.b.h = c65_read_mem(space, pair.d++); |
| 606 | src.b.h3 = 0; |
| 607 | fill = src.b.l = c65_read_mem(space, pair.d++); |
| 608 | src.b.h = c65_read_mem(space, pair.d++); |
| 609 | src.b.h2 = c65_read_mem(space, pair.d++); |
| 610 | dst.b.h3 = 0; |
| 611 | dst.b.l = c65_read_mem(space, pair.d++); |
| 612 | dst.b.h = c65_read_mem(space, pair.d++); |
| 613 | dst.b.h2 = c65_read_mem(space, pair.d++); |
| 614 | |
| 615 | switch (cmd) |
| 616 | { |
| 617 | case 0: |
| 618 | if (src.d == 0x3ffff) m_dump_dma = 1; |
| 619 | if (m_dump_dma) |
| 620 | DBG_LOG(space.machine(), 1,"dma copy job", |
| 621 | ("len:%.4x src:%.6x dst:%.6x sub:%.2x modrm:%.2x\n", |
| 622 | len.w.l, src.d, dst.d, c65_read_mem(space, pair.d), |
| 623 | c65_read_mem(space, pair.d + 1) ) ); |
| 624 | if ((m_dma.version == 1) |
| 625 | && ( (src.d&0x400000) || (dst.d & 0x400000))) |
| 626 | { |
| 627 | if (!(src.d & 0x400000)) |
| 628 | { |
| 629 | dst.d &= ~0x400000; |
| 630 | for (i = 0; i < len.w.l; i++) |
| 631 | c65_write_mem(space, dst.d--, c65_read_mem(space, src.d++)); |
| 632 | } |
| 633 | else if (!(dst.d & 0x400000)) |
| 634 | { |
| 635 | src.d &= ~0x400000; |
| 636 | for (i = 0; i < len.w.l; i++) |
| 637 | c65_write_mem(space, dst.d++, c65_read_mem(space, src.d--)); |
| 638 | } |
| 639 | else |
| 640 | { |
| 641 | src.d &= ~0x400000; |
| 642 | dst.d &= ~0x400000; |
| 643 | for (i = 0; i < len.w.l; i++) |
| 644 | c65_write_mem(space, --dst.d, c65_read_mem(space, --src.d)); |
| 645 | } |
| 646 | } |
| 647 | else |
| 648 | { |
| 649 | for (i = 0; i < len.w.l; i++) |
| 650 | c65_write_mem(space, dst.d++, c65_read_mem(space, src.d++)); |
| 651 | } |
| 652 | break; |
| 653 | case 3: |
| 654 | DBG_LOG(space.machine(), 3,"dma fill job", |
| 655 | ("len:%.4x value:%.2x dst:%.6x sub:%.2x modrm:%.2x\n", |
| 656 | len.w.l, fill, dst.d, c65_read_mem(space, pair.d), |
| 657 | c65_read_mem(space, pair.d + 1))); |
| 658 | for (i = 0; i < len.w.l; i++) |
| 659 | c65_write_mem(space, dst.d++, fill); |
| 660 | break; |
| 661 | case 0x30: |
| 662 | DBG_LOG(space.machine(), 1,"dma copy down", |
| 663 | ("len:%.4x src:%.6x dst:%.6x sub:%.2x modrm:%.2x\n", |
| 664 | len.w.l, src.d, dst.d, c65_read_mem(space, pair.d), |
| 665 | c65_read_mem(space, pair.d + 1) ) ); |
| 666 | for (i = 0; i < len.w.l; i++) |
| 667 | c65_write_mem(space, dst.d--,c65_read_mem(space, src.d--)); |
| 668 | break; |
| 669 | default: |
| 670 | DBG_LOG(space.machine(), 1,"dma job", |
| 671 | ("cmd:%.2x len:%.4x src:%.6x dst:%.6x sub:%.2x modrm:%.2x\n", |
| 672 | cmd,len.w.l, src.d, dst.d, c65_read_mem(space, pair.d), |
| 673 | c65_read_mem(space, pair.d + 1))); |
| 674 | } |
| 675 | break; |
| 676 | default: |
| 677 | DBG_LOG(space.machine(), 1, "dma chip write", ("%.3x %.2x\n", offset, value)); |
| 678 | break; |
| 679 | } |
| 680 | } |
| 681 | |
| 682 | int c65_state::c65_dma_port_r( int offset ) |
| 683 | { |
| 684 | /* offset 3 bit 7 in progress ? */ |
| 685 | DBG_LOG(machine(), 2, "dma chip read", ("%.3x\n", offset)); |
| 686 | return 0x7f; |
| 687 | } |
| 688 | |
| 689 | void c65_state::c65_6511_port_w( int offset, int value ) |
| 690 | { |
| 691 | if (offset == 7) |
| 692 | { |
| 693 | m_6511_port = value; |
| 694 | } |
| 695 | DBG_LOG(machine(), 2, "r6511 write", ("%.2x %.2x\n", offset, value)); |
| 696 | } |
| 697 | |
| 698 | int c65_state::c65_6511_port_r( int offset ) |
| 699 | { |
| 700 | int data = 0xff; |
| 701 | |
| 702 | if (offset == 7) |
| 703 | { |
| 704 | if (ioport("SPECIAL")->read() & 0x20) |
| 705 | data &= ~1; |
| 706 | } |
| 707 | DBG_LOG(machine(), 2, "r6511 read", ("%.2x\n", offset)); |
| 708 | |
| 709 | return data; |
| 710 | } |
| 711 | |
| 712 | /* one docu states custom 4191 disk controller |
| 713 | (for 2 1MB MFM disk drives, 1 internal, the other extern (optional) 1565 |
| 714 | with integrated 512 byte buffer |
| 715 | |
| 716 | 0->0 reset ? |
| 717 | |
| 718 | 0->1, 0->0, wait until 2 positiv, 1->0 ??? |
| 719 | |
| 720 | 0->0, 0 not 0 means no drive ???, other system entries |
| 721 | |
| 722 | |
| 723 | reg 0 write/read |
| 724 | 0,1 written |
| 725 | bit 1 set |
| 726 | bit 2 set |
| 727 | bit 3 set |
| 728 | bit 4 set |
| 729 | |
| 730 | |
| 731 | reg 0 read |
| 732 | bit 0 |
| 733 | bit 1 |
| 734 | bit 2 |
| 735 | 0..2 ->$1d4 |
| 736 | |
| 737 | reg 1 write |
| 738 | $01 written |
| 739 | $18 written |
| 740 | $46 written |
| 741 | $80 written |
| 742 | $a1 written |
| 743 | $01 written, dec |
| 744 | $10 written |
| 745 | |
| 746 | reg 2 read/write?(lsr) |
| 747 | bit 2 |
| 748 | bit 4 |
| 749 | bit 5 busy waiting until zero, then reading reg 7 |
| 750 | bit 6 operation not activ flag!? or set overflow pin used |
| 751 | bit 7 busy flag? |
| 752 | |
| 753 | reg 3 read/write?(rcr) |
| 754 | bit 1 |
| 755 | bit 3 |
| 756 | bit 7 busy flag? |
| 757 | |
| 758 | reg 4 |
| 759 | track?? |
| 760 | 0 written |
| 761 | read -> $1d2 |
| 762 | cmp #$50 |
| 763 | bcs |
| 764 | |
| 765 | |
| 766 | reg 5 |
| 767 | sector ?? |
| 768 | 1 written |
| 769 | read -> $1d3 |
| 770 | cmp #$b bcc |
| 771 | |
| 772 | |
| 773 | reg 6 |
| 774 | head ?? |
| 775 | 0 written |
| 776 | read -> $1d1 |
| 777 | cmp #2 bcc |
| 778 | |
| 779 | reg 7 read |
| 780 | #4e written |
| 781 | 12 times 0, a1 a1 a1 fe written |
| 782 | |
| 783 | reg 8 read |
| 784 | #ff written |
| 785 | 16 times #ff written |
| 786 | |
| 787 | reg 9 |
| 788 | #60 written |
| 789 | |
| 790 | might use the set overflow input |
| 791 | |
| 792 | $21a6c 9a6c format |
| 793 | $21c97 9c97 write operation |
| 794 | $21ca0 9ca0 get byte? |
| 795 | $21cab 9cab read reg 7 |
| 796 | $21caf 9caf write reg 7 |
| 797 | $21cb3 |
| 798 | */ |
| 799 | |
| 800 | #define FDC_LOST 4 |
| 801 | #define FDC_CRC 8 |
| 802 | #define FDC_RNF 0x10 |
| 803 | #define FDC_BUSY 0x80 |
| 804 | #define FDC_IRQ 0x200 |
| 805 | |
| 806 | #define FDC_CMD_MOTOR_SPIN_UP 0x10 |
| 807 | |
| 808 | #if 0 |
| 809 | void c65_state::c65_fdc_state(void) |
| 810 | { |
| 811 | switch (m_fdc.state) |
| 812 | { |
| 813 | case FDC_CMD_MOTOR_SPIN_UP: |
| 814 | if (machine().time() - m_fdc.time) |
| 815 | { |
| 816 | m_fdc.state = 0; |
| 817 | m_fdc.status &= ~FDC_BUSY; |
| 818 | } |
| 819 | break; |
| 820 | } |
| 821 | } |
| 822 | #endif |
| 823 | |
| 824 | void c65_state::c65_fdc_w( int offset, int data ) |
| 825 | { |
| 826 | DBG_LOG(machine(), 1, "fdc write", ("%.5x %.2x %.2x\n", machine().device("maincpu")->safe_pc(), offset, data)); |
| 827 | switch (offset & 0xf) |
| 828 | { |
| 829 | case 0: |
| 830 | m_fdc.reg[0] = data; |
| 831 | break; |
| 832 | case 1: |
| 833 | m_fdc.reg[1] = data; |
| 834 | switch (data & 0xf9) |
| 835 | { |
| 836 | case 0x20: // wait for motor spin up |
| 837 | m_fdc.status &= ~(FDC_IRQ|FDC_LOST|FDC_CRC|FDC_RNF); |
| 838 | m_fdc.status |= FDC_BUSY; |
| 839 | m_fdc.time = machine().time(); |
| 840 | m_fdc.state = FDC_CMD_MOTOR_SPIN_UP; |
| 841 | break; |
| 842 | case 0: // cancel |
| 843 | m_fdc.status &= ~(FDC_BUSY); |
| 844 | m_fdc.state = 0; |
| 845 | break; |
| 846 | case 0x80: // buffered write |
| 847 | case 0x40: // buffered read |
| 848 | case 0x81: // unbuffered write |
| 849 | case 0x41: // unbuffered read |
| 850 | case 0x30:case 0x31: // step |
| 851 | break; |
| 852 | } |
| 853 | break; |
| 854 | case 2: case 3: // read only |
| 855 | break; |
| 856 | case 4: |
| 857 | m_fdc.reg[offset & 0xf] = data; |
| 858 | m_fdc.track = data; |
| 859 | break; |
| 860 | case 5: |
| 861 | m_fdc.reg[offset & 0xf] = data; |
| 862 | m_fdc.sector = data; |
| 863 | break; |
| 864 | case 6: |
| 865 | m_fdc.reg[offset & 0xf] = data; |
| 866 | m_fdc.head = data; |
| 867 | break; |
| 868 | case 7: |
| 869 | m_fdc.buffer[m_fdc.cpu_pos++] = data; |
| 870 | break; |
| 871 | default: |
| 872 | m_fdc.reg[offset & 0xf] = data; |
| 873 | break; |
| 874 | } |
| 875 | } |
| 876 | |
| 877 | int c65_state::c65_fdc_r( int offset ) |
| 878 | { |
| 879 | UINT8 data = 0; |
| 880 | switch (offset & 0xf) |
| 881 | { |
| 882 | case 0: |
| 883 | data = m_fdc.reg[0]; |
| 884 | break; |
| 885 | case 1: |
| 886 | data = m_fdc.reg[1]; |
| 887 | break; |
| 888 | case 2: |
| 889 | data = m_fdc.status; |
| 890 | break; |
| 891 | case 3: |
| 892 | data = m_fdc.status >> 8; |
| 893 | break; |
| 894 | case 4: |
| 895 | data = m_fdc.track; |
| 896 | break; |
| 897 | case 5: |
| 898 | data = m_fdc.sector; |
| 899 | break; |
| 900 | case 6: |
| 901 | data = m_fdc.head; |
| 902 | break; |
| 903 | case 7: |
| 904 | data = m_fdc.buffer[m_fdc.cpu_pos++]; |
| 905 | break; |
| 906 | default: |
| 907 | data = m_fdc.reg[offset & 0xf]; |
| 908 | break; |
| 909 | } |
| 910 | DBG_LOG(machine(), 1, "fdc read", ("%.5x %.2x %.2x\n", machine().device("maincpu")->safe_pc(), offset, data)); |
| 911 | return data; |
| 912 | } |
| 913 | |
| 914 | /* version 1 ramcheck |
| 915 | write 0:0 |
| 916 | read write read write 80000,90000,f0000 |
| 917 | write 0:8 |
| 918 | read write read write 80000,90000,f0000 |
| 919 | |
| 920 | version 2 ramcheck??? |
| 921 | read 0: |
| 922 | write 0:0 |
| 923 | read 0: |
| 924 | first read and second read bit 0x80 set --> nothing |
| 925 | write 0:0 |
| 926 | read 0 |
| 927 | write 0:ff |
| 928 | */ |
| 929 | |
| 930 | READ8_MEMBER( c65_state::c65_ram_expansion_r ) |
| 931 | { |
| 932 | UINT8 data = 0xff; |
| 933 | if (m_ram->size() > (128 * 1024)) |
| 934 | data = m_expansion_ram.reg; |
| 935 | return data; |
| 936 | } |
| 937 | |
| 938 | WRITE8_MEMBER( c65_state::c65_ram_expansion_w ) |
| 939 | { |
| 940 | offs_t expansion_ram_begin; |
| 941 | offs_t expansion_ram_end; |
| 942 | |
| 943 | if (m_ram->size() > (128 * 1024)) |
| 944 | { |
| 945 | m_expansion_ram.reg = data; |
| 946 | |
| 947 | expansion_ram_begin = 0x80000; |
| 948 | expansion_ram_end = 0x80000 + (m_ram->size() - 128*1024) - 1; |
| 949 | |
| 950 | if (data == 0x00) { |
| 951 | space.install_readwrite_bank(expansion_ram_begin, expansion_ram_end,"bank16"); |
| 952 | membank("bank16")->set_base(m_ram->pointer() + 128*1024); |
| 953 | } else { |
| 954 | space.nop_readwrite(expansion_ram_begin, expansion_ram_end); |
| 955 | } |
| 956 | } |
| 957 | } |
| 958 | |
| 959 | WRITE8_MEMBER( c65_state::c65_write_io ) |
| 960 | { |
| 961 | mos6581_device *sid_0 = machine().device<mos6581_device>("sid_r"); |
| 962 | mos6581_device *sid_1 = machine().device<mos6581_device>("sid_l"); |
| 963 | vic3_device *vic3 = machine().device<vic3_device>("vic3"); |
| 964 | |
| 965 | switch (offset & 0xf00) |
| 966 | { |
| 967 | case 0x000: |
| 968 | if (offset < 0x80) |
| 969 | vic3->port_w(space, offset & 0x7f, data); |
| 970 | else if (offset < 0xa0) |
| 971 | c65_fdc_w(offset & 0x1f, data); |
| 972 | else |
| 973 | { |
| 974 | c65_ram_expansion_w(space, offset & 0x1f, data, mem_mask); |
| 975 | /*ram expansion crtl optional */ |
| 976 | } |
| 977 | break; |
| 978 | case 0x100: |
| 979 | case 0x200: |
| 980 | case 0x300: |
| 981 | vic3->palette_w(space, offset - 0x100, data); |
| 982 | break; |
| 983 | case 0x400: |
| 984 | if (offset<0x420) /* maybe 0x20 */ |
| 985 | sid_0->write(space, offset & 0x3f, data); |
| 986 | else if (offset<0x440) |
| 987 | sid_1->write(space, offset & 0x3f, data); |
| 988 | else |
| 989 | DBG_LOG(machine(), 1, "io write", ("%.3x %.2x\n", offset, data)); |
| 990 | break; |
| 991 | case 0x500: |
| 992 | DBG_LOG(machine(), 1, "io write", ("%.3x %.2x\n", offset, data)); |
| 993 | break; |
| 994 | case 0x600: |
| 995 | c65_6511_port_w(offset & 0xff,data); |
| 996 | break; |
| 997 | case 0x700: |
| 998 | c65_dma_port_w(offset & 0xff, data); |
| 999 | break; |
| 1000 | } |
| 1001 | } |
| 1002 | |
| 1003 | WRITE8_MEMBER( c65_state::c65_write_io_dc00 ) |
| 1004 | { |
| 1005 | switch (offset & 0xf00) |
| 1006 | { |
| 1007 | case 0x000: |
| 1008 | m_cia0->write(space, offset, data); |
| 1009 | break; |
| 1010 | case 0x100: |
| 1011 | m_cia1->write(space, offset, data); |
| 1012 | break; |
| 1013 | case 0x200: |
| 1014 | case 0x300: |
| 1015 | DBG_LOG(machine(), 1, "io write", ("%.3x %.2x\n", offset+0xc00, data)); |
| 1016 | break; |
| 1017 | } |
| 1018 | } |
| 1019 | |
| 1020 | READ8_MEMBER( c65_state::c65_read_io ) |
| 1021 | { |
| 1022 | mos6581_device *sid_0 = machine().device<mos6581_device>("sid_r"); |
| 1023 | mos6581_device *sid_1 = machine().device<mos6581_device>("sid_l"); |
| 1024 | vic3_device *vic3 = machine().device<vic3_device>("vic3"); |
| 1025 | |
| 1026 | switch (offset & 0xf00) |
| 1027 | { |
| 1028 | case 0x000: |
| 1029 | if (offset < 0x80) |
| 1030 | return vic3->port_r(space, offset & 0x7f); |
| 1031 | if (offset < 0xa0) |
| 1032 | return c65_fdc_r(offset & 0x1f); |
| 1033 | else |
| 1034 | { |
| 1035 | return c65_ram_expansion_r(space, offset & 0x1f, mem_mask); |
| 1036 | /*return; ram expansion crtl optional */ |
| 1037 | } |
| 1038 | case 0x100: |
| 1039 | case 0x200: |
| 1040 | case 0x300: |
| 1041 | /* read only !? */ |
| 1042 | DBG_LOG(machine(), 1, "io read", ("%.3x\n", offset)); |
| 1043 | break; |
| 1044 | case 0x400: |
| 1045 | if (offset < 0x420) |
| 1046 | return sid_0->read(space, offset & 0x3f); |
| 1047 | if (offset < 0x440) |
| 1048 | return sid_1->read(space, offset & 0x3f); |
| 1049 | DBG_LOG(machine(), 1, "io read", ("%.3x\n", offset)); |
| 1050 | break; |
| 1051 | case 0x500: |
| 1052 | DBG_LOG(machine(), 1, "io read", ("%.3x\n", offset)); |
| 1053 | break; |
| 1054 | case 0x600: |
| 1055 | return c65_6511_port_r(offset&0xff); |
| 1056 | case 0x700: |
| 1057 | return c65_dma_port_r(offset&0xff); |
| 1058 | } |
| 1059 | return 0xff; |
| 1060 | } |
| 1061 | |
| 1062 | READ8_MEMBER( c65_state::c65_read_io_dc00 ) |
| 1063 | { |
| 1064 | switch (offset & 0x300) |
| 1065 | { |
| 1066 | case 0x000: |
| 1067 | return m_cia0->read(space, offset); |
| 1068 | case 0x100: |
| 1069 | return m_cia1->read(space, offset); |
| 1070 | case 0x200: |
| 1071 | case 0x300: |
| 1072 | DBG_LOG(machine(), 1, "io read", ("%.3x\n", offset+0xc00)); |
| 1073 | break; |
| 1074 | } |
| 1075 | return 0xff; |
| 1076 | } |
| 1077 | |
| 1078 | |
| 1079 | /* |
| 1080 | d02f: |
| 1081 | init a5 96 written (seems to be switch to c65 or vic3 mode) |
| 1082 | go64 0 written |
| 1083 | */ |
| 1084 | |
| 1085 | /* bit 1 external sync enable (genlock) |
| 1086 | bit 2 palette enable |
| 1087 | bit 6 vic3 c65 character set */ |
| 1088 | WRITE8_MEMBER(c65_state::c65_bankswitch_interface) |
| 1089 | { |
| 1090 | DBG_LOG(machine(), 2, "c65 bankswitch", ("%.2x\n",data)); |
| 1091 | |
| 1092 | if (m_io_on) |
| 1093 | { |
| 1094 | if (data & 1) |
| 1095 | { |
| 1096 | membank("bank8")->set_base(m_colorram + 0x400); |
| 1097 | membank("bank9")->set_base(m_colorram + 0x400); |
| 1098 | m_maincpu->space(AS_PROGRAM).install_read_bank(0x0dc00, 0x0dfff, "bank8"); |
| 1099 | m_maincpu->space(AS_PROGRAM).install_write_bank(0x0dc00, 0x0dfff, "bank9"); |
| 1100 | } |
| 1101 | else |
| 1102 | { |
| 1103 | m_maincpu->space(AS_PROGRAM).install_read_handler(0x0dc00, 0x0dfff, read8_delegate(FUNC(c65_state::c65_read_io_dc00),this)); |
| 1104 | m_maincpu->space(AS_PROGRAM).install_write_handler(0x0dc00, 0x0dfff, write8_delegate(FUNC(c65_state::c65_write_io_dc00),this)); |
| 1105 | } |
| 1106 | } |
| 1107 | |
| 1108 | m_io_dc00_on = !(data & 1); |
| 1109 | #if 0 |
| 1110 | /* cartridge roms !?*/ |
| 1111 | if (data & 0x08) |
| 1112 | membank("bank1")->set_base(m_roml); |
| 1113 | else |
| 1114 | membank("bank1")->set_base(m_memory + 0x8000); |
| 1115 | |
| 1116 | if (data & 0x10) |
| 1117 | membank("bank2")->set_base(m_basic); |
| 1118 | else |
| 1119 | membank("bank2")->set_base(m_memory + 0xa000); |
| 1120 | #endif |
| 1121 | if ((m_old_value^data) & 0x20) |
| 1122 | { |
| 1123 | /* bankswitching faulty when doing actual page */ |
| 1124 | if (data & 0x20) |
| 1125 | membank("bank3")->set_base(m_basic); |
| 1126 | else |
| 1127 | membank("bank3")->set_base(m_memory + 0xc000); |
| 1128 | } |
| 1129 | m_charset_select = data & 0x40; |
| 1130 | #if 0 |
| 1131 | /* cartridge roms !?*/ |
| 1132 | if (data & 0x80) |
| 1133 | membank("bank8")->set_base(m_kernal); |
| 1134 | else |
| 1135 | membank("bank6")->set_base(m_memory + 0xe000); |
| 1136 | #endif |
| 1137 | m_old_value = data; |
| 1138 | } |
| 1139 | |
| 1140 | void c65_state::c65_bankswitch( ) |
| 1141 | { |
| 1142 | int data, loram, hiram, charen; |
| 1143 | |
| 1144 | data = 0x00; // machine().device<m4510_device>("maincpu")->get_port(); |
| 1145 | if (data == m_old_data) |
| 1146 | return; |
| 1147 | |
| 1148 | DBG_LOG(machine(), 1, "bankswitch", ("%d\n", data & 7)); |
| 1149 | loram = (data & 1) ? 1 : 0; |
| 1150 | hiram = (data & 2) ? 1 : 0; |
| 1151 | charen = (data & 4) ? 1 : 0; |
| 1152 | |
| 1153 | if ((!m_game && m_exrom) || (loram && hiram && !m_exrom)) |
| 1154 | membank("bank1")->set_base(m_roml); |
| 1155 | else |
| 1156 | membank("bank1")->set_base(m_memory + 0x8000); |
| 1157 | |
| 1158 | if ((!m_game && m_exrom && hiram) || (!m_exrom)) |
| 1159 | membank("bank2")->set_base(m_romh); |
| 1160 | else if (loram && hiram) |
| 1161 | membank("bank2")->set_base(m_basic); |
| 1162 | else |
| 1163 | membank("bank2")->set_base(m_memory + 0xa000); |
| 1164 | |
| 1165 | if ((!m_game && m_exrom) || (charen && (loram || hiram))) |
| 1166 | { |
| 1167 | m_io_on = 1; |
| 1168 | membank("bank6")->set_base(m_colorram); |
| 1169 | membank("bank7")->set_base(m_colorram); |
| 1170 | |
| 1171 | if (m_io_dc00_on) |
| 1172 | { |
| 1173 | m_maincpu->space(AS_PROGRAM).install_read_handler(0x0dc00, 0x0dfff, read8_delegate(FUNC(c65_state::c65_read_io_dc00),this)); |
| 1174 | m_maincpu->space(AS_PROGRAM).install_write_handler(0x0dc00, 0x0dfff, write8_delegate(FUNC(c65_state::c65_write_io_dc00),this)); |
| 1175 | } |
| 1176 | else |
| 1177 | { |
| 1178 | m_maincpu->space(AS_PROGRAM).install_read_bank(0x0dc00, 0x0dfff, "bank8"); |
| 1179 | m_maincpu->space(AS_PROGRAM).install_write_bank(0x0dc00, 0x0dfff, "bank9"); |
| 1180 | membank("bank8")->set_base(m_colorram + 0x400); |
| 1181 | membank("bank9")->set_base(m_colorram + 0x400); |
| 1182 | } |
| 1183 | m_maincpu->space(AS_PROGRAM).install_read_handler(0x0d000, 0x0d7ff, read8_delegate(FUNC(c65_state::c65_read_io),this)); |
| 1184 | m_maincpu->space(AS_PROGRAM).install_write_handler(0x0d000, 0x0d7ff, write8_delegate(FUNC(c65_state::c65_write_io),this)); |
| 1185 | } |
| 1186 | else |
| 1187 | { |
| 1188 | m_io_on = 0; |
| 1189 | membank("bank5")->set_base(m_memory + 0xd000); |
| 1190 | membank("bank7")->set_base(m_memory + 0xd800); |
| 1191 | membank("bank9")->set_base(m_memory + 0xdc00); |
| 1192 | if (!charen && (loram || hiram)) |
| 1193 | { |
| 1194 | membank("bank4")->set_base(m_chargen); |
| 1195 | membank("bank6")->set_base(m_chargen + 0x800); |
| 1196 | membank("bank8")->set_base(m_chargen + 0xc00); |
| 1197 | } |
| 1198 | else |
| 1199 | { |
| 1200 | membank("bank4")->set_base(m_memory + 0xd000); |
| 1201 | membank("bank6")->set_base(m_memory + 0xd800); |
| 1202 | membank("bank8")->set_base(m_memory + 0xdc00); |
| 1203 | } |
| 1204 | m_maincpu->space(AS_PROGRAM).install_read_bank(0x0d000, 0x0d7ff, "bank4"); |
| 1205 | m_maincpu->space(AS_PROGRAM).install_write_bank(0x0d000, 0x0d7ff, "bank5"); |
| 1206 | } |
| 1207 | |
| 1208 | if (!m_game && m_exrom) |
| 1209 | { |
| 1210 | membank("bank10")->set_base(m_romh); |
| 1211 | } |
| 1212 | else |
| 1213 | { |
| 1214 | if (hiram) |
| 1215 | { |
| 1216 | membank("bank10")->set_base(m_kernal); |
| 1217 | } |
| 1218 | else |
| 1219 | { |
| 1220 | membank("bank10")->set_base(m_memory + 0xe000); |
| 1221 | } |
| 1222 | } |
| 1223 | m_old_data = data; |
| 1224 | } |
| 1225 | |
| 1226 | #ifdef UNUSED_FUNCTION |
| 1227 | void c65_state::c65_colorram_write( int offset, int value ) |
| 1228 | { |
| 1229 | m_colorram[offset & 0x7ff] = value | 0xf0; |
| 1230 | } |
| 1231 | #endif |
| 1232 | |
| 1233 | /* |
| 1234 | * only 14 address lines |
| 1235 | * a15 and a14 portlines |
| 1236 | * 0x1000-0x1fff, 0x9000-0x9fff char rom |
| 1237 | */ |
| 1238 | READ8_MEMBER(c65_state::c65_dma_read) |
| 1239 | { |
| 1240 | if (!m_game && m_exrom) |
| 1241 | { |
| 1242 | if (offset < 0x3000) |
| 1243 | return m_memory[offset]; |
| 1244 | return m_romh[offset & 0x1fff]; |
| 1245 | } |
| 1246 | if ((m_vicaddr == m_memory) || (m_vicaddr == m_memory + 0x8000)) |
| 1247 | { |
| 1248 | if (offset < 0x1000) |
| 1249 | return m_vicaddr[offset & 0x3fff]; |
| 1250 | if (offset < 0x2000) { |
| 1251 | if (m_charset_select) |
| 1252 | return m_chargen[offset & 0xfff]; |
| 1253 | else |
| 1254 | return m_chargen[offset & 0xfff]; |
| 1255 | } |
| 1256 | return m_vicaddr[offset & 0x3fff]; |
| 1257 | } |
| 1258 | return m_vicaddr[offset & 0x3fff]; |
| 1259 | } |
| 1260 | |
| 1261 | READ8_MEMBER(c65_state::c65_dma_read_color) |
| 1262 | { |
| 1263 | if (m_c64mode) |
| 1264 | return m_colorram[offset & 0x3ff] & 0xf; |
| 1265 | return m_colorram[offset & 0x7ff]; |
| 1266 | } |
| 1267 | |
| 1268 | void c65_state::c65_common_driver_init( ) |
| 1269 | { |
| 1270 | m_memory = auto_alloc_array_clear(machine(), UINT8, 0x10000); |
| 1271 | membank("bank11")->set_base(m_memory + 0x00000); |
| 1272 | membank("bank12")->set_base(m_memory + 0x08000); |
| 1273 | membank("bank13")->set_base(m_memory + 0x0a000); |
| 1274 | membank("bank14")->set_base(m_memory + 0x0c000); |
| 1275 | membank("bank15")->set_base(m_memory + 0x0e000); |
| 1276 | |
| 1277 | cbm_common_init(); |
| 1278 | m_keyline = 0xff; |
| 1279 | |
| 1280 | m_pal = 0; |
| 1281 | m_charset_select = 0; |
| 1282 | m_6511_port = 0xff; |
| 1283 | m_vicirq = 0; |
| 1284 | m_old_data = -1; |
| 1285 | |
| 1286 | /* C65 had no datasette port */ |
| 1287 | m_tape_on = 0; |
| 1288 | m_game = 1; |
| 1289 | m_exrom = 1; |
| 1290 | |
| 1291 | /*memset(m_memory + 0x40000, 0, 0x800000 - 0x40000); */ |
| 1292 | } |
| 1293 | |
| 1294 | DRIVER_INIT_MEMBER(c65_state,c65) |
| 1295 | { |
| 1296 | m_dma.version = 2; |
| 1297 | c65_common_driver_init(); |
| 1298 | } |
| 1299 | |
| 1300 | DRIVER_INIT_MEMBER(c65_state,c65pal) |
| 1301 | { |
| 1302 | m_dma.version = 1; |
| 1303 | c65_common_driver_init(); |
| 1304 | m_pal = 1; |
| 1305 | } |
| 1306 | |
| 1307 | MACHINE_START_MEMBER(c65_state,c65) |
| 1308 | { |
| 1309 | /* clear upper memory */ |
| 1310 | memset(m_ram->pointer() + 128*1024, 0xff, m_ram->size() - 128*1024); |
| 1311 | |
| 1312 | //removed cbm_drive_0_config (SERIAL, 10); |
| 1313 | //removed cbm_drive_1_config (SERIAL, 11); |
| 1314 | m_vicaddr = m_memory; |
| 1315 | |
| 1316 | m_c64mode = 0; |
| 1317 | |
| 1318 | c65_bankswitch_interface(m_maincpu->space(AS_PROGRAM),0,0xff); |
| 1319 | c65_bankswitch(); |
| 1320 | } |
| 1321 | |
| 1322 | |
| 1323 | INTERRUPT_GEN_MEMBER(c65_state::c65_frame_interrupt) |
| 1324 | { |
| 1325 | int value; |
| 1326 | |
| 1327 | c65_nmi(); |
| 1328 | |
| 1329 | /* common keys input ports */ |
| 1330 | cbm_common_interrupt(&device); |
| 1331 | |
| 1332 | /* c65 specific: function keys input ports */ |
| 1333 | value = 0xff; |
| 1334 | |
| 1335 | value &= ~ioport("FUNCT")->read(); |
| 1336 | m_keyline = value; |
| 1337 | } |
trunk/src/mess/machine/c65_old.c
| r243230 | r243231 | |
| 1 | | /*************************************************************************** |
| 2 | | commodore c65 home computer |
| 3 | | peter.trauner@jk.uni-linz.ac.at |
| 4 | | documention |
| 5 | | www.funet.fi |
| 6 | | ***************************************************************************/ |
| 7 | | |
| 8 | | #include "emu.h" |
| 9 | | |
| 10 | | #include "includes/c65.h" |
| 11 | | #include "cpu/m6502/m4510.h" |
| 12 | | #include "sound/mos6581.h" |
| 13 | | #include "machine/mos6526.h" |
| 14 | | #include "bus/cbmiec/cbmiec.h" |
| 15 | | #include "machine/ram.h" |
| 16 | | #include "video/vic4567.h" |
| 17 | | #include "imagedev/cassette.h" |
| 18 | | #include "crsshair.h" |
| 19 | | #include "formats/cbm_tap.h" |
| 20 | | |
| 21 | | #define VERBOSE_LEVEL 0 |
| 22 | | #define DBG_LOG( MACHINE, N, M, A ) \ |
| 23 | | do { \ |
| 24 | | if(VERBOSE_LEVEL >= N) \ |
| 25 | | { \ |
| 26 | | if( M ) \ |
| 27 | | logerror("%11.6f: %-24s", MACHINE.time().as_double(), (char*) M ); \ |
| 28 | | logerror A; \ |
| 29 | | } \ |
| 30 | | } while (0) |
| 31 | | |
| 32 | | |
| 33 | | |
| 34 | | /*********************************************** |
| 35 | | |
| 36 | | Input Reading - Common Components |
| 37 | | |
| 38 | | ***********************************************/ |
| 39 | | |
| 40 | | /* These are needed by c64, c65 and c128, each machine has also additional specific |
| 41 | | components in its INTERRUPT_GEN */ |
| 42 | | |
| 43 | | /* keyboard lines */ |
| 44 | | UINT8 c64_keyline[10]; |
| 45 | | |
| 46 | | void cbm_common_init(void) |
| 47 | | { |
| 48 | | int i; |
| 49 | | |
| 50 | | for (i = 0; i < ARRAY_LENGTH(c64_keyline); i++) |
| 51 | | c64_keyline[i] = 0xff; |
| 52 | | } |
| 53 | | |
| 54 | | static TIMER_CALLBACK( lightpen_tick ) |
| 55 | | { |
| 56 | | if (((machine.root_device().ioport("CTRLSEL")->read() & 0x07) == 0x04) || ((machine.root_device().ioport("CTRLSEL")->read() & 0x07) == 0x06)) |
| 57 | | { |
| 58 | | /* enable lightpen crosshair */ |
| 59 | | crosshair_set_screen(machine, 0, CROSSHAIR_SCREEN_ALL); |
| 60 | | } |
| 61 | | else |
| 62 | | { |
| 63 | | /* disable lightpen crosshair */ |
| 64 | | crosshair_set_screen(machine, 0, CROSSHAIR_SCREEN_NONE); |
| 65 | | } |
| 66 | | } |
| 67 | | |
| 68 | | void cbm_common_interrupt( device_t *device ) |
| 69 | | { |
| 70 | | int value, i; |
| 71 | | int controller1 = device->machine().root_device().ioport("CTRLSEL")->read() & 0x07; |
| 72 | | int controller2 = device->machine().root_device().ioport("CTRLSEL")->read() & 0x70; |
| 73 | | static const char *const c64ports[] = { "ROW0", "ROW1", "ROW2", "ROW3", "ROW4", "ROW5", "ROW6", "ROW7" }; |
| 74 | | |
| 75 | | /* Lines 0-7 : common keyboard */ |
| 76 | | for (i = 0; i < 8; i++) |
| 77 | | { |
| 78 | | value = 0xff; |
| 79 | | value &= ~device->machine().root_device().ioport(c64ports[i])->read(); |
| 80 | | |
| 81 | | /* Shift Lock is mapped on Left Shift */ |
| 82 | | if ((i == 1) && (device->machine().root_device().ioport("SPECIAL")->read() & 0x40)) |
| 83 | | value &= ~0x80; |
| 84 | | |
| 85 | | c64_keyline[i] = value; |
| 86 | | } |
| 87 | | |
| 88 | | |
| 89 | | value = 0xff; |
| 90 | | switch(controller1) |
| 91 | | { |
| 92 | | case 0x00: |
| 93 | | value &= ~device->machine().root_device().ioport("JOY1_1B")->read(); /* Joy1 Directions + Button 1 */ |
| 94 | | break; |
| 95 | | |
| 96 | | case 0x01: |
| 97 | | if (device->machine().root_device().ioport("OTHER")->read() & 0x40) /* Paddle2 Button */ |
| 98 | | value &= ~0x08; |
| 99 | | if (device->machine().root_device().ioport("OTHER")->read() & 0x80) /* Paddle1 Button */ |
| 100 | | value &= ~0x04; |
| 101 | | break; |
| 102 | | |
| 103 | | case 0x02: |
| 104 | | if (device->machine().root_device().ioport("OTHER")->read() & 0x02) /* Mouse Button Left */ |
| 105 | | value &= ~0x10; |
| 106 | | if (device->machine().root_device().ioport("OTHER")->read() & 0x01) /* Mouse Button Right */ |
| 107 | | value &= ~0x01; |
| 108 | | break; |
| 109 | | |
| 110 | | case 0x03: |
| 111 | | value &= ~(device->machine().root_device().ioport("JOY1_2B")->read() & 0x1f); /* Joy1 Directions + Button 1 */ |
| 112 | | break; |
| 113 | | |
| 114 | | case 0x04: |
| 115 | | /* was there any input on the lightpen? where is it mapped? */ |
| 116 | | // if (device->machine().root_device().ioport("OTHER")->read() & 0x04) /* Lightpen Signal */ |
| 117 | | // value &= ?? ; |
| 118 | | break; |
| 119 | | |
| 120 | | case 0x07: |
| 121 | | break; |
| 122 | | |
| 123 | | default: |
| 124 | | logerror("Invalid Controller 1 Setting %d\n", controller1); |
| 125 | | break; |
| 126 | | } |
| 127 | | |
| 128 | | c64_keyline[8] = value; |
| 129 | | |
| 130 | | |
| 131 | | value = 0xff; |
| 132 | | switch(controller2) |
| 133 | | { |
| 134 | | case 0x00: |
| 135 | | value &= ~device->machine().root_device().ioport("JOY2_1B")->read(); /* Joy2 Directions + Button 1 */ |
| 136 | | break; |
| 137 | | |
| 138 | | case 0x10: |
| 139 | | if (device->machine().root_device().ioport("OTHER")->read() & 0x10) /* Paddle4 Button */ |
| 140 | | value &= ~0x08; |
| 141 | | if (device->machine().root_device().ioport("OTHER")->read() & 0x20) /* Paddle3 Button */ |
| 142 | | value &= ~0x04; |
| 143 | | break; |
| 144 | | |
| 145 | | case 0x20: |
| 146 | | if (device->machine().root_device().ioport("OTHER")->read() & 0x02) /* Mouse Button Left */ |
| 147 | | value &= ~0x10; |
| 148 | | if (device->machine().root_device().ioport("OTHER")->read() & 0x01) /* Mouse Button Right */ |
| 149 | | value &= ~0x01; |
| 150 | | break; |
| 151 | | |
| 152 | | case 0x30: |
| 153 | | value &= ~(device->machine().root_device().ioport("JOY2_2B")->read() & 0x1f); /* Joy2 Directions + Button 1 */ |
| 154 | | break; |
| 155 | | |
| 156 | | case 0x40: |
| 157 | | /* was there any input on the lightpen? where is it mapped? */ |
| 158 | | // if (device->machine().root_device().ioport("OTHER")->read() & 0x04) /* Lightpen Signal */ |
| 159 | | // value &= ?? ; |
| 160 | | break; |
| 161 | | |
| 162 | | case 0x70: |
| 163 | | break; |
| 164 | | |
| 165 | | default: |
| 166 | | logerror("Invalid Controller 2 Setting %d\n", controller2); |
| 167 | | break; |
| 168 | | } |
| 169 | | |
| 170 | | c64_keyline[9] = value; |
| 171 | | |
| 172 | | // vic2_frame_interrupt does nothing so this is not necessary |
| 173 | | // vic2_frame_interrupt (device); |
| 174 | | |
| 175 | | /* check if lightpen has been chosen as input: if so, enable crosshair */ |
| 176 | | device->machine().scheduler().timer_set(attotime::zero, FUNC(lightpen_tick)); |
| 177 | | |
| 178 | | set_led_status (device->machine(), 1, device->machine().root_device().ioport("SPECIAL")->read() & 0x40 ? 1 : 0); /* Shift Lock */ |
| 179 | | set_led_status (device->machine(), 0, device->machine().root_device().ioport("CTRLSEL")->read() & 0x80 ? 1 : 0); /* Joystick Swap */ |
| 180 | | } |
| 181 | | |
| 182 | | |
| 183 | | /*********************************************** |
| 184 | | |
| 185 | | CIA Common Handlers |
| 186 | | |
| 187 | | ***********************************************/ |
| 188 | | |
| 189 | | /* These are shared by c64, c65 and c128. c65 and c128 also have additional specific |
| 190 | | components (to select/read additional keyboard lines) */ |
| 191 | | |
| 192 | | /* |
| 193 | | * CIA 0 - Port A |
| 194 | | * bits 7-0 keyboard line select |
| 195 | | * bits 7,6: paddle select( 01 port a, 10 port b) |
| 196 | | * bit 4: joystick a fire button |
| 197 | | * bits 3,2: Paddles port a fire button |
| 198 | | * bits 3-0: joystick a direction |
| 199 | | * |
| 200 | | * CIA 0 - Port B |
| 201 | | * bits 7-0: keyboard raw values |
| 202 | | * bit 4: joystick b fire button, lightpen select |
| 203 | | * bits 3,2: paddle b fire buttons (left,right) |
| 204 | | * bits 3-0: joystick b direction |
| 205 | | * |
| 206 | | * flag cassette read input, serial request in |
| 207 | | * irq to irq connected |
| 208 | | */ |
| 209 | | |
| 210 | | UINT8 cbm_common_cia0_port_a_r( device_t *device, UINT8 output_b ) |
| 211 | | { |
| 212 | | UINT8 value = 0xff; |
| 213 | | |
| 214 | | if (!(output_b & 0x80)) |
| 215 | | { |
| 216 | | UINT8 t = 0xff; |
| 217 | | if (!(c64_keyline[7] & 0x80)) t &= ~0x80; |
| 218 | | if (!(c64_keyline[6] & 0x80)) t &= ~0x40; |
| 219 | | if (!(c64_keyline[5] & 0x80)) t &= ~0x20; |
| 220 | | if (!(c64_keyline[4] & 0x80)) t &= ~0x10; |
| 221 | | if (!(c64_keyline[3] & 0x80)) t &= ~0x08; |
| 222 | | if (!(c64_keyline[2] & 0x80)) t &= ~0x04; |
| 223 | | if (!(c64_keyline[1] & 0x80)) t &= ~0x02; |
| 224 | | if (!(c64_keyline[0] & 0x80)) t &= ~0x01; |
| 225 | | value &= t; |
| 226 | | } |
| 227 | | |
| 228 | | if (!(output_b & 0x40)) |
| 229 | | { |
| 230 | | UINT8 t = 0xff; |
| 231 | | if (!(c64_keyline[7] & 0x40)) t &= ~0x80; |
| 232 | | if (!(c64_keyline[6] & 0x40)) t &= ~0x40; |
| 233 | | if (!(c64_keyline[5] & 0x40)) t &= ~0x20; |
| 234 | | if (!(c64_keyline[4] & 0x40)) t &= ~0x10; |
| 235 | | if (!(c64_keyline[3] & 0x40)) t &= ~0x08; |
| 236 | | if (!(c64_keyline[2] & 0x40)) t &= ~0x04; |
| 237 | | if (!(c64_keyline[1] & 0x40)) t &= ~0x02; |
| 238 | | if (!(c64_keyline[0] & 0x40)) t &= ~0x01; |
| 239 | | value &= t; |
| 240 | | } |
| 241 | | |
| 242 | | if (!(output_b & 0x20)) |
| 243 | | { |
| 244 | | UINT8 t = 0xff; |
| 245 | | if (!(c64_keyline[7] & 0x20)) t &= ~0x80; |
| 246 | | if (!(c64_keyline[6] & 0x20)) t &= ~0x40; |
| 247 | | if (!(c64_keyline[5] & 0x20)) t &= ~0x20; |
| 248 | | if (!(c64_keyline[4] & 0x20)) t &= ~0x10; |
| 249 | | if (!(c64_keyline[3] & 0x20)) t &= ~0x08; |
| 250 | | if (!(c64_keyline[2] & 0x20)) t &= ~0x04; |
| 251 | | if (!(c64_keyline[1] & 0x20)) t &= ~0x02; |
| 252 | | if (!(c64_keyline[0] & 0x20)) t &= ~0x01; |
| 253 | | value &= t; |
| 254 | | } |
| 255 | | |
| 256 | | if (!(output_b & 0x10)) |
| 257 | | { |
| 258 | | UINT8 t = 0xff; |
| 259 | | if (!(c64_keyline[7] & 0x10)) t &= ~0x80; |
| 260 | | if (!(c64_keyline[6] & 0x10)) t &= ~0x40; |
| 261 | | if (!(c64_keyline[5] & 0x10)) t &= ~0x20; |
| 262 | | if (!(c64_keyline[4] & 0x10)) t &= ~0x10; |
| 263 | | if (!(c64_keyline[3] & 0x10)) t &= ~0x08; |
| 264 | | if (!(c64_keyline[2] & 0x10)) t &= ~0x04; |
| 265 | | if (!(c64_keyline[1] & 0x10)) t &= ~0x02; |
| 266 | | if (!(c64_keyline[0] & 0x10)) t &= ~0x01; |
| 267 | | value &= t; |
| 268 | | } |
| 269 | | |
| 270 | | if (!(output_b & 0x08)) |
| 271 | | { |
| 272 | | UINT8 t = 0xff; |
| 273 | | if (!(c64_keyline[7] & 0x08)) t &= ~0x80; |
| 274 | | if (!(c64_keyline[6] & 0x08)) t &= ~0x40; |
| 275 | | if (!(c64_keyline[5] & 0x08)) t &= ~0x20; |
| 276 | | if (!(c64_keyline[4] & 0x08)) t &= ~0x10; |
| 277 | | if (!(c64_keyline[3] & 0x08)) t &= ~0x08; |
| 278 | | if (!(c64_keyline[2] & 0x08)) t &= ~0x04; |
| 279 | | if (!(c64_keyline[1] & 0x08)) t &= ~0x02; |
| 280 | | if (!(c64_keyline[0] & 0x08)) t &= ~0x01; |
| 281 | | value &= t; |
| 282 | | } |
| 283 | | |
| 284 | | if (!(output_b & 0x04)) |
| 285 | | { |
| 286 | | UINT8 t = 0xff; |
| 287 | | if (!(c64_keyline[7] & 0x04)) t &= ~0x80; |
| 288 | | if (!(c64_keyline[6] & 0x04)) t &= ~0x40; |
| 289 | | if (!(c64_keyline[5] & 0x04)) t &= ~0x20; |
| 290 | | if (!(c64_keyline[4] & 0x04)) t &= ~0x10; |
| 291 | | if (!(c64_keyline[3] & 0x04)) t &= ~0x08; |
| 292 | | if (!(c64_keyline[2] & 0x04)) t &= ~0x04; |
| 293 | | if (!(c64_keyline[1] & 0x04)) t &= ~0x02; |
| 294 | | if (!(c64_keyline[0] & 0x04)) t &= ~0x01; |
| 295 | | value &= t; |
| 296 | | } |
| 297 | | |
| 298 | | if (!(output_b & 0x02)) |
| 299 | | { |
| 300 | | UINT8 t = 0xff; |
| 301 | | if (!(c64_keyline[7] & 0x02)) t &= ~0x80; |
| 302 | | if (!(c64_keyline[6] & 0x02)) t &= ~0x40; |
| 303 | | if (!(c64_keyline[5] & 0x02)) t &= ~0x20; |
| 304 | | if (!(c64_keyline[4] & 0x02)) t &= ~0x10; |
| 305 | | if (!(c64_keyline[3] & 0x02)) t &= ~0x08; |
| 306 | | if (!(c64_keyline[2] & 0x02)) t &= ~0x04; |
| 307 | | if (!(c64_keyline[1] & 0x02)) t &= ~0x02; |
| 308 | | if (!(c64_keyline[0] & 0x02)) t &= ~0x01; |
| 309 | | value &= t; |
| 310 | | } |
| 311 | | |
| 312 | | if (!(output_b & 0x01)) |
| 313 | | { |
| 314 | | UINT8 t = 0xff; |
| 315 | | if (!(c64_keyline[7] & 0x01)) t &= ~0x80; |
| 316 | | if (!(c64_keyline[6] & 0x01)) t &= ~0x40; |
| 317 | | if (!(c64_keyline[5] & 0x01)) t &= ~0x20; |
| 318 | | if (!(c64_keyline[4] & 0x01)) t &= ~0x10; |
| 319 | | if (!(c64_keyline[3] & 0x01)) t &= ~0x08; |
| 320 | | if (!(c64_keyline[2] & 0x01)) t &= ~0x04; |
| 321 | | if (!(c64_keyline[1] & 0x01)) t &= ~0x02; |
| 322 | | if (!(c64_keyline[0] & 0x01)) t &= ~0x01; |
| 323 | | value &= t; |
| 324 | | } |
| 325 | | |
| 326 | | if ( device->machine().root_device().ioport("CTRLSEL")->read() & 0x80 ) |
| 327 | | value &= c64_keyline[8]; |
| 328 | | else |
| 329 | | value &= c64_keyline[9]; |
| 330 | | |
| 331 | | return value; |
| 332 | | } |
| 333 | | |
| 334 | | UINT8 cbm_common_cia0_port_b_r( device_t *device, UINT8 output_a ) |
| 335 | | { |
| 336 | | UINT8 value = 0xff; |
| 337 | | |
| 338 | | if (!(output_a & 0x80)) value &= c64_keyline[7]; |
| 339 | | if (!(output_a & 0x40)) value &= c64_keyline[6]; |
| 340 | | if (!(output_a & 0x20)) value &= c64_keyline[5]; |
| 341 | | if (!(output_a & 0x10)) value &= c64_keyline[4]; |
| 342 | | if (!(output_a & 0x08)) value &= c64_keyline[3]; |
| 343 | | if (!(output_a & 0x04)) value &= c64_keyline[2]; |
| 344 | | if (!(output_a & 0x02)) value &= c64_keyline[1]; |
| 345 | | if (!(output_a & 0x01)) value &= c64_keyline[0]; |
| 346 | | |
| 347 | | if ( device->machine().root_device().ioport("CTRLSEL")->read() & 0x80 ) |
| 348 | | value &= c64_keyline[9]; |
| 349 | | else |
| 350 | | value &= c64_keyline[8]; |
| 351 | | |
| 352 | | return value; |
| 353 | | } |
| 354 | | |
| 355 | | |
| 356 | | /*********************************************** |
| 357 | | |
| 358 | | CBM Cartridges |
| 359 | | |
| 360 | | ***********************************************/ |
| 361 | | |
| 362 | | |
| 363 | | /* All the cartridge specific code has been moved |
| 364 | | to machine/ drivers. Once more informations |
| 365 | | surface about the cart expansions for systems |
| 366 | | in c65.c, c128.c, cbmb.c and pet.c, the shared |
| 367 | | code could be refactored to have here the |
| 368 | | common functions */ |
| 369 | | |
| 370 | | |
| 371 | | |
| 372 | | /*********************************************** |
| 373 | | |
| 374 | | CBM Datasette Tapes |
| 375 | | |
| 376 | | ***********************************************/ |
| 377 | | |
| 378 | | #if 0 |
| 379 | | const cassette_interface cbm_cassette_interface = |
| 380 | | { |
| 381 | | cbm_cassette_formats, |
| 382 | | NULL, |
| 383 | | (cassette_state) (CASSETTE_STOPPED | CASSETTE_MOTOR_DISABLED | CASSETTE_SPEAKER_ENABLED), |
| 384 | | NULL |
| 385 | | }; |
| 386 | | #endif |
| 387 | | |
| 388 | | |
| 389 | | /*UINT8 *c65_basic; */ |
| 390 | | /*UINT8 *c65_kernal; */ |
| 391 | | /*UINT8 *c65_dos; */ |
| 392 | | /*UINT8 *c65_monitor; */ |
| 393 | | /*UINT8 *c65_graphics; */ |
| 394 | | |
| 395 | | |
| 396 | | void c65_state::c65_nmi( ) |
| 397 | | { |
| 398 | | if (m_nmilevel != (ioport("SPECIAL")->read() & 0x80) || m_cia1_irq) /* KEY_RESTORE */ |
| 399 | | { |
| 400 | | m_maincpu->set_input_line(INPUT_LINE_NMI, (ioport("SPECIAL")->read() & 0x80) || m_cia1_irq); |
| 401 | | |
| 402 | | m_nmilevel = (ioport("SPECIAL")->read() & 0x80) || m_cia1_irq; |
| 403 | | } |
| 404 | | } |
| 405 | | |
| 406 | | |
| 407 | | /*********************************************** |
| 408 | | |
| 409 | | CIA Interfaces |
| 410 | | |
| 411 | | ***********************************************/ |
| 412 | | |
| 413 | | /* |
| 414 | | * CIA 0 - Port A keyboard line select |
| 415 | | * CIA 0 - Port B keyboard line read |
| 416 | | * |
| 417 | | * flag cassette read input, serial request in |
| 418 | | * irq to irq connected |
| 419 | | * |
| 420 | | * see machine/cbm.c |
| 421 | | */ |
| 422 | | |
| 423 | | READ8_MEMBER(c65_state::c65_cia0_port_a_r) |
| 424 | | { |
| 425 | | UINT8 cia0portb = m_cia0->pb_r(space, 0); |
| 426 | | |
| 427 | | return cbm_common_cia0_port_a_r(m_cia0, cia0portb); |
| 428 | | } |
| 429 | | |
| 430 | | READ8_MEMBER(c65_state::c65_cia0_port_b_r) |
| 431 | | { |
| 432 | | UINT8 value = 0xff; |
| 433 | | UINT8 cia0porta = m_cia0->pa_r(space, 0); |
| 434 | | |
| 435 | | value &= cbm_common_cia0_port_b_r(m_cia0, cia0porta); |
| 436 | | |
| 437 | | if (!(m_6511_port & 0x02)) |
| 438 | | value &= m_keyline; |
| 439 | | |
| 440 | | return value; |
| 441 | | } |
| 442 | | |
| 443 | | WRITE8_MEMBER(c65_state::c65_cia0_port_b_w) |
| 444 | | { |
| 445 | | // was there lightpen support in c65 video chip? |
| 446 | | // vic3_device *vic3 = machine().device<vic3_device>("vic3"); |
| 447 | | // vic3->lightpen_write(data & 0x10); |
| 448 | | } |
| 449 | | |
| 450 | | void c65_state::c65_irq( int level ) |
| 451 | | { |
| 452 | | if (level != m_old_level) |
| 453 | | { |
| 454 | | DBG_LOG(machine(), 3, "mos4510", ("irq %s\n", level ? "start" : "end")); |
| 455 | | m_maincpu->set_input_line(M4510_IRQ_LINE, level); |
| 456 | | m_old_level = level; |
| 457 | | } |
| 458 | | } |
| 459 | | |
| 460 | | /* is this correct for c65 as well as c64? */ |
| 461 | | WRITE_LINE_MEMBER(c65_state::c65_cia0_interrupt) |
| 462 | | { |
| 463 | | m_cia0_irq = state; |
| 464 | | c65_irq(state || m_vicirq); |
| 465 | | } |
| 466 | | |
| 467 | | /* is this correct for c65 as well as c64? */ |
| 468 | | WRITE_LINE_MEMBER(c65_state::c65_vic_interrupt) |
| 469 | | { |
| 470 | | #if 1 |
| 471 | | if (state != m_vicirq) |
| 472 | | { |
| 473 | | c65_irq (state || m_cia0_irq); |
| 474 | | m_vicirq = state; |
| 475 | | } |
| 476 | | #endif |
| 477 | | } |
| 478 | | |
| 479 | | /* |
| 480 | | * CIA 1 - Port A |
| 481 | | * bit 7 serial bus data input |
| 482 | | * bit 6 serial bus clock input |
| 483 | | * bit 5 serial bus data output |
| 484 | | * bit 4 serial bus clock output |
| 485 | | * bit 3 serial bus atn output |
| 486 | | * bit 2 rs232 data output |
| 487 | | * bits 1-0 vic-chip system memory bank select |
| 488 | | * |
| 489 | | * CIA 1 - Port B |
| 490 | | * bit 7 user rs232 data set ready |
| 491 | | * bit 6 user rs232 clear to send |
| 492 | | * bit 5 user |
| 493 | | * bit 4 user rs232 carrier detect |
| 494 | | * bit 3 user rs232 ring indicator |
| 495 | | * bit 2 user rs232 data terminal ready |
| 496 | | * bit 1 user rs232 request to send |
| 497 | | * bit 0 user rs232 received data |
| 498 | | * |
| 499 | | * flag restore key or rs232 received data input |
| 500 | | * irq to nmi connected ? |
| 501 | | */ |
| 502 | | READ8_MEMBER(c65_state::c65_cia1_port_a_r) |
| 503 | | { |
| 504 | | UINT8 value = 0xff; |
| 505 | | |
| 506 | | if (!m_iec->clk_r()) |
| 507 | | value &= ~0x40; |
| 508 | | |
| 509 | | if (!m_iec->data_r()) |
| 510 | | value &= ~0x80; |
| 511 | | |
| 512 | | return value; |
| 513 | | } |
| 514 | | |
| 515 | | WRITE8_MEMBER(c65_state::c65_cia1_port_a_w) |
| 516 | | { |
| 517 | | static const int helper[4] = {0xc000, 0x8000, 0x4000, 0x0000}; |
| 518 | | |
| 519 | | m_iec->atn_w(!BIT(data, 3)); |
| 520 | | m_iec->clk_w(!BIT(data, 4)); |
| 521 | | m_iec->data_w(!BIT(data, 5)); |
| 522 | | |
| 523 | | m_vicaddr = m_memory + helper[data & 0x03]; |
| 524 | | } |
| 525 | | |
| 526 | | WRITE_LINE_MEMBER(c65_state::c65_cia1_interrupt) |
| 527 | | { |
| 528 | | m_cia1_irq = state; |
| 529 | | c65_nmi(); |
| 530 | | } |
| 531 | | |
| 532 | | /*********************************************** |
| 533 | | |
| 534 | | Memory Handlers |
| 535 | | |
| 536 | | ***********************************************/ |
| 537 | | |
| 538 | | /* processor has only 1 mega address space !? */ |
| 539 | | /* and system 8 megabyte */ |
| 540 | | /* dma controller and bankswitch hardware ?*/ |
| 541 | | READ8_MEMBER( c65_state::c65_read_mem ) |
| 542 | | { |
| 543 | | UINT8 result; |
| 544 | | if (offset <= 0x0ffff) |
| 545 | | result = m_memory[offset]; |
| 546 | | else |
| 547 | | result = space.read_byte(offset); |
| 548 | | return result; |
| 549 | | } |
| 550 | | |
| 551 | | WRITE8_MEMBER( c65_state::c65_write_mem ) |
| 552 | | { |
| 553 | | if (offset <= 0x0ffff) |
| 554 | | m_memory[offset] = data; |
| 555 | | else |
| 556 | | space.write_byte(offset, data); |
| 557 | | } |
| 558 | | |
| 559 | | /* dma chip at 0xd700 |
| 560 | | used: |
| 561 | | writing banknumber to offset 2 |
| 562 | | writing hibyte to offset 1 |
| 563 | | writing lobyte to offset 0 |
| 564 | | cpu holded, dma transfer(data at address) executed, cpu activated |
| 565 | | |
| 566 | | command data: |
| 567 | | 0 command (0 copy, 3 fill) |
| 568 | | 1,2 length |
| 569 | | 3,4,5 source |
| 570 | | 6,7,8 dest |
| 571 | | 9 subcommand |
| 572 | | 10 mod |
| 573 | | |
| 574 | | version 1: |
| 575 | | seldom copy (overlapping) from 0x402002 to 0x402008 |
| 576 | | (making place for new line in basic area) |
| 577 | | for whats this bit 0x400000, or is this really the address? |
| 578 | | maybe means add counter to address for access, |
| 579 | | so allowing up or down copies, and reordering copies |
| 580 | | |
| 581 | | version 2: |
| 582 | | cmd 0x30 used for this |
| 583 | | */ |
| 584 | | void c65_state::c65_dma_port_w( int offset, int value ) |
| 585 | | { |
| 586 | | PAIR pair, src, dst, len; |
| 587 | | UINT8 cmd, fill; |
| 588 | | int i; |
| 589 | | address_space &space = m_maincpu->space(AS_PROGRAM); |
| 590 | | |
| 591 | | switch (offset & 3) |
| 592 | | { |
| 593 | | case 2: |
| 594 | | case 1: |
| 595 | | m_dma.data[offset & 3] = value; |
| 596 | | break; |
| 597 | | case 0: |
| 598 | | pair.b.h3 = 0; |
| 599 | | pair.b.h2 = m_dma.data[2]; |
| 600 | | pair.b.h = m_dma.data[1]; |
| 601 | | pair.b.l = m_dma.data[0]=value; |
| 602 | | cmd = c65_read_mem(space, pair.d++); |
| 603 | | len.w.h = 0; |
| 604 | | len.b.l = c65_read_mem(space, pair.d++); |
| 605 | | len.b.h = c65_read_mem(space, pair.d++); |
| 606 | | src.b.h3 = 0; |
| 607 | | fill = src.b.l = c65_read_mem(space, pair.d++); |
| 608 | | src.b.h = c65_read_mem(space, pair.d++); |
| 609 | | src.b.h2 = c65_read_mem(space, pair.d++); |
| 610 | | dst.b.h3 = 0; |
| 611 | | dst.b.l = c65_read_mem(space, pair.d++); |
| 612 | | dst.b.h = c65_read_mem(space, pair.d++); |
| 613 | | dst.b.h2 = c65_read_mem(space, pair.d++); |
| 614 | | |
| 615 | | switch (cmd) |
| 616 | | { |
| 617 | | case 0: |
| 618 | | if (src.d == 0x3ffff) m_dump_dma = 1; |
| 619 | | if (m_dump_dma) |
| 620 | | DBG_LOG(space.machine(), 1,"dma copy job", |
| 621 | | ("len:%.4x src:%.6x dst:%.6x sub:%.2x modrm:%.2x\n", |
| 622 | | len.w.l, src.d, dst.d, c65_read_mem(space, pair.d), |
| 623 | | c65_read_mem(space, pair.d + 1) ) ); |
| 624 | | if ((m_dma.version == 1) |
| 625 | | && ( (src.d&0x400000) || (dst.d & 0x400000))) |
| 626 | | { |
| 627 | | if (!(src.d & 0x400000)) |
| 628 | | { |
| 629 | | dst.d &= ~0x400000; |
| 630 | | for (i = 0; i < len.w.l; i++) |
| 631 | | c65_write_mem(space, dst.d--, c65_read_mem(space, src.d++)); |
| 632 | | } |
| 633 | | else if (!(dst.d & 0x400000)) |
| 634 | | { |
| 635 | | src.d &= ~0x400000; |
| 636 | | for (i = 0; i < len.w.l; i++) |
| 637 | | c65_write_mem(space, dst.d++, c65_read_mem(space, src.d--)); |
| 638 | | } |
| 639 | | else |
| 640 | | { |
| 641 | | src.d &= ~0x400000; |
| 642 | | dst.d &= ~0x400000; |
| 643 | | for (i = 0; i < len.w.l; i++) |
| 644 | | c65_write_mem(space, --dst.d, c65_read_mem(space, --src.d)); |
| 645 | | } |
| 646 | | } |
| 647 | | else |
| 648 | | { |
| 649 | | for (i = 0; i < len.w.l; i++) |
| 650 | | c65_write_mem(space, dst.d++, c65_read_mem(space, src.d++)); |
| 651 | | } |
| 652 | | break; |
| 653 | | case 3: |
| 654 | | DBG_LOG(space.machine(), 3,"dma fill job", |
| 655 | | ("len:%.4x value:%.2x dst:%.6x sub:%.2x modrm:%.2x\n", |
| 656 | | len.w.l, fill, dst.d, c65_read_mem(space, pair.d), |
| 657 | | c65_read_mem(space, pair.d + 1))); |
| 658 | | for (i = 0; i < len.w.l; i++) |
| 659 | | c65_write_mem(space, dst.d++, fill); |
| 660 | | break; |
| 661 | | case 0x30: |
| 662 | | DBG_LOG(space.machine(), 1,"dma copy down", |
| 663 | | ("len:%.4x src:%.6x dst:%.6x sub:%.2x modrm:%.2x\n", |
| 664 | | len.w.l, src.d, dst.d, c65_read_mem(space, pair.d), |
| 665 | | c65_read_mem(space, pair.d + 1) ) ); |
| 666 | | for (i = 0; i < len.w.l; i++) |
| 667 | | c65_write_mem(space, dst.d--,c65_read_mem(space, src.d--)); |
| 668 | | break; |
| 669 | | default: |
| 670 | | DBG_LOG(space.machine(), 1,"dma job", |
| 671 | | ("cmd:%.2x len:%.4x src:%.6x dst:%.6x sub:%.2x modrm:%.2x\n", |
| 672 | | cmd,len.w.l, src.d, dst.d, c65_read_mem(space, pair.d), |
| 673 | | c65_read_mem(space, pair.d + 1))); |
| 674 | | } |
| 675 | | break; |
| 676 | | default: |
| 677 | | DBG_LOG(space.machine(), 1, "dma chip write", ("%.3x %.2x\n", offset, value)); |
| 678 | | break; |
| 679 | | } |
| 680 | | } |
| 681 | | |
| 682 | | int c65_state::c65_dma_port_r( int offset ) |
| 683 | | { |
| 684 | | /* offset 3 bit 7 in progress ? */ |
| 685 | | DBG_LOG(machine(), 2, "dma chip read", ("%.3x\n", offset)); |
| 686 | | return 0x7f; |
| 687 | | } |
| 688 | | |
| 689 | | void c65_state::c65_6511_port_w( int offset, int value ) |
| 690 | | { |
| 691 | | if (offset == 7) |
| 692 | | { |
| 693 | | m_6511_port = value; |
| 694 | | } |
| 695 | | DBG_LOG(machine(), 2, "r6511 write", ("%.2x %.2x\n", offset, value)); |
| 696 | | } |
| 697 | | |
| 698 | | int c65_state::c65_6511_port_r( int offset ) |
| 699 | | { |
| 700 | | int data = 0xff; |
| 701 | | |
| 702 | | if (offset == 7) |
| 703 | | { |
| 704 | | if (ioport("SPECIAL")->read() & 0x20) |
| 705 | | data &= ~1; |
| 706 | | } |
| 707 | | DBG_LOG(machine(), 2, "r6511 read", ("%.2x\n", offset)); |
| 708 | | |
| 709 | | return data; |
| 710 | | } |
| 711 | | |
| 712 | | /* one docu states custom 4191 disk controller |
| 713 | | (for 2 1MB MFM disk drives, 1 internal, the other extern (optional) 1565 |
| 714 | | with integrated 512 byte buffer |
| 715 | | |
| 716 | | 0->0 reset ? |
| 717 | | |
| 718 | | 0->1, 0->0, wait until 2 positiv, 1->0 ??? |
| 719 | | |
| 720 | | 0->0, 0 not 0 means no drive ???, other system entries |
| 721 | | |
| 722 | | |
| 723 | | reg 0 write/read |
| 724 | | 0,1 written |
| 725 | | bit 1 set |
| 726 | | bit 2 set |
| 727 | | bit 3 set |
| 728 | | bit 4 set |
| 729 | | |
| 730 | | |
| 731 | | reg 0 read |
| 732 | | bit 0 |
| 733 | | bit 1 |
| 734 | | bit 2 |
| 735 | | 0..2 ->$1d4 |
| 736 | | |
| 737 | | reg 1 write |
| 738 | | $01 written |
| 739 | | $18 written |
| 740 | | $46 written |
| 741 | | $80 written |
| 742 | | $a1 written |
| 743 | | $01 written, dec |
| 744 | | $10 written |
| 745 | | |
| 746 | | reg 2 read/write?(lsr) |
| 747 | | bit 2 |
| 748 | | bit 4 |
| 749 | | bit 5 busy waiting until zero, then reading reg 7 |
| 750 | | bit 6 operation not activ flag!? or set overflow pin used |
| 751 | | bit 7 busy flag? |
| 752 | | |
| 753 | | reg 3 read/write?(rcr) |
| 754 | | bit 1 |
| 755 | | bit 3 |
| 756 | | bit 7 busy flag? |
| 757 | | |
| 758 | | reg 4 |
| 759 | | track?? |
| 760 | | 0 written |
| 761 | | read -> $1d2 |
| 762 | | cmp #$50 |
| 763 | | bcs |
| 764 | | |
| 765 | | |
| 766 | | reg 5 |
| 767 | | sector ?? |
| 768 | | 1 written |
| 769 | | read -> $1d3 |
| 770 | | cmp #$b bcc |
| 771 | | |
| 772 | | |
| 773 | | reg 6 |
| 774 | | head ?? |
| 775 | | 0 written |
| 776 | | read -> $1d1 |
| 777 | | cmp #2 bcc |
| 778 | | |
| 779 | | reg 7 read |
| 780 | | #4e written |
| 781 | | 12 times 0, a1 a1 a1 fe written |
| 782 | | |
| 783 | | reg 8 read |
| 784 | | #ff written |
| 785 | | 16 times #ff written |
| 786 | | |
| 787 | | reg 9 |
| 788 | | #60 written |
| 789 | | |
| 790 | | might use the set overflow input |
| 791 | | |
| 792 | | $21a6c 9a6c format |
| 793 | | $21c97 9c97 write operation |
| 794 | | $21ca0 9ca0 get byte? |
| 795 | | $21cab 9cab read reg 7 |
| 796 | | $21caf 9caf write reg 7 |
| 797 | | $21cb3 |
| 798 | | */ |
| 799 | | |
| 800 | | #define FDC_LOST 4 |
| 801 | | #define FDC_CRC 8 |
| 802 | | #define FDC_RNF 0x10 |
| 803 | | #define FDC_BUSY 0x80 |
| 804 | | #define FDC_IRQ 0x200 |
| 805 | | |
| 806 | | #define FDC_CMD_MOTOR_SPIN_UP 0x10 |
| 807 | | |
| 808 | | #if 0 |
| 809 | | void c65_state::c65_fdc_state(void) |
| 810 | | { |
| 811 | | switch (m_fdc.state) |
| 812 | | { |
| 813 | | case FDC_CMD_MOTOR_SPIN_UP: |
| 814 | | if (machine().time() - m_fdc.time) |
| 815 | | { |
| 816 | | m_fdc.state = 0; |
| 817 | | m_fdc.status &= ~FDC_BUSY; |
| 818 | | } |
| 819 | | break; |
| 820 | | } |
| 821 | | } |
| 822 | | #endif |
| 823 | | |
| 824 | | void c65_state::c65_fdc_w( int offset, int data ) |
| 825 | | { |
| 826 | | DBG_LOG(machine(), 1, "fdc write", ("%.5x %.2x %.2x\n", machine().device("maincpu")->safe_pc(), offset, data)); |
| 827 | | switch (offset & 0xf) |
| 828 | | { |
| 829 | | case 0: |
| 830 | | m_fdc.reg[0] = data; |
| 831 | | break; |
| 832 | | case 1: |
| 833 | | m_fdc.reg[1] = data; |
| 834 | | switch (data & 0xf9) |
| 835 | | { |
| 836 | | case 0x20: // wait for motor spin up |
| 837 | | m_fdc.status &= ~(FDC_IRQ|FDC_LOST|FDC_CRC|FDC_RNF); |
| 838 | | m_fdc.status |= FDC_BUSY; |
| 839 | | m_fdc.time = machine().time(); |
| 840 | | m_fdc.state = FDC_CMD_MOTOR_SPIN_UP; |
| 841 | | break; |
| 842 | | case 0: // cancel |
| 843 | | m_fdc.status &= ~(FDC_BUSY); |
| 844 | | m_fdc.state = 0; |
| 845 | | break; |
| 846 | | case 0x80: // buffered write |
| 847 | | case 0x40: // buffered read |
| 848 | | case 0x81: // unbuffered write |
| 849 | | case 0x41: // unbuffered read |
| 850 | | case 0x30:case 0x31: // step |
| 851 | | break; |
| 852 | | } |
| 853 | | break; |
| 854 | | case 2: case 3: // read only |
| 855 | | break; |
| 856 | | case 4: |
| 857 | | m_fdc.reg[offset & 0xf] = data; |
| 858 | | m_fdc.track = data; |
| 859 | | break; |
| 860 | | case 5: |
| 861 | | m_fdc.reg[offset & 0xf] = data; |
| 862 | | m_fdc.sector = data; |
| 863 | | break; |
| 864 | | case 6: |
| 865 | | m_fdc.reg[offset & 0xf] = data; |
| 866 | | m_fdc.head = data; |
| 867 | | break; |
| 868 | | case 7: |
| 869 | | m_fdc.buffer[m_fdc.cpu_pos++] = data; |
| 870 | | break; |
| 871 | | default: |
| 872 | | m_fdc.reg[offset & 0xf] = data; |
| 873 | | break; |
| 874 | | } |
| 875 | | } |
| 876 | | |
| 877 | | int c65_state::c65_fdc_r( int offset ) |
| 878 | | { |
| 879 | | UINT8 data = 0; |
| 880 | | switch (offset & 0xf) |
| 881 | | { |
| 882 | | case 0: |
| 883 | | data = m_fdc.reg[0]; |
| 884 | | break; |
| 885 | | case 1: |
| 886 | | data = m_fdc.reg[1]; |
| 887 | | break; |
| 888 | | case 2: |
| 889 | | data = m_fdc.status; |
| 890 | | break; |
| 891 | | case 3: |
| 892 | | data = m_fdc.status >> 8; |
| 893 | | break; |
| 894 | | case 4: |
| 895 | | data = m_fdc.track; |
| 896 | | break; |
| 897 | | case 5: |
| 898 | | data = m_fdc.sector; |
| 899 | | break; |
| 900 | | case 6: |
| 901 | | data = m_fdc.head; |
| 902 | | break; |
| 903 | | case 7: |
| 904 | | data = m_fdc.buffer[m_fdc.cpu_pos++]; |
| 905 | | break; |
| 906 | | default: |
| 907 | | data = m_fdc.reg[offset & 0xf]; |
| 908 | | break; |
| 909 | | } |
| 910 | | DBG_LOG(machine(), 1, "fdc read", ("%.5x %.2x %.2x\n", machine().device("maincpu")->safe_pc(), offset, data)); |
| 911 | | return data; |
| 912 | | } |
| 913 | | |
| 914 | | /* version 1 ramcheck |
| 915 | | write 0:0 |
| 916 | | read write read write 80000,90000,f0000 |
| 917 | | write 0:8 |
| 918 | | read write read write 80000,90000,f0000 |
| 919 | | |
| 920 | | version 2 ramcheck??? |
| 921 | | read 0: |
| 922 | | write 0:0 |
| 923 | | read 0: |
| 924 | | first read and second read bit 0x80 set --> nothing |
| 925 | | write 0:0 |
| 926 | | read 0 |
| 927 | | write 0:ff |
| 928 | | */ |
| 929 | | |
| 930 | | READ8_MEMBER( c65_state::c65_ram_expansion_r ) |
| 931 | | { |
| 932 | | UINT8 data = 0xff; |
| 933 | | if (m_ram->size() > (128 * 1024)) |
| 934 | | data = m_expansion_ram.reg; |
| 935 | | return data; |
| 936 | | } |
| 937 | | |
| 938 | | WRITE8_MEMBER( c65_state::c65_ram_expansion_w ) |
| 939 | | { |
| 940 | | offs_t expansion_ram_begin; |
| 941 | | offs_t expansion_ram_end; |
| 942 | | |
| 943 | | if (m_ram->size() > (128 * 1024)) |
| 944 | | { |
| 945 | | m_expansion_ram.reg = data; |
| 946 | | |
| 947 | | expansion_ram_begin = 0x80000; |
| 948 | | expansion_ram_end = 0x80000 + (m_ram->size() - 128*1024) - 1; |
| 949 | | |
| 950 | | if (data == 0x00) { |
| 951 | | space.install_readwrite_bank(expansion_ram_begin, expansion_ram_end,"bank16"); |
| 952 | | membank("bank16")->set_base(m_ram->pointer() + 128*1024); |
| 953 | | } else { |
| 954 | | space.nop_readwrite(expansion_ram_begin, expansion_ram_end); |
| 955 | | } |
| 956 | | } |
| 957 | | } |
| 958 | | |
| 959 | | WRITE8_MEMBER( c65_state::c65_write_io ) |
| 960 | | { |
| 961 | | mos6581_device *sid_0 = machine().device<mos6581_device>("sid_r"); |
| 962 | | mos6581_device *sid_1 = machine().device<mos6581_device>("sid_l"); |
| 963 | | vic3_device *vic3 = machine().device<vic3_device>("vic3"); |
| 964 | | |
| 965 | | switch (offset & 0xf00) |
| 966 | | { |
| 967 | | case 0x000: |
| 968 | | if (offset < 0x80) |
| 969 | | vic3->port_w(space, offset & 0x7f, data); |
| 970 | | else if (offset < 0xa0) |
| 971 | | c65_fdc_w(offset & 0x1f, data); |
| 972 | | else |
| 973 | | { |
| 974 | | c65_ram_expansion_w(space, offset & 0x1f, data, mem_mask); |
| 975 | | /*ram expansion crtl optional */ |
| 976 | | } |
| 977 | | break; |
| 978 | | case 0x100: |
| 979 | | case 0x200: |
| 980 | | case 0x300: |
| 981 | | vic3->palette_w(space, offset - 0x100, data); |
| 982 | | break; |
| 983 | | case 0x400: |
| 984 | | if (offset<0x420) /* maybe 0x20 */ |
| 985 | | sid_0->write(space, offset & 0x3f, data); |
| 986 | | else if (offset<0x440) |
| 987 | | sid_1->write(space, offset & 0x3f, data); |
| 988 | | else |
| 989 | | DBG_LOG(machine(), 1, "io write", ("%.3x %.2x\n", offset, data)); |
| 990 | | break; |
| 991 | | case 0x500: |
| 992 | | DBG_LOG(machine(), 1, "io write", ("%.3x %.2x\n", offset, data)); |
| 993 | | break; |
| 994 | | case 0x600: |
| 995 | | c65_6511_port_w(offset & 0xff,data); |
| 996 | | break; |
| 997 | | case 0x700: |
| 998 | | c65_dma_port_w(offset & 0xff, data); |
| 999 | | break; |
| 1000 | | } |
| 1001 | | } |
| 1002 | | |
| 1003 | | WRITE8_MEMBER( c65_state::c65_write_io_dc00 ) |
| 1004 | | { |
| 1005 | | switch (offset & 0xf00) |
| 1006 | | { |
| 1007 | | case 0x000: |
| 1008 | | m_cia0->write(space, offset, data); |
| 1009 | | break; |
| 1010 | | case 0x100: |
| 1011 | | m_cia1->write(space, offset, data); |
| 1012 | | break; |
| 1013 | | case 0x200: |
| 1014 | | case 0x300: |
| 1015 | | DBG_LOG(machine(), 1, "io write", ("%.3x %.2x\n", offset+0xc00, data)); |
| 1016 | | break; |
| 1017 | | } |
| 1018 | | } |
| 1019 | | |
| 1020 | | READ8_MEMBER( c65_state::c65_read_io ) |
| 1021 | | { |
| 1022 | | mos6581_device *sid_0 = machine().device<mos6581_device>("sid_r"); |
| 1023 | | mos6581_device *sid_1 = machine().device<mos6581_device>("sid_l"); |
| 1024 | | vic3_device *vic3 = machine().device<vic3_device>("vic3"); |
| 1025 | | |
| 1026 | | switch (offset & 0xf00) |
| 1027 | | { |
| 1028 | | case 0x000: |
| 1029 | | if (offset < 0x80) |
| 1030 | | return vic3->port_r(space, offset & 0x7f); |
| 1031 | | if (offset < 0xa0) |
| 1032 | | return c65_fdc_r(offset & 0x1f); |
| 1033 | | else |
| 1034 | | { |
| 1035 | | return c65_ram_expansion_r(space, offset & 0x1f, mem_mask); |
| 1036 | | /*return; ram expansion crtl optional */ |
| 1037 | | } |
| 1038 | | case 0x100: |
| 1039 | | case 0x200: |
| 1040 | | case 0x300: |
| 1041 | | /* read only !? */ |
| 1042 | | DBG_LOG(machine(), 1, "io read", ("%.3x\n", offset)); |
| 1043 | | break; |
| 1044 | | case 0x400: |
| 1045 | | if (offset < 0x420) |
| 1046 | | return sid_0->read(space, offset & 0x3f); |
| 1047 | | if (offset < 0x440) |
| 1048 | | return sid_1->read(space, offset & 0x3f); |
| 1049 | | DBG_LOG(machine(), 1, "io read", ("%.3x\n", offset)); |
| 1050 | | break; |
| 1051 | | case 0x500: |
| 1052 | | DBG_LOG(machine(), 1, "io read", ("%.3x\n", offset)); |
| 1053 | | break; |
| 1054 | | case 0x600: |
| 1055 | | return c65_6511_port_r(offset&0xff); |
| 1056 | | case 0x700: |
| 1057 | | return c65_dma_port_r(offset&0xff); |
| 1058 | | } |
| 1059 | | return 0xff; |
| 1060 | | } |
| 1061 | | |
| 1062 | | READ8_MEMBER( c65_state::c65_read_io_dc00 ) |
| 1063 | | { |
| 1064 | | switch (offset & 0x300) |
| 1065 | | { |
| 1066 | | case 0x000: |
| 1067 | | return m_cia0->read(space, offset); |
| 1068 | | case 0x100: |
| 1069 | | return m_cia1->read(space, offset); |
| 1070 | | case 0x200: |
| 1071 | | case 0x300: |
| 1072 | | DBG_LOG(machine(), 1, "io read", ("%.3x\n", offset+0xc00)); |
| 1073 | | break; |
| 1074 | | } |
| 1075 | | return 0xff; |
| 1076 | | } |
| 1077 | | |
| 1078 | | |
| 1079 | | /* |
| 1080 | | d02f: |
| 1081 | | init a5 96 written (seems to be switch to c65 or vic3 mode) |
| 1082 | | go64 0 written |
| 1083 | | */ |
| 1084 | | |
| 1085 | | /* bit 1 external sync enable (genlock) |
| 1086 | | bit 2 palette enable |
| 1087 | | bit 6 vic3 c65 character set */ |
| 1088 | | WRITE8_MEMBER(c65_state::c65_bankswitch_interface) |
| 1089 | | { |
| 1090 | | DBG_LOG(machine(), 2, "c65 bankswitch", ("%.2x\n",data)); |
| 1091 | | |
| 1092 | | if (m_io_on) |
| 1093 | | { |
| 1094 | | if (data & 1) |
| 1095 | | { |
| 1096 | | membank("bank8")->set_base(m_colorram + 0x400); |
| 1097 | | membank("bank9")->set_base(m_colorram + 0x400); |
| 1098 | | m_maincpu->space(AS_PROGRAM).install_read_bank(0x0dc00, 0x0dfff, "bank8"); |
| 1099 | | m_maincpu->space(AS_PROGRAM).install_write_bank(0x0dc00, 0x0dfff, "bank9"); |
| 1100 | | } |
| 1101 | | else |
| 1102 | | { |
| 1103 | | m_maincpu->space(AS_PROGRAM).install_read_handler(0x0dc00, 0x0dfff, read8_delegate(FUNC(c65_state::c65_read_io_dc00),this)); |
| 1104 | | m_maincpu->space(AS_PROGRAM).install_write_handler(0x0dc00, 0x0dfff, write8_delegate(FUNC(c65_state::c65_write_io_dc00),this)); |
| 1105 | | } |
| 1106 | | } |
| 1107 | | |
| 1108 | | m_io_dc00_on = !(data & 1); |
| 1109 | | #if 0 |
| 1110 | | /* cartridge roms !?*/ |
| 1111 | | if (data & 0x08) |
| 1112 | | membank("bank1")->set_base(m_roml); |
| 1113 | | else |
| 1114 | | membank("bank1")->set_base(m_memory + 0x8000); |
| 1115 | | |
| 1116 | | if (data & 0x10) |
| 1117 | | membank("bank2")->set_base(m_basic); |
| 1118 | | else |
| 1119 | | membank("bank2")->set_base(m_memory + 0xa000); |
| 1120 | | #endif |
| 1121 | | if ((m_old_value^data) & 0x20) |
| 1122 | | { |
| 1123 | | /* bankswitching faulty when doing actual page */ |
| 1124 | | if (data & 0x20) |
| 1125 | | membank("bank3")->set_base(m_basic); |
| 1126 | | else |
| 1127 | | membank("bank3")->set_base(m_memory + 0xc000); |
| 1128 | | } |
| 1129 | | m_charset_select = data & 0x40; |
| 1130 | | #if 0 |
| 1131 | | /* cartridge roms !?*/ |
| 1132 | | if (data & 0x80) |
| 1133 | | membank("bank8")->set_base(m_kernal); |
| 1134 | | else |
| 1135 | | membank("bank6")->set_base(m_memory + 0xe000); |
| 1136 | | #endif |
| 1137 | | m_old_value = data; |
| 1138 | | } |
| 1139 | | |
| 1140 | | void c65_state::c65_bankswitch( ) |
| 1141 | | { |
| 1142 | | int data, loram, hiram, charen; |
| 1143 | | |
| 1144 | | data = 0x00; // machine().device<m4510_device>("maincpu")->get_port(); |
| 1145 | | if (data == m_old_data) |
| 1146 | | return; |
| 1147 | | |
| 1148 | | DBG_LOG(machine(), 1, "bankswitch", ("%d\n", data & 7)); |
| 1149 | | loram = (data & 1) ? 1 : 0; |
| 1150 | | hiram = (data & 2) ? 1 : 0; |
| 1151 | | charen = (data & 4) ? 1 : 0; |
| 1152 | | |
| 1153 | | if ((!m_game && m_exrom) || (loram && hiram && !m_exrom)) |
| 1154 | | membank("bank1")->set_base(m_roml); |
| 1155 | | else |
| 1156 | | membank("bank1")->set_base(m_memory + 0x8000); |
| 1157 | | |
| 1158 | | if ((!m_game && m_exrom && hiram) || (!m_exrom)) |
| 1159 | | membank("bank2")->set_base(m_romh); |
| 1160 | | else if (loram && hiram) |
| 1161 | | membank("bank2")->set_base(m_basic); |
| 1162 | | else |
| 1163 | | membank("bank2")->set_base(m_memory + 0xa000); |
| 1164 | | |
| 1165 | | if ((!m_game && m_exrom) || (charen && (loram || hiram))) |
| 1166 | | { |
| 1167 | | m_io_on = 1; |
| 1168 | | membank("bank6")->set_base(m_colorram); |
| 1169 | | membank("bank7")->set_base(m_colorram); |
| 1170 | | |
| 1171 | | if (m_io_dc00_on) |
| 1172 | | { |
| 1173 | | m_maincpu->space(AS_PROGRAM).install_read_handler(0x0dc00, 0x0dfff, read8_delegate(FUNC(c65_state::c65_read_io_dc00),this)); |
| 1174 | | m_maincpu->space(AS_PROGRAM).install_write_handler(0x0dc00, 0x0dfff, write8_delegate(FUNC(c65_state::c65_write_io_dc00),this)); |
| 1175 | | } |
| 1176 | | else |
| 1177 | | { |
| 1178 | | m_maincpu->space(AS_PROGRAM).install_read_bank(0x0dc00, 0x0dfff, "bank8"); |
| 1179 | | m_maincpu->space(AS_PROGRAM).install_write_bank(0x0dc00, 0x0dfff, "bank9"); |
| 1180 | | membank("bank8")->set_base(m_colorram + 0x400); |
| 1181 | | membank("bank9")->set_base(m_colorram + 0x400); |
| 1182 | | } |
| 1183 | | m_maincpu->space(AS_PROGRAM).install_read_handler(0x0d000, 0x0d7ff, read8_delegate(FUNC(c65_state::c65_read_io),this)); |
| 1184 | | m_maincpu->space(AS_PROGRAM).install_write_handler(0x0d000, 0x0d7ff, write8_delegate(FUNC(c65_state::c65_write_io),this)); |
| 1185 | | } |
| 1186 | | else |
| 1187 | | { |
| 1188 | | m_io_on = 0; |
| 1189 | | membank("bank5")->set_base(m_memory + 0xd000); |
| 1190 | | membank("bank7")->set_base(m_memory + 0xd800); |
| 1191 | | membank("bank9")->set_base(m_memory + 0xdc00); |
| 1192 | | if (!charen && (loram || hiram)) |
| 1193 | | { |
| 1194 | | membank("bank4")->set_base(m_chargen); |
| 1195 | | membank("bank6")->set_base(m_chargen + 0x800); |
| 1196 | | membank("bank8")->set_base(m_chargen + 0xc00); |
| 1197 | | } |
| 1198 | | else |
| 1199 | | { |
| 1200 | | membank("bank4")->set_base(m_memory + 0xd000); |
| 1201 | | membank("bank6")->set_base(m_memory + 0xd800); |
| 1202 | | membank("bank8")->set_base(m_memory + 0xdc00); |
| 1203 | | } |
| 1204 | | m_maincpu->space(AS_PROGRAM).install_read_bank(0x0d000, 0x0d7ff, "bank4"); |
| 1205 | | m_maincpu->space(AS_PROGRAM).install_write_bank(0x0d000, 0x0d7ff, "bank5"); |
| 1206 | | } |
| 1207 | | |
| 1208 | | if (!m_game && m_exrom) |
| 1209 | | { |
| 1210 | | membank("bank10")->set_base(m_romh); |
| 1211 | | } |
| 1212 | | else |
| 1213 | | { |
| 1214 | | if (hiram) |
| 1215 | | { |
| 1216 | | membank("bank10")->set_base(m_kernal); |
| 1217 | | } |
| 1218 | | else |
| 1219 | | { |
| 1220 | | membank("bank10")->set_base(m_memory + 0xe000); |
| 1221 | | } |
| 1222 | | } |
| 1223 | | m_old_data = data; |
| 1224 | | } |
| 1225 | | |
| 1226 | | #ifdef UNUSED_FUNCTION |
| 1227 | | void c65_state::c65_colorram_write( int offset, int value ) |
| 1228 | | { |
| 1229 | | m_colorram[offset & 0x7ff] = value | 0xf0; |
| 1230 | | } |
| 1231 | | #endif |
| 1232 | | |
| 1233 | | /* |
| 1234 | | * only 14 address lines |
| 1235 | | * a15 and a14 portlines |
| 1236 | | * 0x1000-0x1fff, 0x9000-0x9fff char rom |
| 1237 | | */ |
| 1238 | | READ8_MEMBER(c65_state::c65_dma_read) |
| 1239 | | { |
| 1240 | | if (!m_game && m_exrom) |
| 1241 | | { |
| 1242 | | if (offset < 0x3000) |
| 1243 | | return m_memory[offset]; |
| 1244 | | return m_romh[offset & 0x1fff]; |
| 1245 | | } |
| 1246 | | if ((m_vicaddr == m_memory) || (m_vicaddr == m_memory + 0x8000)) |
| 1247 | | { |
| 1248 | | if (offset < 0x1000) |
| 1249 | | return m_vicaddr[offset & 0x3fff]; |
| 1250 | | if (offset < 0x2000) { |
| 1251 | | if (m_charset_select) |
| 1252 | | return m_chargen[offset & 0xfff]; |
| 1253 | | else |
| 1254 | | return m_chargen[offset & 0xfff]; |
| 1255 | | } |
| 1256 | | return m_vicaddr[offset & 0x3fff]; |
| 1257 | | } |
| 1258 | | return m_vicaddr[offset & 0x3fff]; |
| 1259 | | } |
| 1260 | | |
| 1261 | | READ8_MEMBER(c65_state::c65_dma_read_color) |
| 1262 | | { |
| 1263 | | if (m_c64mode) |
| 1264 | | return m_colorram[offset & 0x3ff] & 0xf; |
| 1265 | | return m_colorram[offset & 0x7ff]; |
| 1266 | | } |
| 1267 | | |
| 1268 | | void c65_state::c65_common_driver_init( ) |
| 1269 | | { |
| 1270 | | m_memory = auto_alloc_array_clear(machine(), UINT8, 0x10000); |
| 1271 | | membank("bank11")->set_base(m_memory + 0x00000); |
| 1272 | | membank("bank12")->set_base(m_memory + 0x08000); |
| 1273 | | membank("bank13")->set_base(m_memory + 0x0a000); |
| 1274 | | membank("bank14")->set_base(m_memory + 0x0c000); |
| 1275 | | membank("bank15")->set_base(m_memory + 0x0e000); |
| 1276 | | |
| 1277 | | cbm_common_init(); |
| 1278 | | m_keyline = 0xff; |
| 1279 | | |
| 1280 | | m_pal = 0; |
| 1281 | | m_charset_select = 0; |
| 1282 | | m_6511_port = 0xff; |
| 1283 | | m_vicirq = 0; |
| 1284 | | m_old_data = -1; |
| 1285 | | |
| 1286 | | /* C65 had no datasette port */ |
| 1287 | | m_tape_on = 0; |
| 1288 | | m_game = 1; |
| 1289 | | m_exrom = 1; |
| 1290 | | |
| 1291 | | /*memset(m_memory + 0x40000, 0, 0x800000 - 0x40000); */ |
| 1292 | | } |
| 1293 | | |
| 1294 | | DRIVER_INIT_MEMBER(c65_state,c65) |
| 1295 | | { |
| 1296 | | m_dma.version = 2; |
| 1297 | | c65_common_driver_init(); |
| 1298 | | } |
| 1299 | | |
| 1300 | | DRIVER_INIT_MEMBER(c65_state,c65pal) |
| 1301 | | { |
| 1302 | | m_dma.version = 1; |
| 1303 | | c65_common_driver_init(); |
| 1304 | | m_pal = 1; |
| 1305 | | } |
| 1306 | | |
| 1307 | | MACHINE_START_MEMBER(c65_state,c65) |
| 1308 | | { |
| 1309 | | /* clear upper memory */ |
| 1310 | | memset(m_ram->pointer() + 128*1024, 0xff, m_ram->size() - 128*1024); |
| 1311 | | |
| 1312 | | //removed cbm_drive_0_config (SERIAL, 10); |
| 1313 | | //removed cbm_drive_1_config (SERIAL, 11); |
| 1314 | | m_vicaddr = m_memory; |
| 1315 | | |
| 1316 | | m_c64mode = 0; |
| 1317 | | |
| 1318 | | c65_bankswitch_interface(m_maincpu->space(AS_PROGRAM),0,0xff); |
| 1319 | | c65_bankswitch(); |
| 1320 | | } |
| 1321 | | |
| 1322 | | |
| 1323 | | INTERRUPT_GEN_MEMBER(c65_state::c65_frame_interrupt) |
| 1324 | | { |
| 1325 | | int value; |
| 1326 | | |
| 1327 | | c65_nmi(); |
| 1328 | | |
| 1329 | | /* common keys input ports */ |
| 1330 | | cbm_common_interrupt(&device); |
| 1331 | | |
| 1332 | | /* c65 specific: function keys input ports */ |
| 1333 | | value = 0xff; |
| 1334 | | |
| 1335 | | value &= ~ioport("FUNCT")->read(); |
| 1336 | | m_keyline = value; |
| 1337 | | } |
| 1338 | | |
trunk/src/osd/modules/font/font_sdl.c
| r243230 | r243231 | |
| 32 | 32 | class osd_font_sdl : public osd_font |
| 33 | 33 | { |
| 34 | 34 | public: |
| 35 | | virtual ~osd_font_sdl() {}; |
| 35 | virtual ~osd_font_sdl() {}; |
| 36 | 36 | |
| 37 | | virtual bool open(const char *font_path, const char *name, int &height); |
| 38 | | virtual void close(); |
| 39 | | virtual bool get_bitmap(unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs); |
| 37 | virtual bool open(const char *font_path, const char *name, int &height); |
| 38 | virtual void close(); |
| 39 | virtual bool get_bitmap(unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs); |
| 40 | 40 | private: |
| 41 | 41 | #ifndef SDLMAME_HAIKU |
| 42 | | TTF_Font *search_font_config(astring name, bool bold, bool italic, bool underline, bool &bakedstyles); |
| 42 | TTF_Font *search_font_config(astring name, bool bold, bool italic, bool underline, bool &bakedstyles); |
| 43 | 43 | #endif |
| 44 | | bool BDF_Check_Magic(astring name); |
| 45 | | TTF_Font * TTF_OpenFont_Magic(astring name, int fsize); |
| 46 | | TTF_Font *m_font; |
| 44 | bool BDF_Check_Magic(astring name); |
| 45 | TTF_Font * TTF_OpenFont_Magic(astring name, int fsize); |
| 46 | TTF_Font *m_font; |
| 47 | 47 | }; |
| 48 | 48 | |
| 49 | 49 | bool osd_font_sdl::open(const char *font_path, const char *_name, int &height) |
| 50 | 50 | { |
| 51 | | TTF_Font *font = (TTF_Font *)NULL; |
| 52 | | bool bakedstyles = false; |
| 53 | | int style = 0; |
| 51 | TTF_Font *font = (TTF_Font *)NULL; |
| 52 | bool bakedstyles = false; |
| 53 | int style = 0; |
| 54 | 54 | |
| 55 | | // accept qualifiers from the name |
| 56 | | astring name(_name); |
| 55 | // accept qualifiers from the name |
| 56 | astring name(_name); |
| 57 | 57 | |
| 58 | | if (name == "default") |
| 59 | | { |
| 60 | | name = "Liberation Sans"; |
| 61 | | } |
| 58 | if (name == "default") |
| 59 | { |
| 60 | name = "Liberation Sans"; |
| 61 | } |
| 62 | 62 | |
| 63 | | bool bold = (name.replace(0, "[B]", "") + name.replace(0, "[b]", "") > 0); |
| 64 | | bool italic = (name.replace(0, "[I]", "") + name.replace(0, "[i]", "") > 0); |
| 65 | | bool underline = (name.replace(0, "[U]", "") + name.replace(0, "[u]", "") > 0); |
| 66 | | bool strike = (name.replace(0, "[S]", "") + name.replace(0, "[s]", "") > 0); |
| 63 | bool bold = (name.replace(0, "[B]", "") + name.replace(0, "[b]", "") > 0); |
| 64 | bool italic = (name.replace(0, "[I]", "") + name.replace(0, "[i]", "") > 0); |
| 65 | bool underline = (name.replace(0, "[U]", "") + name.replace(0, "[u]", "") > 0); |
| 66 | bool strike = (name.replace(0, "[S]", "") + name.replace(0, "[s]", "") > 0); |
| 67 | 67 | |
| 68 | | // first up, try it as a filename |
| 69 | | font = TTF_OpenFont_Magic(name, POINT_SIZE); |
| 68 | // first up, try it as a filename |
| 69 | font = TTF_OpenFont_Magic(name, POINT_SIZE); |
| 70 | 70 | |
| 71 | | // if no success, try the font path |
| 71 | // if no success, try the font path |
| 72 | 72 | |
| 73 | | if (!font) |
| 74 | | { |
| 75 | | osd_printf_verbose("Searching font %s in -%s\n", name.cstr(), OPTION_FONTPATH); |
| 76 | | //emu_file file(options().font_path(), OPEN_FLAG_READ); |
| 77 | | emu_file file(font_path, OPEN_FLAG_READ); |
| 78 | | if (file.open(name) == FILERR_NONE) |
| 79 | | { |
| 80 | | astring full_name = file.fullpath(); |
| 81 | | font = TTF_OpenFont_Magic(full_name, POINT_SIZE); |
| 82 | | if (font) |
| 83 | | osd_printf_verbose("Found font %s\n", full_name.cstr()); |
| 84 | | } |
| 85 | | } |
| 73 | if (!font) |
| 74 | { |
| 75 | osd_printf_verbose("Searching font %s in -%s\n", name.cstr(), OPTION_FONTPATH); |
| 76 | //emu_file file(options().font_path(), OPEN_FLAG_READ); |
| 77 | emu_file file(font_path, OPEN_FLAG_READ); |
| 78 | if (file.open(name) == FILERR_NONE) |
| 79 | { |
| 80 | astring full_name = file.fullpath(); |
| 81 | font = TTF_OpenFont_Magic(full_name, POINT_SIZE); |
| 82 | if (font) |
| 83 | osd_printf_verbose("Found font %s\n", full_name.cstr()); |
| 84 | } |
| 85 | } |
| 86 | 86 | |
| 87 | | // if that didn't work, crank up the FontConfig database |
| 87 | // if that didn't work, crank up the FontConfig database |
| 88 | 88 | #ifndef SDLMAME_HAIKU |
| 89 | | if (!font) |
| 90 | | { |
| 91 | | font = search_font_config(name, bold, italic, underline, bakedstyles); |
| 92 | | } |
| 89 | if (!font) |
| 90 | { |
| 91 | font = search_font_config(name, bold, italic, underline, bakedstyles); |
| 92 | } |
| 93 | 93 | #endif |
| 94 | 94 | |
| 95 | | if (!font) |
| 96 | | { |
| 97 | | if (!BDF_Check_Magic(name)) |
| 98 | | { |
| 99 | | osd_printf_verbose("font %s is not TrueType or BDF, using MAME default\n", name.cstr()); |
| 100 | | } |
| 101 | | return NULL; |
| 102 | | } |
| 95 | if (!font) |
| 96 | { |
| 97 | if (!BDF_Check_Magic(name)) |
| 98 | { |
| 99 | osd_printf_verbose("font %s is not TrueType or BDF, using MAME default\n", name.cstr()); |
| 100 | } |
| 101 | return NULL; |
| 102 | } |
| 103 | 103 | |
| 104 | | // apply styles |
| 105 | | if (!bakedstyles) |
| 106 | | { |
| 107 | | style |= bold ? TTF_STYLE_BOLD : 0; |
| 108 | | style |= italic ? TTF_STYLE_ITALIC : 0; |
| 109 | | } |
| 110 | | style |= underline ? TTF_STYLE_UNDERLINE : 0; |
| 111 | | // SDL_ttf 2.0.9 and earlier does not define TTF_STYLE_STRIKETHROUGH |
| 104 | // apply styles |
| 105 | if (!bakedstyles) |
| 106 | { |
| 107 | style |= bold ? TTF_STYLE_BOLD : 0; |
| 108 | style |= italic ? TTF_STYLE_ITALIC : 0; |
| 109 | } |
| 110 | style |= underline ? TTF_STYLE_UNDERLINE : 0; |
| 111 | // SDL_ttf 2.0.9 and earlier does not define TTF_STYLE_STRIKETHROUGH |
| 112 | 112 | #if SDL_VERSIONNUM(TTF_MAJOR_VERSION, TTF_MINOR_VERSION, TTF_PATCHLEVEL) > SDL_VERSIONNUM(2,0,9) |
| 113 | | style |= strike ? TTF_STYLE_STRIKETHROUGH : 0; |
| 113 | style |= strike ? TTF_STYLE_STRIKETHROUGH : 0; |
| 114 | 114 | #else |
| 115 | | if (strike) |
| 116 | | osd_printf_warning("Ignoring strikethrough for SDL_TTF older than 2.0.10\n"); |
| 115 | if (strike) |
| 116 | osd_printf_warning("Ignoring strikethrough for SDL_TTF older than 2.0.10\n"); |
| 117 | 117 | #endif // PATCHLEVEL |
| 118 | | TTF_SetFontStyle(font, style); |
| 118 | TTF_SetFontStyle(font, style); |
| 119 | 119 | |
| 120 | | height = TTF_FontLineSkip(font); |
| 120 | height = TTF_FontLineSkip(font); |
| 121 | 121 | |
| 122 | | m_font = font; |
| 123 | | return true; |
| 122 | m_font = font; |
| 123 | return true; |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | //------------------------------------------------- |
| r243230 | r243231 | |
| 130 | 130 | |
| 131 | 131 | void osd_font_sdl::close() |
| 132 | 132 | { |
| 133 | | TTF_CloseFont(this->m_font); |
| 133 | TTF_CloseFont(this->m_font); |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | //------------------------------------------------- |
| r243230 | r243231 | |
| 143 | 143 | |
| 144 | 144 | bool osd_font_sdl::get_bitmap(unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs) |
| 145 | 145 | { |
| 146 | | TTF_Font *ttffont; |
| 147 | | SDL_Surface *drawsurf; |
| 148 | | SDL_Color fcol = { 0xff, 0xff, 0xff }; |
| 149 | | UINT16 ustr[16]; |
| 146 | TTF_Font *ttffont; |
| 147 | SDL_Surface *drawsurf; |
| 148 | SDL_Color fcol = { 0xff, 0xff, 0xff }; |
| 149 | UINT16 ustr[16]; |
| 150 | 150 | |
| 151 | | ttffont = m_font; |
| 151 | ttffont = m_font; |
| 152 | 152 | |
| 153 | | memset(ustr,0,sizeof(ustr)); |
| 154 | | ustr[0] = (UINT16)chnum; |
| 155 | | drawsurf = TTF_RenderUNICODE_Solid(ttffont, ustr, fcol); |
| 153 | memset(ustr,0,sizeof(ustr)); |
| 154 | ustr[0] = (UINT16)chnum; |
| 155 | drawsurf = TTF_RenderUNICODE_Solid(ttffont, ustr, fcol); |
| 156 | 156 | |
| 157 | | // was nothing returned? |
| 158 | | if (drawsurf) |
| 159 | | { |
| 160 | | // allocate a MAME destination bitmap |
| 161 | | bitmap.allocate(drawsurf->w, drawsurf->h); |
| 157 | // was nothing returned? |
| 158 | if (drawsurf) |
| 159 | { |
| 160 | // allocate a MAME destination bitmap |
| 161 | bitmap.allocate(drawsurf->w, drawsurf->h); |
| 162 | 162 | |
| 163 | | // copy the rendered character image into it |
| 164 | | for (int y = 0; y < bitmap.height(); y++) |
| 165 | | { |
| 166 | | UINT32 *dstrow = &bitmap.pix32(y); |
| 167 | | UINT8 *srcrow = (UINT8 *)drawsurf->pixels; |
| 163 | // copy the rendered character image into it |
| 164 | for (int y = 0; y < bitmap.height(); y++) |
| 165 | { |
| 166 | UINT32 *dstrow = &bitmap.pix32(y); |
| 167 | UINT8 *srcrow = (UINT8 *)drawsurf->pixels; |
| 168 | 168 | |
| 169 | | srcrow += (y * drawsurf->pitch); |
| 169 | srcrow += (y * drawsurf->pitch); |
| 170 | 170 | |
| 171 | | for (int x = 0; x < drawsurf->w; x++) |
| 172 | | { |
| 173 | | dstrow[x] = srcrow[x] ? rgb_t(0xff,0xff,0xff,0xff) : rgb_t(0x00,0xff,0xff,0xff); |
| 174 | | } |
| 175 | | } |
| 171 | for (int x = 0; x < drawsurf->w; x++) |
| 172 | { |
| 173 | dstrow[x] = srcrow[x] ? rgb_t(0xff,0xff,0xff,0xff) : rgb_t(0x00,0xff,0xff,0xff); |
| 174 | } |
| 175 | } |
| 176 | 176 | |
| 177 | | // what are these? |
| 178 | | xoffs = yoffs = 0; |
| 179 | | width = drawsurf->w; |
| 177 | // what are these? |
| 178 | xoffs = yoffs = 0; |
| 179 | width = drawsurf->w; |
| 180 | 180 | |
| 181 | | SDL_FreeSurface(drawsurf); |
| 182 | | } |
| 181 | SDL_FreeSurface(drawsurf); |
| 182 | } |
| 183 | 183 | |
| 184 | | return bitmap.valid(); |
| 184 | return bitmap.valid(); |
| 185 | 185 | } |
| 186 | 186 | |
| 187 | 187 | TTF_Font * osd_font_sdl::TTF_OpenFont_Magic(astring name, int fsize) |
| 188 | 188 | { |
| 189 | | emu_file file(OPEN_FLAG_READ); |
| 190 | | if (file.open(name) == FILERR_NONE) |
| 191 | | { |
| 192 | | unsigned char buffer[5] = { 0xff, 0xff, 0xff, 0xff, 0xff }; |
| 193 | | unsigned char magic[5] = { 0x00, 0x01, 0x00, 0x00, 0x00 }; |
| 194 | | file.read(buffer,5); |
| 195 | | if (memcmp(buffer, magic, 5)) |
| 196 | | return NULL; |
| 197 | | } |
| 198 | | return TTF_OpenFont(name.cstr(), POINT_SIZE); |
| 189 | emu_file file(OPEN_FLAG_READ); |
| 190 | if (file.open(name) == FILERR_NONE) |
| 191 | { |
| 192 | unsigned char buffer[5] = { 0xff, 0xff, 0xff, 0xff, 0xff }; |
| 193 | unsigned char magic[5] = { 0x00, 0x01, 0x00, 0x00, 0x00 }; |
| 194 | file.read(buffer,5); |
| 195 | if (memcmp(buffer, magic, 5)) |
| 196 | return NULL; |
| 197 | } |
| 198 | return TTF_OpenFont(name.cstr(), POINT_SIZE); |
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | bool osd_font_sdl::BDF_Check_Magic(astring name) |
| 202 | 202 | { |
| 203 | | emu_file file(OPEN_FLAG_READ); |
| 204 | | if (file.open(name) == FILERR_NONE) |
| 205 | | { |
| 206 | | unsigned char buffer[9]; |
| 207 | | unsigned char magic[9] = { 'S', 'T', 'A', 'R', 'T', 'F', 'O', 'N', 'T' }; |
| 208 | | file.read(buffer, 9); |
| 209 | | file.close(); |
| 210 | | if (!memcmp(buffer, magic, 9)) |
| 211 | | return true; |
| 212 | | } |
| 203 | emu_file file(OPEN_FLAG_READ); |
| 204 | if (file.open(name) == FILERR_NONE) |
| 205 | { |
| 206 | unsigned char buffer[9]; |
| 207 | unsigned char magic[9] = { 'S', 'T', 'A', 'R', 'T', 'F', 'O', 'N', 'T' }; |
| 208 | file.read(buffer, 9); |
| 209 | file.close(); |
| 210 | if (!memcmp(buffer, magic, 9)) |
| 211 | return true; |
| 212 | } |
| 213 | 213 | |
| 214 | | return false; |
| 214 | return false; |
| 215 | 215 | } |
| 216 | 216 | |
| 217 | 217 | #ifndef SDLMAME_HAIKU |
| 218 | 218 | TTF_Font *osd_font_sdl::search_font_config(astring name, bool bold, bool italic, bool underline, bool &bakedstyles) |
| 219 | 219 | { |
| 220 | | TTF_Font *font = (TTF_Font *)NULL; |
| 221 | | FcConfig *config; |
| 222 | | FcPattern *pat; |
| 223 | | FcObjectSet *os; |
| 224 | | FcFontSet *fontset; |
| 225 | | FcValue val; |
| 220 | TTF_Font *font = (TTF_Font *)NULL; |
| 221 | FcConfig *config; |
| 222 | FcPattern *pat; |
| 223 | FcObjectSet *os; |
| 224 | FcFontSet *fontset; |
| 225 | FcValue val; |
| 226 | 226 | |
| 227 | | config = FcConfigGetCurrent(); |
| 228 | | pat = FcPatternCreate(); |
| 229 | | os = FcObjectSetCreate(); |
| 230 | | FcPatternAddString(pat, FC_FAMILY, (const FcChar8 *)name.cstr()); |
| 227 | config = FcConfigGetCurrent(); |
| 228 | pat = FcPatternCreate(); |
| 229 | os = FcObjectSetCreate(); |
| 230 | FcPatternAddString(pat, FC_FAMILY, (const FcChar8 *)name.cstr()); |
| 231 | 231 | |
| 232 | | // try and get a font with the requested styles baked-in |
| 233 | | if (bold) |
| 234 | | { |
| 235 | | if (italic) |
| 236 | | { |
| 237 | | FcPatternAddString(pat, FC_STYLE, (const FcChar8 *)"Bold Italic"); |
| 238 | | } |
| 239 | | else |
| 240 | | { |
| 241 | | FcPatternAddString(pat, FC_STYLE, (const FcChar8 *)"Bold"); |
| 242 | | } |
| 243 | | } |
| 244 | | else if (italic) |
| 245 | | { |
| 246 | | FcPatternAddString(pat, FC_STYLE, (const FcChar8 *)"Italic"); |
| 247 | | } |
| 248 | | else |
| 249 | | { |
| 250 | | FcPatternAddString(pat, FC_STYLE, (const FcChar8 *)"Regular"); |
| 251 | | } |
| 232 | // try and get a font with the requested styles baked-in |
| 233 | if (bold) |
| 234 | { |
| 235 | if (italic) |
| 236 | { |
| 237 | FcPatternAddString(pat, FC_STYLE, (const FcChar8 *)"Bold Italic"); |
| 238 | } |
| 239 | else |
| 240 | { |
| 241 | FcPatternAddString(pat, FC_STYLE, (const FcChar8 *)"Bold"); |
| 242 | } |
| 243 | } |
| 244 | else if (italic) |
| 245 | { |
| 246 | FcPatternAddString(pat, FC_STYLE, (const FcChar8 *)"Italic"); |
| 247 | } |
| 248 | else |
| 249 | { |
| 250 | FcPatternAddString(pat, FC_STYLE, (const FcChar8 *)"Regular"); |
| 251 | } |
| 252 | 252 | |
| 253 | | FcPatternAddString(pat, FC_FONTFORMAT, (const FcChar8 *)"TrueType"); |
| 253 | FcPatternAddString(pat, FC_FONTFORMAT, (const FcChar8 *)"TrueType"); |
| 254 | 254 | |
| 255 | | FcObjectSetAdd(os, FC_FILE); |
| 256 | | fontset = FcFontList(config, pat, os); |
| 255 | FcObjectSetAdd(os, FC_FILE); |
| 256 | fontset = FcFontList(config, pat, os); |
| 257 | 257 | |
| 258 | | for (int i = 0; i < fontset->nfont; i++) |
| 259 | | { |
| 260 | | if (FcPatternGet(fontset->fonts[i], FC_FILE, 0, &val) != FcResultMatch) |
| 261 | | { |
| 262 | | continue; |
| 263 | | } |
| 258 | for (int i = 0; i < fontset->nfont; i++) |
| 259 | { |
| 260 | if (FcPatternGet(fontset->fonts[i], FC_FILE, 0, &val) != FcResultMatch) |
| 261 | { |
| 262 | continue; |
| 263 | } |
| 264 | 264 | |
| 265 | | if (val.type != FcTypeString) |
| 266 | | { |
| 267 | | continue; |
| 268 | | } |
| 265 | if (val.type != FcTypeString) |
| 266 | { |
| 267 | continue; |
| 268 | } |
| 269 | 269 | |
| 270 | | osd_printf_verbose("Matching font: %s\n", val.u.s); |
| 271 | | { |
| 272 | | astring match_name((const char*)val.u.s); |
| 273 | | font = TTF_OpenFont_Magic(match_name, POINT_SIZE); |
| 274 | | } |
| 270 | osd_printf_verbose("Matching font: %s\n", val.u.s); |
| 271 | { |
| 272 | astring match_name((const char*)val.u.s); |
| 273 | font = TTF_OpenFont_Magic(match_name, POINT_SIZE); |
| 274 | } |
| 275 | 275 | |
| 276 | | if (font) |
| 277 | | { |
| 278 | | bakedstyles = true; |
| 279 | | break; |
| 280 | | } |
| 281 | | } |
| 276 | if (font) |
| 277 | { |
| 278 | bakedstyles = true; |
| 279 | break; |
| 280 | } |
| 281 | } |
| 282 | 282 | |
| 283 | | // didn't get a font above? try again with no baked-in styles |
| 284 | | if (!font) |
| 285 | | { |
| 286 | | FcPatternDestroy(pat); |
| 287 | | FcFontSetDestroy(fontset); |
| 283 | // didn't get a font above? try again with no baked-in styles |
| 284 | if (!font) |
| 285 | { |
| 286 | FcPatternDestroy(pat); |
| 287 | FcFontSetDestroy(fontset); |
| 288 | 288 | |
| 289 | | pat = FcPatternCreate(); |
| 290 | | FcPatternAddString(pat, FC_FAMILY, (const FcChar8 *)name.cstr()); |
| 291 | | FcPatternAddString(pat, FC_STYLE, (const FcChar8 *)"Regular"); |
| 292 | | FcPatternAddString(pat, FC_FONTFORMAT, (const FcChar8 *)"TrueType"); |
| 293 | | fontset = FcFontList(config, pat, os); |
| 289 | pat = FcPatternCreate(); |
| 290 | FcPatternAddString(pat, FC_FAMILY, (const FcChar8 *)name.cstr()); |
| 291 | FcPatternAddString(pat, FC_STYLE, (const FcChar8 *)"Regular"); |
| 292 | FcPatternAddString(pat, FC_FONTFORMAT, (const FcChar8 *)"TrueType"); |
| 293 | fontset = FcFontList(config, pat, os); |
| 294 | 294 | |
| 295 | | for (int i = 0; i < fontset->nfont; i++) |
| 296 | | { |
| 297 | | if (FcPatternGet(fontset->fonts[i], FC_FILE, 0, &val) != FcResultMatch) |
| 298 | | { |
| 299 | | continue; |
| 300 | | } |
| 295 | for (int i = 0; i < fontset->nfont; i++) |
| 296 | { |
| 297 | if (FcPatternGet(fontset->fonts[i], FC_FILE, 0, &val) != FcResultMatch) |
| 298 | { |
| 299 | continue; |
| 300 | } |
| 301 | 301 | |
| 302 | | if (val.type != FcTypeString) |
| 303 | | { |
| 304 | | continue; |
| 305 | | } |
| 302 | if (val.type != FcTypeString) |
| 303 | { |
| 304 | continue; |
| 305 | } |
| 306 | 306 | |
| 307 | | osd_printf_verbose("Matching unstyled font: %s\n", val.u.s); |
| 308 | | { |
| 309 | | astring match_name((const char*)val.u.s); |
| 310 | | font = TTF_OpenFont_Magic(match_name, POINT_SIZE); |
| 311 | | } |
| 307 | osd_printf_verbose("Matching unstyled font: %s\n", val.u.s); |
| 308 | { |
| 309 | astring match_name((const char*)val.u.s); |
| 310 | font = TTF_OpenFont_Magic(match_name, POINT_SIZE); |
| 311 | } |
| 312 | 312 | |
| 313 | | if (font) |
| 314 | | { |
| 315 | | break; |
| 316 | | } |
| 317 | | } |
| 318 | | } |
| 313 | if (font) |
| 314 | { |
| 315 | break; |
| 316 | } |
| 317 | } |
| 318 | } |
| 319 | 319 | |
| 320 | | FcPatternDestroy(pat); |
| 321 | | FcObjectSetDestroy(os); |
| 322 | | FcFontSetDestroy(fontset); |
| 323 | | return font; |
| 320 | FcPatternDestroy(pat); |
| 321 | FcObjectSetDestroy(os); |
| 322 | FcFontSetDestroy(fontset); |
| 323 | return font; |
| 324 | 324 | } |
| 325 | 325 | #endif |
| 326 | 326 | |
| r243230 | r243231 | |
| 328 | 328 | class font_sdl : public osd_module, public font_module |
| 329 | 329 | { |
| 330 | 330 | public: |
| 331 | | font_sdl() |
| 332 | | : osd_module(OSD_FONT_PROVIDER, "sdl"), font_module() |
| 333 | | { |
| 334 | | } |
| 331 | font_sdl() |
| 332 | : osd_module(OSD_FONT_PROVIDER, "sdl"), font_module() |
| 333 | { |
| 334 | } |
| 335 | 335 | |
| 336 | | osd_font *font_alloc() |
| 337 | | { |
| 338 | | return global_alloc(osd_font_sdl); |
| 339 | | } |
| 336 | osd_font *font_alloc() |
| 337 | { |
| 338 | return global_alloc(osd_font_sdl); |
| 339 | } |
| 340 | 340 | |
| 341 | | int init() |
| 342 | | { |
| 343 | | if (TTF_Init() == -1) |
| 344 | | { |
| 345 | | osd_printf_error("SDL_ttf failed: %s\n", TTF_GetError()); |
| 346 | | return -1; |
| 347 | | } |
| 348 | | return 0; |
| 349 | | } |
| 341 | int init() |
| 342 | { |
| 343 | if (TTF_Init() == -1) |
| 344 | { |
| 345 | osd_printf_error("SDL_ttf failed: %s\n", TTF_GetError()); |
| 346 | return -1; |
| 347 | } |
| 348 | return 0; |
| 349 | } |
| 350 | 350 | |
| 351 | | virtual void exit() |
| 352 | | { |
| 353 | | TTF_Quit(); |
| 354 | | } |
| 351 | virtual void exit() |
| 352 | { |
| 353 | TTF_Quit(); |
| 354 | } |
| 355 | 355 | }; |
| 356 | 356 | #else /* SDLMAME_UNIX */ |
| 357 | | MODULE_NOT_SUPPORTED(font_sdl, OSD_FONT_PROVIDER, "sdl") |
| 357 | MODULE_NOT_SUPPORTED(font_sdl, OSD_FONT_PROVIDER, "sdl") |
| 358 | 358 | #endif |
| 359 | 359 | |
| 360 | 360 | MODULE_DEFINITION(FONT_SDL, font_sdl) |
| 361 | |
| 362 | |
trunk/src/osd/modules/font/font_windows.c
| r243230 | r243231 | |
| 34 | 34 | class osd_font_windows : public osd_font |
| 35 | 35 | { |
| 36 | 36 | public: |
| 37 | | virtual ~osd_font_windows() {}; |
| 37 | virtual ~osd_font_windows() {}; |
| 38 | 38 | |
| 39 | | virtual bool open(const char *font_path, const char *name, int &height); |
| 40 | | virtual void close(); |
| 41 | | virtual bool get_bitmap(unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs); |
| 39 | virtual bool open(const char *font_path, const char *name, int &height); |
| 40 | virtual void close(); |
| 41 | virtual bool get_bitmap(unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs); |
| 42 | 42 | private: |
| 43 | | HGDIOBJ m_font; |
| 43 | HGDIOBJ m_font; |
| 44 | 44 | }; |
| 45 | 45 | |
| 46 | 46 | bool osd_font_windows::open(const char *font_path, const char *_name, int &height) |
| 47 | 47 | { |
| 48 | | // accept qualifiers from the name |
| 49 | | astring name(_name); |
| 50 | | if (name == "default") name = "Tahoma"; |
| 51 | | bool bold = (name.replace(0, "[B]", "") + name.replace(0, "[b]", "") > 0); |
| 52 | | bool italic = (name.replace(0, "[I]", "") + name.replace(0, "[i]", "") > 0); |
| 48 | // accept qualifiers from the name |
| 49 | astring name(_name); |
| 50 | if (name == "default") name = "Tahoma"; |
| 51 | bool bold = (name.replace(0, "[B]", "") + name.replace(0, "[b]", "") > 0); |
| 52 | bool italic = (name.replace(0, "[I]", "") + name.replace(0, "[i]", "") > 0); |
| 53 | 53 | |
| 54 | | // build a basic LOGFONT description of what we want |
| 55 | | LOGFONT logfont; |
| 56 | | logfont.lfHeight = DEFAULT_FONT_HEIGHT; |
| 57 | | logfont.lfWidth = 0; |
| 58 | | logfont.lfEscapement = 0; |
| 59 | | logfont.lfOrientation = 0; |
| 60 | | logfont.lfWeight = bold ? FW_BOLD : FW_MEDIUM; |
| 61 | | logfont.lfItalic = italic; |
| 62 | | logfont.lfUnderline = FALSE; |
| 63 | | logfont.lfStrikeOut = FALSE; |
| 64 | | logfont.lfCharSet = ANSI_CHARSET; |
| 65 | | logfont.lfOutPrecision = OUT_DEFAULT_PRECIS; |
| 66 | | logfont.lfClipPrecision = CLIP_DEFAULT_PRECIS; |
| 67 | | logfont.lfQuality = NONANTIALIASED_QUALITY; |
| 68 | | logfont.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE; |
| 54 | // build a basic LOGFONT description of what we want |
| 55 | LOGFONT logfont; |
| 56 | logfont.lfHeight = DEFAULT_FONT_HEIGHT; |
| 57 | logfont.lfWidth = 0; |
| 58 | logfont.lfEscapement = 0; |
| 59 | logfont.lfOrientation = 0; |
| 60 | logfont.lfWeight = bold ? FW_BOLD : FW_MEDIUM; |
| 61 | logfont.lfItalic = italic; |
| 62 | logfont.lfUnderline = FALSE; |
| 63 | logfont.lfStrikeOut = FALSE; |
| 64 | logfont.lfCharSet = ANSI_CHARSET; |
| 65 | logfont.lfOutPrecision = OUT_DEFAULT_PRECIS; |
| 66 | logfont.lfClipPrecision = CLIP_DEFAULT_PRECIS; |
| 67 | logfont.lfQuality = NONANTIALIASED_QUALITY; |
| 68 | logfont.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE; |
| 69 | 69 | |
| 70 | | // copy in the face name |
| 71 | | TCHAR *face = tstring_from_utf8(name); |
| 72 | | _tcsncpy(logfont.lfFaceName, face, sizeof(logfont.lfFaceName) / sizeof(TCHAR)); |
| 73 | | logfont.lfFaceName[sizeof(logfont.lfFaceName) / sizeof(TCHAR)-1] = 0; |
| 74 | | osd_free(face); |
| 70 | // copy in the face name |
| 71 | TCHAR *face = tstring_from_utf8(name); |
| 72 | _tcsncpy(logfont.lfFaceName, face, sizeof(logfont.lfFaceName) / sizeof(TCHAR)); |
| 73 | logfont.lfFaceName[sizeof(logfont.lfFaceName) / sizeof(TCHAR)-1] = 0; |
| 74 | osd_free(face); |
| 75 | 75 | |
| 76 | | // create the font |
| 77 | | height = logfont.lfHeight; |
| 78 | | m_font = CreateFontIndirect(&logfont); |
| 79 | | if (m_font == NULL) |
| 80 | | return false; |
| 76 | // create the font |
| 77 | height = logfont.lfHeight; |
| 78 | m_font = CreateFontIndirect(&logfont); |
| 79 | if (m_font == NULL) |
| 80 | return false; |
| 81 | 81 | |
| 82 | | // select it into a temp DC and get the real font name |
| 83 | | HDC dummyDC = CreateCompatibleDC(NULL); |
| 84 | | HGDIOBJ oldfont = SelectObject(dummyDC, m_font); |
| 85 | | TCHAR realname[100]; |
| 86 | | GetTextFace(dummyDC, ARRAY_LENGTH(realname), realname); |
| 87 | | SelectObject(dummyDC, oldfont); |
| 88 | | DeleteDC(dummyDC); |
| 82 | // select it into a temp DC and get the real font name |
| 83 | HDC dummyDC = CreateCompatibleDC(NULL); |
| 84 | HGDIOBJ oldfont = SelectObject(dummyDC, m_font); |
| 85 | TCHAR realname[100]; |
| 86 | GetTextFace(dummyDC, ARRAY_LENGTH(realname), realname); |
| 87 | SelectObject(dummyDC, oldfont); |
| 88 | DeleteDC(dummyDC); |
| 89 | 89 | |
| 90 | | // if it doesn't match our request, fail |
| 91 | | char *utf = utf8_from_tstring(realname); |
| 92 | | int result = core_stricmp(utf, name); |
| 93 | | osd_free(utf); |
| 90 | // if it doesn't match our request, fail |
| 91 | char *utf = utf8_from_tstring(realname); |
| 92 | int result = core_stricmp(utf, name); |
| 93 | osd_free(utf); |
| 94 | 94 | |
| 95 | | // if we didn't match, nuke our font and fall back |
| 96 | | if (result != 0) |
| 97 | | { |
| 98 | | DeleteObject(m_font); |
| 99 | | m_font = NULL; |
| 100 | | return false; |
| 101 | | } |
| 102 | | return true; |
| 95 | // if we didn't match, nuke our font and fall back |
| 96 | if (result != 0) |
| 97 | { |
| 98 | DeleteObject(m_font); |
| 99 | m_font = NULL; |
| 100 | return false; |
| 101 | } |
| 102 | return true; |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | //------------------------------------------------- |
| r243230 | r243231 | |
| 109 | 109 | |
| 110 | 110 | void osd_font_windows::close() |
| 111 | 111 | { |
| 112 | | // delete the font ojbect |
| 113 | | if (m_font != NULL) |
| 114 | | DeleteObject(m_font); |
| 112 | // delete the font ojbect |
| 113 | if (m_font != NULL) |
| 114 | DeleteObject(m_font); |
| 115 | 115 | |
| 116 | 116 | } |
| 117 | 117 | |
| r243230 | r243231 | |
| 125 | 125 | |
| 126 | 126 | bool osd_font_windows::get_bitmap(unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs) |
| 127 | 127 | { |
| 128 | | // create a dummy DC to work with |
| 129 | | HDC dummyDC = CreateCompatibleDC(NULL); |
| 130 | | HGDIOBJ oldfont = SelectObject(dummyDC, m_font); |
| 128 | // create a dummy DC to work with |
| 129 | HDC dummyDC = CreateCompatibleDC(NULL); |
| 130 | HGDIOBJ oldfont = SelectObject(dummyDC, m_font); |
| 131 | 131 | |
| 132 | | // get the text metrics |
| 133 | | TEXTMETRIC metrics = { 0 }; |
| 134 | | GetTextMetrics(dummyDC, &metrics); |
| 132 | // get the text metrics |
| 133 | TEXTMETRIC metrics = { 0 }; |
| 134 | GetTextMetrics(dummyDC, &metrics); |
| 135 | 135 | |
| 136 | | // get the width of this character |
| 137 | | ABC abc; |
| 138 | | if (!GetCharABCWidths(dummyDC, chnum, chnum, &abc)) |
| 139 | | { |
| 140 | | abc.abcA = 0; |
| 141 | | abc.abcC = 0; |
| 142 | | GetCharWidth32(dummyDC, chnum, chnum, reinterpret_cast<LPINT>(&abc.abcB)); |
| 143 | | } |
| 144 | | width = abc.abcA + abc.abcB + abc.abcC; |
| 136 | // get the width of this character |
| 137 | ABC abc; |
| 138 | if (!GetCharABCWidths(dummyDC, chnum, chnum, &abc)) |
| 139 | { |
| 140 | abc.abcA = 0; |
| 141 | abc.abcC = 0; |
| 142 | GetCharWidth32(dummyDC, chnum, chnum, reinterpret_cast<LPINT>(&abc.abcB)); |
| 143 | } |
| 144 | width = abc.abcA + abc.abcB + abc.abcC; |
| 145 | 145 | |
| 146 | | // determine desired bitmap size |
| 147 | | int bmwidth = (50 + abc.abcA + abc.abcB + abc.abcC + 50 + 31) & ~31; |
| 148 | | int bmheight = 50 + metrics.tmHeight + 50; |
| 146 | // determine desired bitmap size |
| 147 | int bmwidth = (50 + abc.abcA + abc.abcB + abc.abcC + 50 + 31) & ~31; |
| 148 | int bmheight = 50 + metrics.tmHeight + 50; |
| 149 | 149 | |
| 150 | | // describe the bitmap we want |
| 151 | | BYTE bitmapinfodata[sizeof(BITMAPINFOHEADER)+2 * sizeof(RGBQUAD)] = { 0 }; |
| 152 | | BITMAPINFO &info = *reinterpret_cast<BITMAPINFO *>(bitmapinfodata); |
| 153 | | info.bmiHeader.biSize = sizeof(info.bmiHeader); |
| 154 | | info.bmiHeader.biWidth = bmwidth; |
| 155 | | info.bmiHeader.biHeight = -bmheight; |
| 156 | | info.bmiHeader.biPlanes = 1; |
| 157 | | info.bmiHeader.biBitCount = 1; |
| 158 | | info.bmiHeader.biCompression = BI_RGB; |
| 159 | | info.bmiHeader.biSizeImage = 0; |
| 160 | | info.bmiHeader.biXPelsPerMeter = GetDeviceCaps(dummyDC, HORZRES) / GetDeviceCaps(dummyDC, HORZSIZE); |
| 161 | | info.bmiHeader.biYPelsPerMeter = GetDeviceCaps(dummyDC, VERTRES) / GetDeviceCaps(dummyDC, VERTSIZE); |
| 162 | | info.bmiHeader.biClrUsed = 0; |
| 163 | | info.bmiHeader.biClrImportant = 0; |
| 164 | | RGBQUAD col1 = info.bmiColors[0]; |
| 165 | | RGBQUAD col2 = info.bmiColors[1]; |
| 166 | | col1.rgbBlue = col1.rgbGreen = col1.rgbRed = 0x00; |
| 167 | | col2.rgbBlue = col2.rgbGreen = col2.rgbRed = 0xff; |
| 150 | // describe the bitmap we want |
| 151 | BYTE bitmapinfodata[sizeof(BITMAPINFOHEADER)+2 * sizeof(RGBQUAD)] = { 0 }; |
| 152 | BITMAPINFO &info = *reinterpret_cast<BITMAPINFO *>(bitmapinfodata); |
| 153 | info.bmiHeader.biSize = sizeof(info.bmiHeader); |
| 154 | info.bmiHeader.biWidth = bmwidth; |
| 155 | info.bmiHeader.biHeight = -bmheight; |
| 156 | info.bmiHeader.biPlanes = 1; |
| 157 | info.bmiHeader.biBitCount = 1; |
| 158 | info.bmiHeader.biCompression = BI_RGB; |
| 159 | info.bmiHeader.biSizeImage = 0; |
| 160 | info.bmiHeader.biXPelsPerMeter = GetDeviceCaps(dummyDC, HORZRES) / GetDeviceCaps(dummyDC, HORZSIZE); |
| 161 | info.bmiHeader.biYPelsPerMeter = GetDeviceCaps(dummyDC, VERTRES) / GetDeviceCaps(dummyDC, VERTSIZE); |
| 162 | info.bmiHeader.biClrUsed = 0; |
| 163 | info.bmiHeader.biClrImportant = 0; |
| 164 | RGBQUAD col1 = info.bmiColors[0]; |
| 165 | RGBQUAD col2 = info.bmiColors[1]; |
| 166 | col1.rgbBlue = col1.rgbGreen = col1.rgbRed = 0x00; |
| 167 | col2.rgbBlue = col2.rgbGreen = col2.rgbRed = 0xff; |
| 168 | 168 | |
| 169 | | // create a DIB to render to |
| 170 | | BYTE *bits; |
| 171 | | HBITMAP dib = CreateDIBSection(dummyDC, &info, DIB_RGB_COLORS, reinterpret_cast<VOID **>(&bits), NULL, 0); |
| 172 | | HGDIOBJ oldbitmap = SelectObject(dummyDC, dib); |
| 169 | // create a DIB to render to |
| 170 | BYTE *bits; |
| 171 | HBITMAP dib = CreateDIBSection(dummyDC, &info, DIB_RGB_COLORS, reinterpret_cast<VOID **>(&bits), NULL, 0); |
| 172 | HGDIOBJ oldbitmap = SelectObject(dummyDC, dib); |
| 173 | 173 | |
| 174 | | // clear the bitmap |
| 175 | | int rowbytes = bmwidth / 8; |
| 176 | | memset(bits, 0, rowbytes * bmheight); |
| 174 | // clear the bitmap |
| 175 | int rowbytes = bmwidth / 8; |
| 176 | memset(bits, 0, rowbytes * bmheight); |
| 177 | 177 | |
| 178 | | // now draw the character |
| 179 | | WCHAR tempchar = chnum; |
| 180 | | SetTextColor(dummyDC, RGB(0xff, 0xff, 0xff)); |
| 181 | | SetBkColor(dummyDC, RGB(0x00, 0x00, 0x00)); |
| 182 | | ExtTextOutW(dummyDC, 50 + abc.abcA, 50, ETO_OPAQUE, NULL, &tempchar, 1, NULL); |
| 178 | // now draw the character |
| 179 | WCHAR tempchar = chnum; |
| 180 | SetTextColor(dummyDC, RGB(0xff, 0xff, 0xff)); |
| 181 | SetBkColor(dummyDC, RGB(0x00, 0x00, 0x00)); |
| 182 | ExtTextOutW(dummyDC, 50 + abc.abcA, 50, ETO_OPAQUE, NULL, &tempchar, 1, NULL); |
| 183 | 183 | |
| 184 | | // characters are expected to be full-height |
| 185 | | rectangle actbounds; |
| 186 | | actbounds.min_y = 50; |
| 187 | | actbounds.max_y = 50 + metrics.tmHeight - 1; |
| 184 | // characters are expected to be full-height |
| 185 | rectangle actbounds; |
| 186 | actbounds.min_y = 50; |
| 187 | actbounds.max_y = 50 + metrics.tmHeight - 1; |
| 188 | 188 | |
| 189 | | // determine the actual left of the character |
| 190 | | for (actbounds.min_x = 0; actbounds.min_x < rowbytes; actbounds.min_x++) |
| 191 | | { |
| 192 | | BYTE *offs = bits + actbounds.min_x; |
| 193 | | UINT8 summary = 0; |
| 194 | | for (int y = 0; y < bmheight; y++) |
| 195 | | summary |= offs[y * rowbytes]; |
| 196 | | if (summary != 0) |
| 197 | | { |
| 198 | | actbounds.min_x *= 8; |
| 199 | | if (!(summary & 0x80)) actbounds.min_x++; |
| 200 | | if (!(summary & 0xc0)) actbounds.min_x++; |
| 201 | | if (!(summary & 0xe0)) actbounds.min_x++; |
| 202 | | if (!(summary & 0xf0)) actbounds.min_x++; |
| 203 | | if (!(summary & 0xf8)) actbounds.min_x++; |
| 204 | | if (!(summary & 0xfc)) actbounds.min_x++; |
| 205 | | if (!(summary & 0xfe)) actbounds.min_x++; |
| 206 | | break; |
| 207 | | } |
| 208 | | } |
| 189 | // determine the actual left of the character |
| 190 | for (actbounds.min_x = 0; actbounds.min_x < rowbytes; actbounds.min_x++) |
| 191 | { |
| 192 | BYTE *offs = bits + actbounds.min_x; |
| 193 | UINT8 summary = 0; |
| 194 | for (int y = 0; y < bmheight; y++) |
| 195 | summary |= offs[y * rowbytes]; |
| 196 | if (summary != 0) |
| 197 | { |
| 198 | actbounds.min_x *= 8; |
| 199 | if (!(summary & 0x80)) actbounds.min_x++; |
| 200 | if (!(summary & 0xc0)) actbounds.min_x++; |
| 201 | if (!(summary & 0xe0)) actbounds.min_x++; |
| 202 | if (!(summary & 0xf0)) actbounds.min_x++; |
| 203 | if (!(summary & 0xf8)) actbounds.min_x++; |
| 204 | if (!(summary & 0xfc)) actbounds.min_x++; |
| 205 | if (!(summary & 0xfe)) actbounds.min_x++; |
| 206 | break; |
| 207 | } |
| 208 | } |
| 209 | 209 | |
| 210 | | // determine the actual right of the character |
| 211 | | for (actbounds.max_x = rowbytes - 1; actbounds.max_x >= 0; actbounds.max_x--) |
| 212 | | { |
| 213 | | BYTE *offs = bits + actbounds.max_x; |
| 214 | | UINT8 summary = 0; |
| 215 | | for (int y = 0; y < bmheight; y++) |
| 216 | | summary |= offs[y * rowbytes]; |
| 217 | | if (summary != 0) |
| 218 | | { |
| 219 | | actbounds.max_x *= 8; |
| 220 | | if (summary & 0x7f) actbounds.max_x++; |
| 221 | | if (summary & 0x3f) actbounds.max_x++; |
| 222 | | if (summary & 0x1f) actbounds.max_x++; |
| 223 | | if (summary & 0x0f) actbounds.max_x++; |
| 224 | | if (summary & 0x07) actbounds.max_x++; |
| 225 | | if (summary & 0x03) actbounds.max_x++; |
| 226 | | if (summary & 0x01) actbounds.max_x++; |
| 227 | | break; |
| 228 | | } |
| 229 | | } |
| 210 | // determine the actual right of the character |
| 211 | for (actbounds.max_x = rowbytes - 1; actbounds.max_x >= 0; actbounds.max_x--) |
| 212 | { |
| 213 | BYTE *offs = bits + actbounds.max_x; |
| 214 | UINT8 summary = 0; |
| 215 | for (int y = 0; y < bmheight; y++) |
| 216 | summary |= offs[y * rowbytes]; |
| 217 | if (summary != 0) |
| 218 | { |
| 219 | actbounds.max_x *= 8; |
| 220 | if (summary & 0x7f) actbounds.max_x++; |
| 221 | if (summary & 0x3f) actbounds.max_x++; |
| 222 | if (summary & 0x1f) actbounds.max_x++; |
| 223 | if (summary & 0x0f) actbounds.max_x++; |
| 224 | if (summary & 0x07) actbounds.max_x++; |
| 225 | if (summary & 0x03) actbounds.max_x++; |
| 226 | if (summary & 0x01) actbounds.max_x++; |
| 227 | break; |
| 228 | } |
| 229 | } |
| 230 | 230 | |
| 231 | | // allocate a new bitmap |
| 232 | | if (actbounds.max_x >= actbounds.min_x && actbounds.max_y >= actbounds.min_y) |
| 233 | | { |
| 234 | | bitmap.allocate(actbounds.max_x + 1 - actbounds.min_x, actbounds.max_y + 1 - actbounds.min_y); |
| 231 | // allocate a new bitmap |
| 232 | if (actbounds.max_x >= actbounds.min_x && actbounds.max_y >= actbounds.min_y) |
| 233 | { |
| 234 | bitmap.allocate(actbounds.max_x + 1 - actbounds.min_x, actbounds.max_y + 1 - actbounds.min_y); |
| 235 | 235 | |
| 236 | | // copy the bits into it |
| 237 | | for (int y = 0; y < bitmap.height(); y++) |
| 238 | | { |
| 239 | | UINT32 *dstrow = &bitmap.pix32(y); |
| 240 | | UINT8 *srcrow = &bits[(y + actbounds.min_y) * rowbytes]; |
| 241 | | for (int x = 0; x < bitmap.width(); x++) |
| 242 | | { |
| 243 | | int effx = x + actbounds.min_x; |
| 244 | | dstrow[x] = ((srcrow[effx / 8] << (effx % 8)) & 0x80) ? rgb_t(0xff, 0xff, 0xff, 0xff) : rgb_t(0x00, 0xff, 0xff, 0xff); |
| 245 | | } |
| 246 | | } |
| 236 | // copy the bits into it |
| 237 | for (int y = 0; y < bitmap.height(); y++) |
| 238 | { |
| 239 | UINT32 *dstrow = &bitmap.pix32(y); |
| 240 | UINT8 *srcrow = &bits[(y + actbounds.min_y) * rowbytes]; |
| 241 | for (int x = 0; x < bitmap.width(); x++) |
| 242 | { |
| 243 | int effx = x + actbounds.min_x; |
| 244 | dstrow[x] = ((srcrow[effx / 8] << (effx % 8)) & 0x80) ? rgb_t(0xff, 0xff, 0xff, 0xff) : rgb_t(0x00, 0xff, 0xff, 0xff); |
| 245 | } |
| 246 | } |
| 247 | 247 | |
| 248 | | // set the final offset values |
| 249 | | xoffs = actbounds.min_x - (50 + abc.abcA); |
| 250 | | yoffs = actbounds.max_y - (50 + metrics.tmAscent); |
| 251 | | } |
| 248 | // set the final offset values |
| 249 | xoffs = actbounds.min_x - (50 + abc.abcA); |
| 250 | yoffs = actbounds.max_y - (50 + metrics.tmAscent); |
| 251 | } |
| 252 | 252 | |
| 253 | | // de-select the font and release the DC |
| 254 | | SelectObject(dummyDC, oldbitmap); |
| 255 | | DeleteObject(dib); |
| 256 | | SelectObject(dummyDC, oldfont); |
| 257 | | DeleteDC(dummyDC); |
| 258 | | return bitmap.valid(); |
| 253 | // de-select the font and release the DC |
| 254 | SelectObject(dummyDC, oldbitmap); |
| 255 | DeleteObject(dib); |
| 256 | SelectObject(dummyDC, oldfont); |
| 257 | DeleteDC(dummyDC); |
| 258 | return bitmap.valid(); |
| 259 | 259 | } |
| 260 | 260 | |
| 261 | 261 | class font_win : public osd_module, public font_module |
| 262 | 262 | { |
| 263 | 263 | public: |
| 264 | | font_win() |
| 265 | | : osd_module(OSD_FONT_PROVIDER, "win"), font_module() |
| 266 | | { |
| 267 | | } |
| 264 | font_win() |
| 265 | : osd_module(OSD_FONT_PROVIDER, "win"), font_module() |
| 266 | { |
| 267 | } |
| 268 | 268 | |
| 269 | | osd_font *font_alloc() |
| 270 | | { |
| 271 | | return global_alloc(osd_font_windows); |
| 272 | | } |
| 269 | osd_font *font_alloc() |
| 270 | { |
| 271 | return global_alloc(osd_font_windows); |
| 272 | } |
| 273 | 273 | |
| 274 | 274 | }; |
| 275 | 275 | #else /* SDLMAME_UNIX */ |
| 276 | | MODULE_NOT_SUPPORTED(font_win, OSD_FONT_PROVIDER, "win") |
| 276 | MODULE_NOT_SUPPORTED(font_win, OSD_FONT_PROVIDER, "win") |
| 277 | 277 | #endif |
| 278 | 278 | |
| 279 | 279 | MODULE_DEFINITION(FONT_WINDOWS, font_win) |
trunk/src/osd/modules/lib/osdobj_common.c
| r243230 | r243231 | |
| 17 | 17 | |
| 18 | 18 | const options_entry osd_options::s_option_entries[] = |
| 19 | 19 | { |
| 20 | | { NULL, NULL, OPTION_HEADER, "OSD FONT OPTIONS" }, |
| 21 | | { OSD_FONT_PROVIDER, "auto", OPTION_STRING, "provider for ui font: " }, |
| 20 | { NULL, NULL, OPTION_HEADER, "OSD FONT OPTIONS" }, |
| 21 | { OSD_FONT_PROVIDER, "auto", OPTION_STRING, "provider for ui font: " }, |
| 22 | 22 | |
| 23 | | { NULL, NULL, OPTION_HEADER, "OSD CLI OPTIONS" }, |
| 24 | | { OSDCOMMAND_LIST_MIDI_DEVICES ";mlist", "0", OPTION_COMMAND, "list available MIDI I/O devices" }, |
| 25 | | { OSDCOMMAND_LIST_NETWORK_ADAPTERS ";nlist", "0", OPTION_COMMAND, "list available network adapters" }, |
| 23 | { NULL, NULL, OPTION_HEADER, "OSD CLI OPTIONS" }, |
| 24 | { OSDCOMMAND_LIST_MIDI_DEVICES ";mlist", "0", OPTION_COMMAND, "list available MIDI I/O devices" }, |
| 25 | { OSDCOMMAND_LIST_NETWORK_ADAPTERS ";nlist", "0", OPTION_COMMAND, "list available network adapters" }, |
| 26 | 26 | |
| 27 | | // debugging options |
| 28 | | { NULL, NULL, OPTION_HEADER, "OSD DEBUGGING OPTIONS" }, |
| 29 | | { OSDOPTION_DEBUGGER, OSDOPTVAL_AUTO, OPTION_STRING, "debugger used : " }, |
| 30 | | { OSDOPTION_WATCHDOG ";wdog", "0", OPTION_INTEGER, "force the program to terminate if no updates within specified number of seconds" }, |
| 27 | // debugging options |
| 28 | { NULL, NULL, OPTION_HEADER, "OSD DEBUGGING OPTIONS" }, |
| 29 | { OSDOPTION_DEBUGGER, OSDOPTVAL_AUTO, OPTION_STRING, "debugger used : " }, |
| 30 | { OSDOPTION_WATCHDOG ";wdog", "0", OPTION_INTEGER, "force the program to terminate if no updates within specified number of seconds" }, |
| 31 | 31 | |
| 32 | | // performance options |
| 33 | | { NULL, NULL, OPTION_HEADER, "OSD PERFORMANCE OPTIONS" }, |
| 34 | | { OSDOPTION_MULTITHREADING ";mt", "0", OPTION_BOOLEAN, "enable multithreading; this enables rendering and blitting on a separate thread" }, |
| 35 | | { OSDOPTION_NUMPROCESSORS ";np", OSDOPTVAL_AUTO, OPTION_STRING, "number of processors; this overrides the number the system reports" }, |
| 36 | | { OSDOPTION_BENCH, "0", OPTION_INTEGER, "benchmark for the given number of emulated seconds; implies -video none -sound none -nothrottle" }, |
| 37 | | // video options |
| 38 | | { NULL, NULL, OPTION_HEADER, "OSD VIDEO OPTIONS" }, |
| 32 | // performance options |
| 33 | { NULL, NULL, OPTION_HEADER, "OSD PERFORMANCE OPTIONS" }, |
| 34 | { OSDOPTION_MULTITHREADING ";mt", "0", OPTION_BOOLEAN, "enable multithreading; this enables rendering and blitting on a separate thread" }, |
| 35 | { OSDOPTION_NUMPROCESSORS ";np", OSDOPTVAL_AUTO, OPTION_STRING, "number of processors; this overrides the number the system reports" }, |
| 36 | { OSDOPTION_BENCH, "0", OPTION_INTEGER, "benchmark for the given number of emulated seconds; implies -video none -sound none -nothrottle" }, |
| 37 | // video options |
| 38 | { NULL, NULL, OPTION_HEADER, "OSD VIDEO OPTIONS" }, |
| 39 | 39 | // OS X can be trusted to have working hardware OpenGL, so default to it on for the best user experience |
| 40 | | { OSDOPTION_VIDEO, OSDOPTVAL_AUTO, OPTION_STRING, "video output method: " }, |
| 41 | | { OSDOPTION_NUMSCREENS "(1-4)", "1", OPTION_INTEGER, "number of screens to create; usually, you want just one" }, |
| 42 | | { OSDOPTION_WINDOW ";w", "0", OPTION_BOOLEAN, "enable window mode; otherwise, full screen mode is assumed" }, |
| 43 | | { OSDOPTION_MAXIMIZE ";max", "1", OPTION_BOOLEAN, "default to maximized windows; otherwise, windows will be minimized" }, |
| 44 | | { OSDOPTION_KEEPASPECT ";ka", "1", OPTION_BOOLEAN, "constrain to the proper aspect ratio" }, |
| 45 | | { OSDOPTION_UNEVENSTRETCH ";ues", "1", OPTION_BOOLEAN, "allow non-integer stretch factors" }, |
| 46 | | { OSDOPTION_WAITVSYNC ";vs", "0", OPTION_BOOLEAN, "enable waiting for the start of VBLANK before flipping screens; reduces tearing effects" }, |
| 47 | | { OSDOPTION_SYNCREFRESH ";srf", "0", OPTION_BOOLEAN, "enable using the start of VBLANK for throttling instead of the game time" }, |
| 40 | { OSDOPTION_VIDEO, OSDOPTVAL_AUTO, OPTION_STRING, "video output method: " }, |
| 41 | { OSDOPTION_NUMSCREENS "(1-4)", "1", OPTION_INTEGER, "number of screens to create; usually, you want just one" }, |
| 42 | { OSDOPTION_WINDOW ";w", "0", OPTION_BOOLEAN, "enable window mode; otherwise, full screen mode is assumed" }, |
| 43 | { OSDOPTION_MAXIMIZE ";max", "1", OPTION_BOOLEAN, "default to maximized windows; otherwise, windows will be minimized" }, |
| 44 | { OSDOPTION_KEEPASPECT ";ka", "1", OPTION_BOOLEAN, "constrain to the proper aspect ratio" }, |
| 45 | { OSDOPTION_UNEVENSTRETCH ";ues", "1", OPTION_BOOLEAN, "allow non-integer stretch factors" }, |
| 46 | { OSDOPTION_WAITVSYNC ";vs", "0", OPTION_BOOLEAN, "enable waiting for the start of VBLANK before flipping screens; reduces tearing effects" }, |
| 47 | { OSDOPTION_SYNCREFRESH ";srf", "0", OPTION_BOOLEAN, "enable using the start of VBLANK for throttling instead of the game time" }, |
| 48 | 48 | |
| 49 | | // per-window options |
| 50 | | { NULL, NULL, OPTION_HEADER, "OSD PER-WINDOW VIDEO OPTIONS" }, |
| 51 | | { OSDOPTION_SCREEN, OSDOPTVAL_AUTO, OPTION_STRING, "explicit name of the first screen; 'auto' here will try to make a best guess" }, |
| 52 | | { OSDOPTION_ASPECT ";screen_aspect", OSDOPTVAL_AUTO, OPTION_STRING, "aspect ratio for all screens; 'auto' here will try to make a best guess" }, |
| 53 | | { OSDOPTION_RESOLUTION ";r", OSDOPTVAL_AUTO, OPTION_STRING, "preferred resolution for all screens; format is <width>x<height>[@<refreshrate>] or 'auto'" }, |
| 54 | | { OSDOPTION_VIEW, OSDOPTVAL_AUTO, OPTION_STRING, "preferred view for all screens" }, |
| 49 | // per-window options |
| 50 | { NULL, NULL, OPTION_HEADER, "OSD PER-WINDOW VIDEO OPTIONS" }, |
| 51 | { OSDOPTION_SCREEN, OSDOPTVAL_AUTO, OPTION_STRING, "explicit name of the first screen; 'auto' here will try to make a best guess" }, |
| 52 | { OSDOPTION_ASPECT ";screen_aspect", OSDOPTVAL_AUTO, OPTION_STRING, "aspect ratio for all screens; 'auto' here will try to make a best guess" }, |
| 53 | { OSDOPTION_RESOLUTION ";r", OSDOPTVAL_AUTO, OPTION_STRING, "preferred resolution for all screens; format is <width>x<height>[@<refreshrate>] or 'auto'" }, |
| 54 | { OSDOPTION_VIEW, OSDOPTVAL_AUTO, OPTION_STRING, "preferred view for all screens" }, |
| 55 | 55 | |
| 56 | | { OSDOPTION_SCREEN "0", OSDOPTVAL_AUTO, OPTION_STRING, "explicit name of the first screen; 'auto' here will try to make a best guess" }, |
| 57 | | { OSDOPTION_ASPECT "0", OSDOPTVAL_AUTO, OPTION_STRING, "aspect ratio of the first screen; 'auto' here will try to make a best guess" }, |
| 58 | | { OSDOPTION_RESOLUTION "0;r0", OSDOPTVAL_AUTO, OPTION_STRING, "preferred resolution of the first screen; format is <width>x<height>[@<refreshrate>] or 'auto'" }, |
| 59 | | { OSDOPTION_VIEW "0", OSDOPTVAL_AUTO, OPTION_STRING, "preferred view for the first screen" }, |
| 56 | { OSDOPTION_SCREEN "0", OSDOPTVAL_AUTO, OPTION_STRING, "explicit name of the first screen; 'auto' here will try to make a best guess" }, |
| 57 | { OSDOPTION_ASPECT "0", OSDOPTVAL_AUTO, OPTION_STRING, "aspect ratio of the first screen; 'auto' here will try to make a best guess" }, |
| 58 | { OSDOPTION_RESOLUTION "0;r0", OSDOPTVAL_AUTO, OPTION_STRING, "preferred resolution of the first screen; format is <width>x<height>[@<refreshrate>] or 'auto'" }, |
| 59 | { OSDOPTION_VIEW "0", OSDOPTVAL_AUTO, OPTION_STRING, "preferred view for the first screen" }, |
| 60 | 60 | |
| 61 | | { OSDOPTION_SCREEN "1", OSDOPTVAL_AUTO, OPTION_STRING, "explicit name of the second screen; 'auto' here will try to make a best guess" }, |
| 62 | | { OSDOPTION_ASPECT "1", OSDOPTVAL_AUTO, OPTION_STRING, "aspect ratio of the second screen; 'auto' here will try to make a best guess" }, |
| 63 | | { OSDOPTION_RESOLUTION "1;r1", OSDOPTVAL_AUTO, OPTION_STRING, "preferred resolution of the second screen; format is <width>x<height>[@<refreshrate>] or 'auto'" }, |
| 64 | | { OSDOPTION_VIEW "1", OSDOPTVAL_AUTO, OPTION_STRING, "preferred view for the second screen" }, |
| 61 | { OSDOPTION_SCREEN "1", OSDOPTVAL_AUTO, OPTION_STRING, "explicit name of the second screen; 'auto' here will try to make a best guess" }, |
| 62 | { OSDOPTION_ASPECT "1", OSDOPTVAL_AUTO, OPTION_STRING, "aspect ratio of the second screen; 'auto' here will try to make a best guess" }, |
| 63 | { OSDOPTION_RESOLUTION "1;r1", OSDOPTVAL_AUTO, OPTION_STRING, "preferred resolution of the second screen; format is <width>x<height>[@<refreshrate>] or 'auto'" }, |
| 64 | { OSDOPTION_VIEW "1", OSDOPTVAL_AUTO, OPTION_STRING, "preferred view for the second screen" }, |
| 65 | 65 | |
| 66 | | { OSDOPTION_SCREEN "2", OSDOPTVAL_AUTO, OPTION_STRING, "explicit name of the third screen; 'auto' here will try to make a best guess" }, |
| 67 | | { OSDOPTION_ASPECT "2", OSDOPTVAL_AUTO, OPTION_STRING, "aspect ratio of the third screen; 'auto' here will try to make a best guess" }, |
| 68 | | { OSDOPTION_RESOLUTION "2;r2", OSDOPTVAL_AUTO, OPTION_STRING, "preferred resolution of the third screen; format is <width>x<height>[@<refreshrate>] or 'auto'" }, |
| 69 | | { OSDOPTION_VIEW "2", OSDOPTVAL_AUTO, OPTION_STRING, "preferred view for the third screen" }, |
| 66 | { OSDOPTION_SCREEN "2", OSDOPTVAL_AUTO, OPTION_STRING, "explicit name of the third screen; 'auto' here will try to make a best guess" }, |
| 67 | { OSDOPTION_ASPECT "2", OSDOPTVAL_AUTO, OPTION_STRING, "aspect ratio of the third screen; 'auto' here will try to make a best guess" }, |
| 68 | { OSDOPTION_RESOLUTION "2;r2", OSDOPTVAL_AUTO, OPTION_STRING, "preferred resolution of the third screen; format is <width>x<height>[@<refreshrate>] or 'auto'" }, |
| 69 | { OSDOPTION_VIEW "2", OSDOPTVAL_AUTO, OPTION_STRING, "preferred view for the third screen" }, |
| 70 | 70 | |
| 71 | | { OSDOPTION_SCREEN "3", OSDOPTVAL_AUTO, OPTION_STRING, "explicit name of the fourth screen; 'auto' here will try to make a best guess" }, |
| 72 | | { OSDOPTION_ASPECT "3", OSDOPTVAL_AUTO, OPTION_STRING, "aspect ratio of the fourth screen; 'auto' here will try to make a best guess" }, |
| 73 | | { OSDOPTION_RESOLUTION "3;r3", OSDOPTVAL_AUTO, OPTION_STRING, "preferred resolution of the fourth screen; format is <width>x<height>[@<refreshrate>] or 'auto'" }, |
| 74 | | { OSDOPTION_VIEW "3", OSDOPTVAL_AUTO, OPTION_STRING, "preferred view for the fourth screen" }, |
| 71 | { OSDOPTION_SCREEN "3", OSDOPTVAL_AUTO, OPTION_STRING, "explicit name of the fourth screen; 'auto' here will try to make a best guess" }, |
| 72 | { OSDOPTION_ASPECT "3", OSDOPTVAL_AUTO, OPTION_STRING, "aspect ratio of the fourth screen; 'auto' here will try to make a best guess" }, |
| 73 | { OSDOPTION_RESOLUTION "3;r3", OSDOPTVAL_AUTO, OPTION_STRING, "preferred resolution of the fourth screen; format is <width>x<height>[@<refreshrate>] or 'auto'" }, |
| 74 | { OSDOPTION_VIEW "3", OSDOPTVAL_AUTO, OPTION_STRING, "preferred view for the fourth screen" }, |
| 75 | 75 | |
| 76 | | // full screen options |
| 77 | | { NULL, NULL, OPTION_HEADER, "OSD FULL SCREEN OPTIONS" }, |
| 78 | | { OSDOPTION_SWITCHRES, "0", OPTION_BOOLEAN, "enable resolution switching" }, |
| 76 | // full screen options |
| 77 | { NULL, NULL, OPTION_HEADER, "OSD FULL SCREEN OPTIONS" }, |
| 78 | { OSDOPTION_SWITCHRES, "0", OPTION_BOOLEAN, "enable resolution switching" }, |
| 79 | 79 | |
| 80 | | // sound options |
| 81 | | { NULL, NULL, OPTION_HEADER, "OSD SOUND OPTIONS" }, |
| 82 | | { OSDOPTION_SOUND, OSDOPTVAL_AUTO, OPTION_STRING, "sound output method: " }, |
| 83 | | { OSDOPTION_AUDIO_LATENCY "(1-5)", "2", OPTION_INTEGER, "set audio latency (increase to reduce glitches, decrease for responsiveness)" }, |
| 80 | // sound options |
| 81 | { NULL, NULL, OPTION_HEADER, "OSD SOUND OPTIONS" }, |
| 82 | { OSDOPTION_SOUND, OSDOPTVAL_AUTO, OPTION_STRING, "sound output method: " }, |
| 83 | { OSDOPTION_AUDIO_LATENCY "(1-5)", "2", OPTION_INTEGER, "set audio latency (increase to reduce glitches, decrease for responsiveness)" }, |
| 84 | 84 | |
| 85 | | // End of list |
| 86 | | { NULL } |
| 85 | // End of list |
| 86 | { NULL } |
| 87 | 87 | }; |
| 88 | 88 | |
| 89 | 89 | osd_options::osd_options() |
| 90 | 90 | : cli_options() |
| 91 | 91 | { |
| 92 | | add_entries(osd_options::s_option_entries); |
| 92 | add_entries(osd_options::s_option_entries); |
| 93 | 93 | }; |
| 94 | 94 | |
| 95 | 95 | |
| r243230 | r243231 | |
| 99 | 99 | |
| 100 | 100 | osd_common_t::osd_common_t(osd_options &options) |
| 101 | 101 | : m_machine(NULL), |
| 102 | | m_options(options), |
| 103 | | m_sound(NULL), |
| 104 | | m_debugger(NULL) |
| 102 | m_options(options), |
| 103 | m_sound(NULL), |
| 104 | m_debugger(NULL) |
| 105 | 105 | |
| 106 | 106 | { |
| 107 | 107 | } |
| r243230 | r243231 | |
| 110 | 110 | |
| 111 | 111 | void osd_common_t::register_options() |
| 112 | 112 | { |
| 113 | | REGISTER_MODULE(m_mod_man, FONT_OSX); |
| 114 | | REGISTER_MODULE(m_mod_man, FONT_WINDOWS); |
| 115 | | REGISTER_MODULE(m_mod_man, FONT_SDL); |
| 116 | | REGISTER_MODULE(m_mod_man, FONT_NONE); |
| 117 | 113 | |
| 118 | | REGISTER_MODULE(m_mod_man, SOUND_DSOUND); |
| 119 | | REGISTER_MODULE(m_mod_man, SOUND_JS); |
| 120 | | REGISTER_MODULE(m_mod_man, SOUND_SDL); |
| 121 | | REGISTER_MODULE(m_mod_man, SOUND_NONE); |
| 114 | REGISTER_MODULE(m_mod_man, FONT_OSX); |
| 115 | REGISTER_MODULE(m_mod_man, FONT_WINDOWS); |
| 116 | REGISTER_MODULE(m_mod_man, FONT_SDL); |
| 117 | REGISTER_MODULE(m_mod_man, FONT_NONE); |
| 122 | 118 | |
| 119 | REGISTER_MODULE(m_mod_man, SOUND_DSOUND); |
| 120 | REGISTER_MODULE(m_mod_man, SOUND_JS); |
| 121 | REGISTER_MODULE(m_mod_man, SOUND_SDL); |
| 122 | REGISTER_MODULE(m_mod_man, SOUND_NONE); |
| 123 | |
| 123 | 124 | #ifdef SDLMAME_MACOSX |
| 124 | | REGISTER_MODULE(m_mod_man, DEBUG_OSX); |
| 125 | REGISTER_MODULE(m_mod_man, DEBUG_OSX); |
| 125 | 126 | #endif |
| 126 | | REGISTER_MODULE(m_mod_man, DEBUG_WINDOWS); |
| 127 | | REGISTER_MODULE(m_mod_man, DEBUG_QT); |
| 128 | | REGISTER_MODULE(m_mod_man, DEBUG_INTERNAL); |
| 129 | | REGISTER_MODULE(m_mod_man, DEBUG_NONE); |
| 127 | REGISTER_MODULE(m_mod_man, DEBUG_WINDOWS); |
| 128 | REGISTER_MODULE(m_mod_man, DEBUG_QT); |
| 129 | REGISTER_MODULE(m_mod_man, DEBUG_INTERNAL); |
| 130 | REGISTER_MODULE(m_mod_man, DEBUG_NONE); |
| 130 | 131 | |
| 131 | | // after initialization we know which modules are supported |
| 132 | // after initialization we know which modules are supported |
| 132 | 133 | |
| 133 | | const char *names[20]; |
| 134 | | int num; |
| 135 | | m_mod_man.get_module_names(OSD_FONT_PROVIDER, 20, &num, names); |
| 136 | | dynamic_array<const char *> dnames; |
| 137 | | for (int i = 0; i < num; i++) |
| 138 | | dnames.append(names[i]); |
| 139 | | update_option(OSD_FONT_PROVIDER, dnames); |
| 134 | const char *names[20]; |
| 135 | int num; |
| 136 | m_mod_man.get_module_names(OSD_FONT_PROVIDER, 20, &num, names); |
| 137 | dynamic_array<const char *> dnames; |
| 138 | for (int i = 0; i < num; i++) |
| 139 | dnames.append(names[i]); |
| 140 | update_option(OSD_FONT_PROVIDER, dnames); |
| 140 | 141 | |
| 141 | | m_mod_man.get_module_names(OSD_SOUND_PROVIDER, 20, &num, names); |
| 142 | | dnames.reset(); |
| 143 | | for (int i = 0; i < num; i++) |
| 144 | | dnames.append(names[i]); |
| 145 | | update_option(OSD_SOUND_PROVIDER, dnames); |
| 142 | m_mod_man.get_module_names(OSD_SOUND_PROVIDER, 20, &num, names); |
| 143 | dnames.reset(); |
| 144 | for (int i = 0; i < num; i++) |
| 145 | dnames.append(names[i]); |
| 146 | update_option(OSD_SOUND_PROVIDER, dnames); |
| 146 | 147 | |
| 147 | | // Register debugger options and update options |
| 148 | | m_mod_man.get_module_names(OSD_DEBUG_PROVIDER, 20, &num, names); |
| 149 | | dnames.reset(); |
| 150 | | for (int i = 0; i < num; i++) |
| 151 | | dnames.append(names[i]); |
| 152 | | update_option(OSD_DEBUG_PROVIDER, dnames); |
| 148 | // Register debugger options and update options |
| 149 | m_mod_man.get_module_names(OSD_DEBUG_PROVIDER, 20, &num, names); |
| 150 | dnames.reset(); |
| 151 | for (int i = 0; i < num; i++) |
| 152 | dnames.append(names[i]); |
| 153 | update_option(OSD_DEBUG_PROVIDER, dnames); |
| 153 | 154 | |
| 154 | | // Register video options and update options |
| 155 | | video_options_add("none", NULL); |
| 156 | | video_register(); |
| 157 | | update_option(OSDOPTION_VIDEO, m_video_names); |
| 155 | // Register video options and update options |
| 156 | video_options_add("none", NULL); |
| 157 | video_register(); |
| 158 | update_option(OSDOPTION_VIDEO, m_video_names); |
| 158 | 159 | } |
| 159 | 160 | |
| 160 | 161 | void osd_common_t::update_option(const char * key, dynamic_array<const char *> &values) |
| r243230 | r243231 | |
| 304 | 305 | // It provides an array of stereo samples in L-R order which should be |
| 305 | 306 | // output at the configured sample_rate. |
| 306 | 307 | // |
| 307 | | m_sound->update_audio_stream(m_machine->video().throttled(), buffer,samples_this_frame); |
| 308 | m_sound->update_audio_stream(m_machine->video().throttled(), buffer,samples_this_frame); |
| 308 | 309 | } |
| 309 | 310 | |
| 310 | 311 | |
| r243230 | r243231 | |
| 321 | 322 | // while (attenuation++ < 0) |
| 322 | 323 | // volume /= 1.122018454; // = (10 ^ (1/20)) = 1dB |
| 323 | 324 | // |
| 324 | | if (m_sound != NULL) |
| 325 | | m_sound->set_mastervolume(attenuation); |
| 325 | if (m_sound != NULL) |
| 326 | m_sound->set_mastervolume(attenuation); |
| 326 | 327 | } |
| 327 | 328 | |
| 328 | 329 | |
| r243230 | r243231 | |
| 397 | 398 | |
| 398 | 399 | bool osd_common_t::execute_command(const char *command) |
| 399 | 400 | { |
| 400 | | if (strcmp(command, OSDCOMMAND_LIST_NETWORK_ADAPTERS) == 0) |
| 401 | | { |
| 402 | | network_init(); |
| 403 | | osd_list_network_adapters(); |
| 404 | | network_exit(); |
| 405 | | return true; |
| 406 | | } |
| 407 | | else if (strcmp(command, OSDCOMMAND_LIST_MIDI_DEVICES) == 0) |
| 408 | | { |
| 409 | | osd_list_midi_devices(); |
| 410 | | return true; |
| 411 | | } |
| 401 | if (strcmp(command, OSDCOMMAND_LIST_NETWORK_ADAPTERS) == 0) |
| 402 | { |
| 403 | network_init(); |
| 404 | osd_list_network_adapters(); |
| 405 | network_exit(); |
| 406 | return true; |
| 407 | } |
| 408 | else if (strcmp(command, OSDCOMMAND_LIST_MIDI_DEVICES) == 0) |
| 409 | { |
| 410 | osd_list_midi_devices(); |
| 411 | return true; |
| 412 | } |
| 412 | 413 | |
| 413 | | return false; |
| 414 | return false; |
| 414 | 415 | |
| 415 | 416 | } |
| 416 | 417 | |
| r243230 | r243231 | |
| 436 | 437 | #endif |
| 437 | 438 | midi_init(); |
| 438 | 439 | |
| 439 | | m_font_module = select_module_options<font_module *>(options(), OSD_FONT_PROVIDER); |
| 440 | m_font_module = select_module_options<font_module *>(options(), OSD_FONT_PROVIDER); |
| 440 | 441 | |
| 441 | | m_sound = select_module_options<sound_module *>(options(), OSD_SOUND_PROVIDER); |
| 442 | | m_sound->m_sample_rate = options().sample_rate(); |
| 443 | | m_sound->m_audio_latency = options().audio_latency(); |
| 442 | m_sound = select_module_options<sound_module *>(options(), OSD_SOUND_PROVIDER); |
| 443 | m_sound->m_sample_rate = options().sample_rate(); |
| 444 | m_sound->m_audio_latency = options().audio_latency(); |
| 444 | 445 | |
| 445 | | m_debugger = select_module_options<debug_module *>(options(), OSD_DEBUG_PROVIDER); |
| 446 | m_debugger = select_module_options<debug_module *>(options(), OSD_DEBUG_PROVIDER); |
| 446 | 447 | |
| 447 | | m_mod_man.init(); |
| 448 | m_mod_man.init(); |
| 448 | 449 | |
| 449 | 450 | } |
| 450 | 451 | |
| r243230 | r243231 | |
| 523 | 524 | |
| 524 | 525 | void osd_common_t::osd_exit() |
| 525 | 526 | { |
| 526 | | m_mod_man.exit(); |
| 527 | m_mod_man.exit(); |
| 527 | 528 | |
| 528 | | exit_subsystems(); |
| 529 | exit_subsystems(); |
| 529 | 530 | } |
| 530 | 531 | |
| 531 | 532 | void osd_common_t::video_options_add(const char *name, void *type) |
| r243230 | r243231 | |
| 536 | 537 | |
| 537 | 538 | bool osd_common_t::midi_init() |
| 538 | 539 | { |
| 539 | | // this should be done on the OS_level |
| 540 | | return osd_midi_init(); |
| 540 | // this should be done on the OS_level |
| 541 | return osd_midi_init(); |
| 541 | 542 | } |
| 542 | 543 | |
| 543 | 544 | void osd_common_t::midi_exit() |
| 544 | 545 | { |
| 545 | | osd_midi_exit(); |
| 546 | osd_midi_exit(); |
| 546 | 547 | } |
| 548 | |
| 549 | |
trunk/src/osd/modules/midi/portmidi.c
| r243230 | r243231 | |
| 16 | 16 | |
| 17 | 17 | struct osd_midi_device |
| 18 | 18 | { |
| 19 | | PortMidiStream *pmStream; |
| 20 | | PmEvent rx_evBuf[RX_EVENT_BUF_SIZE]; |
| 21 | | UINT8 xmit_in[4]; // Pm_Messages mean we can at most have 3 residue bytes |
| 22 | | int xmit_cnt; |
| 23 | | UINT8 last_status; |
| 24 | | bool rx_sysex; |
| 19 | PortMidiStream *pmStream; |
| 20 | PmEvent rx_evBuf[RX_EVENT_BUF_SIZE]; |
| 21 | UINT8 xmit_in[4]; // Pm_Messages mean we can at most have 3 residue bytes |
| 22 | int xmit_cnt; |
| 23 | UINT8 last_status; |
| 24 | bool rx_sysex; |
| 25 | 25 | }; |
| 26 | 26 | |
| 27 | 27 | bool osd_midi_init() |
| 28 | 28 | { |
| 29 | | Pm_Initialize(); |
| 30 | | return true; |
| 29 | Pm_Initialize(); |
| 30 | return true; |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | void osd_midi_exit() |
| 34 | 34 | { |
| 35 | | Pm_Terminate(); |
| 35 | Pm_Terminate(); |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | void osd_list_midi_devices(void) |
| 39 | 39 | { |
| 40 | | int num_devs = Pm_CountDevices(); |
| 41 | | const PmDeviceInfo *pmInfo; |
| 40 | int num_devs = Pm_CountDevices(); |
| 41 | const PmDeviceInfo *pmInfo; |
| 42 | 42 | |
| 43 | | printf("\n"); |
| 43 | printf("\n"); |
| 44 | 44 | |
| 45 | | if (num_devs == 0) |
| 46 | | { |
| 47 | | printf("No MIDI ports were found\n"); |
| 48 | | return; |
| 49 | | } |
| 45 | if (num_devs == 0) |
| 46 | { |
| 47 | printf("No MIDI ports were found\n"); |
| 48 | return; |
| 49 | } |
| 50 | 50 | |
| 51 | | printf("MIDI input ports:\n"); |
| 52 | | for (int i = 0; i < num_devs; i++) |
| 53 | | { |
| 54 | | pmInfo = Pm_GetDeviceInfo(i); |
| 51 | printf("MIDI input ports:\n"); |
| 52 | for (int i = 0; i < num_devs; i++) |
| 53 | { |
| 54 | pmInfo = Pm_GetDeviceInfo(i); |
| 55 | 55 | |
| 56 | | if (pmInfo->input) |
| 57 | | { |
| 58 | | printf("%s %s\n", pmInfo->name, (i == Pm_GetDefaultInputDeviceID()) ? "(default)" : ""); |
| 59 | | } |
| 60 | | } |
| 56 | if (pmInfo->input) |
| 57 | { |
| 58 | printf("%s %s\n", pmInfo->name, (i == Pm_GetDefaultInputDeviceID()) ? "(default)" : ""); |
| 59 | } |
| 60 | } |
| 61 | 61 | |
| 62 | | printf("\nMIDI output ports:\n"); |
| 63 | | for (int i = 0; i < num_devs; i++) |
| 64 | | { |
| 65 | | pmInfo = Pm_GetDeviceInfo(i); |
| 62 | printf("\nMIDI output ports:\n"); |
| 63 | for (int i = 0; i < num_devs; i++) |
| 64 | { |
| 65 | pmInfo = Pm_GetDeviceInfo(i); |
| 66 | 66 | |
| 67 | | if (pmInfo->output) |
| 68 | | { |
| 69 | | printf("%s %s\n", pmInfo->name, (i == Pm_GetDefaultOutputDeviceID()) ? "(default)" : ""); |
| 70 | | } |
| 71 | | } |
| 67 | if (pmInfo->output) |
| 68 | { |
| 69 | printf("%s %s\n", pmInfo->name, (i == Pm_GetDefaultOutputDeviceID()) ? "(default)" : ""); |
| 70 | } |
| 71 | } |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | osd_midi_device *osd_open_midi_input(const char *devname) |
| 75 | 75 | { |
| 76 | | int num_devs = Pm_CountDevices(); |
| 77 | | int found_dev = -1; |
| 78 | | const PmDeviceInfo *pmInfo; |
| 79 | | PortMidiStream *stm; |
| 80 | | osd_midi_device *ret; |
| 76 | int num_devs = Pm_CountDevices(); |
| 77 | int found_dev = -1; |
| 78 | const PmDeviceInfo *pmInfo; |
| 79 | PortMidiStream *stm; |
| 80 | osd_midi_device *ret; |
| 81 | 81 | |
| 82 | | if (!strcmp("default", devname)) |
| 83 | | { |
| 84 | | found_dev = Pm_GetDefaultInputDeviceID(); |
| 85 | | } |
| 86 | | else |
| 87 | | { |
| 88 | | for (int i = 0; i < num_devs; i++) |
| 89 | | { |
| 90 | | pmInfo = Pm_GetDeviceInfo(i); |
| 82 | if (!strcmp("default", devname)) |
| 83 | { |
| 84 | found_dev = Pm_GetDefaultInputDeviceID(); |
| 85 | } |
| 86 | else |
| 87 | { |
| 88 | for (int i = 0; i < num_devs; i++) |
| 89 | { |
| 90 | pmInfo = Pm_GetDeviceInfo(i); |
| 91 | 91 | |
| 92 | | if (pmInfo->input) |
| 93 | | { |
| 94 | | if (!strcmp(devname, pmInfo->name)) |
| 95 | | { |
| 96 | | found_dev = i; |
| 97 | | break; |
| 98 | | } |
| 99 | | } |
| 100 | | } |
| 101 | | } |
| 92 | if (pmInfo->input) |
| 93 | { |
| 94 | if (!strcmp(devname, pmInfo->name)) |
| 95 | { |
| 96 | found_dev = i; |
| 97 | break; |
| 98 | } |
| 99 | } |
| 100 | } |
| 101 | } |
| 102 | 102 | |
| 103 | | if (found_dev >= 0) |
| 104 | | { |
| 105 | | if (Pm_OpenInput(&stm, found_dev, NULL, RX_EVENT_BUF_SIZE, NULL, NULL) == pmNoError) |
| 106 | | { |
| 107 | | ret = (osd_midi_device *)osd_malloc(sizeof(osd_midi_device)); |
| 108 | | memset(ret, 0, sizeof(osd_midi_device)); |
| 109 | | ret->pmStream = stm; |
| 110 | | return ret; |
| 111 | | } |
| 112 | | else |
| 113 | | { |
| 114 | | printf("Couldn't open PM device\n"); |
| 115 | | return NULL; |
| 116 | | } |
| 117 | | } |
| 118 | | else |
| 119 | | { |
| 120 | | return NULL; |
| 121 | | } |
| 103 | if (found_dev >= 0) |
| 104 | { |
| 105 | if (Pm_OpenInput(&stm, found_dev, NULL, RX_EVENT_BUF_SIZE, NULL, NULL) == pmNoError) |
| 106 | { |
| 107 | ret = (osd_midi_device *)osd_malloc(sizeof(osd_midi_device)); |
| 108 | memset(ret, 0, sizeof(osd_midi_device)); |
| 109 | ret->pmStream = stm; |
| 110 | return ret; |
| 111 | } |
| 112 | else |
| 113 | { |
| 114 | printf("Couldn't open PM device\n"); |
| 115 | return NULL; |
| 116 | } |
| 117 | } |
| 118 | else |
| 119 | { |
| 120 | return NULL; |
| 121 | } |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | osd_midi_device *osd_open_midi_output(const char *devname) |
| 125 | 125 | { |
| 126 | | int num_devs = Pm_CountDevices(); |
| 127 | | int found_dev = -1; |
| 128 | | const PmDeviceInfo *pmInfo; |
| 129 | | PortMidiStream *stm; |
| 130 | | osd_midi_device *ret; |
| 126 | int num_devs = Pm_CountDevices(); |
| 127 | int found_dev = -1; |
| 128 | const PmDeviceInfo *pmInfo; |
| 129 | PortMidiStream *stm; |
| 130 | osd_midi_device *ret; |
| 131 | 131 | |
| 132 | | if (!strcmp("default", devname)) |
| 133 | | { |
| 134 | | found_dev = Pm_GetDefaultOutputDeviceID(); |
| 135 | | } |
| 136 | | else |
| 137 | | { |
| 138 | | for (int i = 0; i < num_devs; i++) |
| 139 | | { |
| 140 | | pmInfo = Pm_GetDeviceInfo(i); |
| 132 | if (!strcmp("default", devname)) |
| 133 | { |
| 134 | found_dev = Pm_GetDefaultOutputDeviceID(); |
| 135 | } |
| 136 | else |
| 137 | { |
| 138 | for (int i = 0; i < num_devs; i++) |
| 139 | { |
| 140 | pmInfo = Pm_GetDeviceInfo(i); |
| 141 | 141 | |
| 142 | | if (pmInfo->output) |
| 143 | | { |
| 144 | | if (!strcmp(devname, pmInfo->name)) |
| 145 | | { |
| 146 | | found_dev = i; |
| 147 | | break; |
| 148 | | } |
| 149 | | } |
| 150 | | } |
| 151 | | } |
| 142 | if (pmInfo->output) |
| 143 | { |
| 144 | if (!strcmp(devname, pmInfo->name)) |
| 145 | { |
| 146 | found_dev = i; |
| 147 | break; |
| 148 | } |
| 149 | } |
| 150 | } |
| 151 | } |
| 152 | 152 | |
| 153 | | if (found_dev >= 0) |
| 154 | | { |
| 155 | | if (Pm_OpenOutput(&stm, found_dev, NULL, 100, NULL, NULL, 0) == pmNoError) |
| 156 | | { |
| 157 | | ret = (osd_midi_device *)osd_malloc(sizeof(osd_midi_device)); |
| 158 | | memset(ret, 0, sizeof(osd_midi_device)); |
| 159 | | ret->pmStream = stm; |
| 160 | | return ret; |
| 161 | | } |
| 162 | | else |
| 163 | | { |
| 164 | | printf("Couldn't open PM device\n"); |
| 165 | | return NULL; |
| 166 | | } |
| 167 | | } |
| 168 | | else |
| 169 | | { |
| 170 | | return NULL; |
| 171 | | } |
| 172 | | return NULL; |
| 153 | if (found_dev >= 0) |
| 154 | { |
| 155 | if (Pm_OpenOutput(&stm, found_dev, NULL, 100, NULL, NULL, 0) == pmNoError) |
| 156 | { |
| 157 | ret = (osd_midi_device *)osd_malloc(sizeof(osd_midi_device)); |
| 158 | memset(ret, 0, sizeof(osd_midi_device)); |
| 159 | ret->pmStream = stm; |
| 160 | return ret; |
| 161 | } |
| 162 | else |
| 163 | { |
| 164 | printf("Couldn't open PM device\n"); |
| 165 | return NULL; |
| 166 | } |
| 167 | } |
| 168 | else |
| 169 | { |
| 170 | return NULL; |
| 171 | } |
| 172 | return NULL; |
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | void osd_close_midi_channel(osd_midi_device *dev) |
| 176 | 176 | { |
| 177 | | Pm_Close(dev->pmStream); |
| 178 | | osd_free(dev); |
| 177 | Pm_Close(dev->pmStream); |
| 178 | osd_free(dev); |
| 179 | 179 | } |
| 180 | 180 | |
| 181 | 181 | bool osd_poll_midi_channel(osd_midi_device *dev) |
| 182 | 182 | { |
| 183 | | PmError chk = Pm_Poll(dev->pmStream); |
| 183 | PmError chk = Pm_Poll(dev->pmStream); |
| 184 | 184 | |
| 185 | | return (chk == pmGotData) ? true : false; |
| 185 | return (chk == pmGotData) ? true : false; |
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | int osd_read_midi_channel(osd_midi_device *dev, UINT8 *pOut) |
| 189 | 189 | { |
| 190 | | int msgsRead = Pm_Read(dev->pmStream, dev->rx_evBuf, RX_EVENT_BUF_SIZE); |
| 191 | | int bytesOut = 0; |
| 190 | int msgsRead = Pm_Read(dev->pmStream, dev->rx_evBuf, RX_EVENT_BUF_SIZE); |
| 191 | int bytesOut = 0; |
| 192 | 192 | |
| 193 | | if (msgsRead <= 0) |
| 194 | | { |
| 195 | | return 0; |
| 196 | | } |
| 193 | if (msgsRead <= 0) |
| 194 | { |
| 195 | return 0; |
| 196 | } |
| 197 | 197 | |
| 198 | | for (int msg = 0; msg < msgsRead; msg++) |
| 199 | | { |
| 200 | | UINT8 status = Pm_MessageStatus(dev->rx_evBuf[msg].message); |
| 198 | for (int msg = 0; msg < msgsRead; msg++) |
| 199 | { |
| 200 | UINT8 status = Pm_MessageStatus(dev->rx_evBuf[msg].message); |
| 201 | 201 | |
| 202 | | if (dev->rx_sysex) |
| 203 | | { |
| 204 | | if (status & 0x80) // sys real-time imposing on us? |
| 205 | | { |
| 206 | | if ((status == 0xf2) || (status == 0xf3)) |
| 207 | | { |
| 208 | | *pOut++ = status; |
| 209 | | *pOut++ = Pm_MessageData1(dev->rx_evBuf[msg].message); |
| 210 | | *pOut++ = Pm_MessageData2(dev->rx_evBuf[msg].message); |
| 211 | | bytesOut += 3; |
| 212 | | } |
| 213 | | else |
| 214 | | { |
| 215 | | *pOut++ = status; |
| 216 | | bytesOut++; |
| 217 | | if (status == MIDI_EOX) |
| 218 | | { |
| 219 | | dev->rx_sysex = false; |
| 220 | | } |
| 221 | | } |
| 222 | | } |
| 223 | | else // shift out the sysex bytes |
| 224 | | { |
| 225 | | for (int i = 0; i < 4; i++) |
| 226 | | { |
| 227 | | UINT8 byte = dev->rx_evBuf[msg].message & 0xff; |
| 228 | | *pOut++ = byte; |
| 229 | | bytesOut++; |
| 230 | | if (byte == MIDI_EOX) |
| 231 | | { |
| 232 | | dev->rx_sysex = false; |
| 233 | | break; |
| 234 | | } |
| 235 | | dev->rx_evBuf[msg].message >>= 8; |
| 236 | | } |
| 237 | | } |
| 238 | | } |
| 239 | | else |
| 240 | | { |
| 241 | | switch ((status>>4) & 0xf) |
| 242 | | { |
| 243 | | case 0xc: // 2-byte messages |
| 244 | | case 0xd: |
| 245 | | *pOut++ = status; |
| 246 | | *pOut++ = Pm_MessageData1(dev->rx_evBuf[msg].message); |
| 247 | | bytesOut += 2; |
| 248 | | break; |
| 202 | if (dev->rx_sysex) |
| 203 | { |
| 204 | if (status & 0x80) // sys real-time imposing on us? |
| 205 | { |
| 206 | if ((status == 0xf2) || (status == 0xf3)) |
| 207 | { |
| 208 | *pOut++ = status; |
| 209 | *pOut++ = Pm_MessageData1(dev->rx_evBuf[msg].message); |
| 210 | *pOut++ = Pm_MessageData2(dev->rx_evBuf[msg].message); |
| 211 | bytesOut += 3; |
| 212 | } |
| 213 | else |
| 214 | { |
| 215 | *pOut++ = status; |
| 216 | bytesOut++; |
| 217 | if (status == MIDI_EOX) |
| 218 | { |
| 219 | dev->rx_sysex = false; |
| 220 | } |
| 221 | } |
| 222 | } |
| 223 | else // shift out the sysex bytes |
| 224 | { |
| 225 | for (int i = 0; i < 4; i++) |
| 226 | { |
| 227 | UINT8 byte = dev->rx_evBuf[msg].message & 0xff; |
| 228 | *pOut++ = byte; |
| 229 | bytesOut++; |
| 230 | if (byte == MIDI_EOX) |
| 231 | { |
| 232 | dev->rx_sysex = false; |
| 233 | break; |
| 234 | } |
| 235 | dev->rx_evBuf[msg].message >>= 8; |
| 236 | } |
| 237 | } |
| 238 | } |
| 239 | else |
| 240 | { |
| 241 | switch ((status>>4) & 0xf) |
| 242 | { |
| 243 | case 0xc: // 2-byte messages |
| 244 | case 0xd: |
| 245 | *pOut++ = status; |
| 246 | *pOut++ = Pm_MessageData1(dev->rx_evBuf[msg].message); |
| 247 | bytesOut += 2; |
| 248 | break; |
| 249 | 249 | |
| 250 | | case 0xf: // system common |
| 251 | | switch (status & 0xf) |
| 252 | | { |
| 253 | | case 0: // System Exclusive |
| 254 | | { |
| 255 | | *pOut++ = status; // this should be OK: the shortest legal sysex is F0 tt dd F7, I believe |
| 256 | | *pOut++ = (dev->rx_evBuf[msg].message>>8) & 0xff; |
| 257 | | *pOut++ = (dev->rx_evBuf[msg].message>>16) & 0xff; |
| 258 | | UINT8 last = *pOut++ = (dev->rx_evBuf[msg].message>>24) & 0xff; |
| 259 | | bytesOut += 4; |
| 260 | | dev->rx_sysex = (last != MIDI_EOX); |
| 261 | | break; |
| 262 | | } |
| 250 | case 0xf: // system common |
| 251 | switch (status & 0xf) |
| 252 | { |
| 253 | case 0: // System Exclusive |
| 254 | { |
| 255 | *pOut++ = status; // this should be OK: the shortest legal sysex is F0 tt dd F7, I believe |
| 256 | *pOut++ = (dev->rx_evBuf[msg].message>>8) & 0xff; |
| 257 | *pOut++ = (dev->rx_evBuf[msg].message>>16) & 0xff; |
| 258 | UINT8 last = *pOut++ = (dev->rx_evBuf[msg].message>>24) & 0xff; |
| 259 | bytesOut += 4; |
| 260 | dev->rx_sysex = (last != MIDI_EOX); |
| 261 | break; |
| 262 | } |
| 263 | 263 | |
| 264 | | case 7: // End of System Exclusive |
| 265 | | *pOut++ = status; |
| 266 | | bytesOut += 1; |
| 267 | | dev->rx_sysex = false; |
| 268 | | break; |
| 264 | case 7: // End of System Exclusive |
| 265 | *pOut++ = status; |
| 266 | bytesOut += 1; |
| 267 | dev->rx_sysex = false; |
| 268 | break; |
| 269 | 269 | |
| 270 | | case 2: // song pos |
| 271 | | case 3: // song select |
| 272 | | *pOut++ = status; |
| 273 | | *pOut++ = Pm_MessageData1(dev->rx_evBuf[msg].message); |
| 274 | | *pOut++ = Pm_MessageData2(dev->rx_evBuf[msg].message); |
| 275 | | bytesOut += 3; |
| 276 | | break; |
| 270 | case 2: // song pos |
| 271 | case 3: // song select |
| 272 | *pOut++ = status; |
| 273 | *pOut++ = Pm_MessageData1(dev->rx_evBuf[msg].message); |
| 274 | *pOut++ = Pm_MessageData2(dev->rx_evBuf[msg].message); |
| 275 | bytesOut += 3; |
| 276 | break; |
| 277 | 277 | |
| 278 | | default: // all other defined Fx messages are 1 byte |
| 279 | | break; |
| 280 | | } |
| 281 | | break; |
| 278 | default: // all other defined Fx messages are 1 byte |
| 279 | break; |
| 280 | } |
| 281 | break; |
| 282 | 282 | |
| 283 | | default: |
| 284 | | *pOut++ = status; |
| 285 | | *pOut++ = Pm_MessageData1(dev->rx_evBuf[msg].message); |
| 286 | | *pOut++ = Pm_MessageData2(dev->rx_evBuf[msg].message); |
| 287 | | bytesOut += 3; |
| 288 | | break; |
| 289 | | } |
| 290 | | } |
| 291 | | } |
| 283 | default: |
| 284 | *pOut++ = status; |
| 285 | *pOut++ = Pm_MessageData1(dev->rx_evBuf[msg].message); |
| 286 | *pOut++ = Pm_MessageData2(dev->rx_evBuf[msg].message); |
| 287 | bytesOut += 3; |
| 288 | break; |
| 289 | } |
| 290 | } |
| 291 | } |
| 292 | 292 | |
| 293 | | return bytesOut; |
| 293 | return bytesOut; |
| 294 | 294 | } |
| 295 | 295 | |
| 296 | 296 | void osd_write_midi_channel(osd_midi_device *dev, UINT8 data) |
| 297 | 297 | { |
| 298 | | int bytes_needed = 0; |
| 299 | | PmEvent ev; |
| 300 | | ev.timestamp = 0; // use the current time |
| 298 | int bytes_needed = 0; |
| 299 | PmEvent ev; |
| 300 | ev.timestamp = 0; // use the current time |
| 301 | 301 | |
| 302 | 302 | // printf("write: %02x (%d)\n", data, dev->xmit_cnt); |
| 303 | 303 | |
| 304 | | // reject data bytes when no valid status exists |
| 305 | | if ((dev->last_status == 0) && !(data & 0x80)) |
| 306 | | { |
| 307 | | dev->xmit_cnt = 0; |
| 308 | | return; |
| 309 | | } |
| 304 | // reject data bytes when no valid status exists |
| 305 | if ((dev->last_status == 0) && !(data & 0x80)) |
| 306 | { |
| 307 | dev->xmit_cnt = 0; |
| 308 | return; |
| 309 | } |
| 310 | 310 | |
| 311 | | if (dev->xmit_cnt >= 4) |
| 312 | | { |
| 313 | | printf("MIDI out: packet assembly overflow, contact MAMEdev!\n"); |
| 314 | | return; |
| 315 | | } |
| 311 | if (dev->xmit_cnt >= 4) |
| 312 | { |
| 313 | printf("MIDI out: packet assembly overflow, contact MAMEdev!\n"); |
| 314 | return; |
| 315 | } |
| 316 | 316 | |
| 317 | | // handle sysex |
| 318 | | if (dev->last_status == MIDI_SYSEX) |
| 319 | | { |
| 317 | // handle sysex |
| 318 | if (dev->last_status == MIDI_SYSEX) |
| 319 | { |
| 320 | 320 | // printf("sysex: %02x (%d)\n", data, dev->xmit_cnt); |
| 321 | 321 | |
| 322 | | // if we get a status that isn't sysex, assume it's system common |
| 323 | | if ((data & 0x80) && (data != MIDI_EOX)) |
| 324 | | { |
| 322 | // if we get a status that isn't sysex, assume it's system common |
| 323 | if ((data & 0x80) && (data != MIDI_EOX)) |
| 324 | { |
| 325 | 325 | // printf("common during sysex!\n"); |
| 326 | | ev.message = Pm_Message(data, 0, 0); |
| 327 | | Pm_Write(dev->pmStream, &ev, 1); |
| 328 | | return; |
| 329 | | } |
| 326 | ev.message = Pm_Message(data, 0, 0); |
| 327 | Pm_Write(dev->pmStream, &ev, 1); |
| 328 | return; |
| 329 | } |
| 330 | 330 | |
| 331 | | dev->xmit_in[dev->xmit_cnt++] = data; |
| 331 | dev->xmit_in[dev->xmit_cnt++] = data; |
| 332 | 332 | |
| 333 | | // if EOX or 4 bytes filled, transmit 4 bytes |
| 334 | | if ((dev->xmit_cnt == 4) || (data == MIDI_EOX)) |
| 335 | | { |
| 336 | | ev.message = dev->xmit_in[0] | (dev->xmit_in[1]<<8) | (dev->xmit_in[2]<<16) | (dev->xmit_in[3]<<24); |
| 337 | | Pm_Write(dev->pmStream, &ev, 1); |
| 338 | | dev->xmit_in[0] = dev->xmit_in[1] = dev->xmit_in[2] = dev->xmit_in[3] = 0; |
| 339 | | dev->xmit_cnt = 0; |
| 333 | // if EOX or 4 bytes filled, transmit 4 bytes |
| 334 | if ((dev->xmit_cnt == 4) || (data == MIDI_EOX)) |
| 335 | { |
| 336 | ev.message = dev->xmit_in[0] | (dev->xmit_in[1]<<8) | (dev->xmit_in[2]<<16) | (dev->xmit_in[3]<<24); |
| 337 | Pm_Write(dev->pmStream, &ev, 1); |
| 338 | dev->xmit_in[0] = dev->xmit_in[1] = dev->xmit_in[2] = dev->xmit_in[3] = 0; |
| 339 | dev->xmit_cnt = 0; |
| 340 | 340 | |
| 341 | 341 | // printf("SysEx packet: %08x\n", ev.message); |
| 342 | 342 | |
| 343 | | // if this is EOX, kill the running status |
| 344 | | if (data == MIDI_EOX) |
| 345 | | { |
| 346 | | dev->last_status = 0; |
| 347 | | } |
| 348 | | } |
| 343 | // if this is EOX, kill the running status |
| 344 | if (data == MIDI_EOX) |
| 345 | { |
| 346 | dev->last_status = 0; |
| 347 | } |
| 348 | } |
| 349 | 349 | |
| 350 | | return; |
| 351 | | } |
| 350 | return; |
| 351 | } |
| 352 | 352 | |
| 353 | | // handle running status. don't allow system real-time messages to be considered as running status. |
| 354 | | if ((dev->xmit_cnt == 0) && (data & 0x80) && (data < 0xf8)) |
| 355 | | { |
| 356 | | dev->last_status = data; |
| 357 | | } |
| 353 | // handle running status. don't allow system real-time messages to be considered as running status. |
| 354 | if ((dev->xmit_cnt == 0) && (data & 0x80) && (data < 0xf8)) |
| 355 | { |
| 356 | dev->last_status = data; |
| 357 | } |
| 358 | 358 | |
| 359 | | if ((dev->xmit_cnt == 0) && !(data & 0x80)) |
| 360 | | { |
| 361 | | dev->xmit_in[dev->xmit_cnt++] = dev->last_status; |
| 362 | | dev->xmit_in[dev->xmit_cnt++] = data; |
| 359 | if ((dev->xmit_cnt == 0) && !(data & 0x80)) |
| 360 | { |
| 361 | dev->xmit_in[dev->xmit_cnt++] = dev->last_status; |
| 362 | dev->xmit_in[dev->xmit_cnt++] = data; |
| 363 | 363 | // printf("\trunning status: [%d] = %02x, [%d] = %02x, last_status = %02x\n", dev->xmit_cnt-2, dev->last_status, dev->xmit_cnt-1, data, dev->last_status); |
| 364 | | } |
| 365 | | else |
| 366 | | { |
| 367 | | dev->xmit_in[dev->xmit_cnt++] = data; |
| 364 | } |
| 365 | else |
| 366 | { |
| 367 | dev->xmit_in[dev->xmit_cnt++] = data; |
| 368 | 368 | // printf("\tNRS: [%d] = %02x\n", dev->xmit_cnt-1, data); |
| 369 | | } |
| 369 | } |
| 370 | 370 | |
| 371 | | if ((dev->xmit_cnt == 1) && (dev->xmit_in[0] == MIDI_SYSEX)) |
| 372 | | { |
| 371 | if ((dev->xmit_cnt == 1) && (dev->xmit_in[0] == MIDI_SYSEX)) |
| 372 | { |
| 373 | 373 | // printf("Start SysEx!\n"); |
| 374 | | dev->last_status = MIDI_SYSEX; |
| 375 | | return; |
| 376 | | } |
| 374 | dev->last_status = MIDI_SYSEX; |
| 375 | return; |
| 376 | } |
| 377 | 377 | |
| 378 | | // are we there yet? |
| 378 | // are we there yet? |
| 379 | 379 | // printf("status check: %02x\n", dev->xmit_in[0]); |
| 380 | | switch ((dev->xmit_in[0]>>4) & 0xf) |
| 381 | | { |
| 382 | | case 0xc: // 2-byte messages |
| 383 | | case 0xd: |
| 384 | | bytes_needed = 2; |
| 385 | | break; |
| 380 | switch ((dev->xmit_in[0]>>4) & 0xf) |
| 381 | { |
| 382 | case 0xc: // 2-byte messages |
| 383 | case 0xd: |
| 384 | bytes_needed = 2; |
| 385 | break; |
| 386 | 386 | |
| 387 | | case 0xf: // system common |
| 388 | | switch (dev->xmit_in[0] & 0xf) |
| 389 | | { |
| 390 | | case 0: // System Exclusive is handled above |
| 391 | | break; |
| 387 | case 0xf: // system common |
| 388 | switch (dev->xmit_in[0] & 0xf) |
| 389 | { |
| 390 | case 0: // System Exclusive is handled above |
| 391 | break; |
| 392 | 392 | |
| 393 | | case 7: // End of System Exclusive |
| 394 | | bytes_needed = 1; |
| 395 | | break; |
| 393 | case 7: // End of System Exclusive |
| 394 | bytes_needed = 1; |
| 395 | break; |
| 396 | 396 | |
| 397 | | case 2: // song pos |
| 398 | | case 3: // song select |
| 399 | | bytes_needed = 3; |
| 400 | | break; |
| 397 | case 2: // song pos |
| 398 | case 3: // song select |
| 399 | bytes_needed = 3; |
| 400 | break; |
| 401 | 401 | |
| 402 | | default: // all other defined Fx messages are 1 byte |
| 403 | | bytes_needed = 1; |
| 404 | | break; |
| 405 | | } |
| 406 | | break; |
| 402 | default: // all other defined Fx messages are 1 byte |
| 403 | bytes_needed = 1; |
| 404 | break; |
| 405 | } |
| 406 | break; |
| 407 | 407 | |
| 408 | | default: |
| 409 | | bytes_needed = 3; |
| 410 | | break; |
| 411 | | } |
| 408 | default: |
| 409 | bytes_needed = 3; |
| 410 | break; |
| 411 | } |
| 412 | 412 | |
| 413 | | if (dev->xmit_cnt == bytes_needed) |
| 414 | | { |
| 415 | | ev.message = Pm_Message(dev->xmit_in[0], dev->xmit_in[1], dev->xmit_in[2]); |
| 416 | | Pm_Write(dev->pmStream, &ev, 1); |
| 417 | | dev->xmit_cnt = 0; |
| 418 | | } |
| 413 | if (dev->xmit_cnt == bytes_needed) |
| 414 | { |
| 415 | ev.message = Pm_Message(dev->xmit_in[0], dev->xmit_in[1], dev->xmit_in[2]); |
| 416 | Pm_Write(dev->pmStream, &ev, 1); |
| 417 | dev->xmit_cnt = 0; |
| 418 | } |
| 419 | 419 | |
| 420 | 420 | } |
trunk/src/osd/sdl/draw13.c
| r243230 | r243231 | |
| 48 | 48 | |
| 49 | 49 | static inline bool is_opaque(const float &a) |
| 50 | 50 | { |
| 51 | | return (a >= 1.0f); |
| 51 | return (a >= 1.0f); |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | static inline bool is_transparent(const float &a) |
| 55 | 55 | { |
| 56 | | return (a < 0.0001f); |
| 56 | return (a < 0.0001f); |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | //============================================================ |
| r243230 | r243231 | |
| 63 | 63 | |
| 64 | 64 | struct quad_setup_data |
| 65 | 65 | { |
| 66 | | quad_setup_data() |
| 67 | | : dudx(0), dvdx(0), dudy(0), dvdy(0), startu(0), startv(0), |
| 68 | | rotwidth(0), rotheight(0) |
| 69 | | {} |
| 70 | | void compute(const render_primitive &prim); |
| 66 | quad_setup_data() |
| 67 | : dudx(0), dvdx(0), dudy(0), dvdy(0), startu(0), startv(0), |
| 68 | rotwidth(0), rotheight(0) |
| 69 | {} |
| 70 | void compute(const render_primitive &prim); |
| 71 | 71 | |
| 72 | 72 | INT32 dudx, dvdx, dudy, dvdy; |
| 73 | 73 | INT32 startu, startv; |
| r243230 | r243231 | |
| 105 | 105 | /* texture_info holds information about a texture */ |
| 106 | 106 | class texture_info |
| 107 | 107 | { |
| 108 | | friend class simple_list<texture_info>; |
| 108 | friend class simple_list<texture_info>; |
| 109 | 109 | public: |
| 110 | | texture_info(SDL_Renderer *renderer, const render_texinfo &texsource, const quad_setup_data &setup, const UINT32 flags); |
| 111 | | ~texture_info(); |
| 110 | texture_info(SDL_Renderer *renderer, const render_texinfo &texsource, const quad_setup_data &setup, const UINT32 flags); |
| 111 | ~texture_info(); |
| 112 | 112 | |
| 113 | | void set_data(const render_texinfo &texsource, const UINT32 flags); |
| 114 | | void render_quad(const render_primitive *prim, const int x, const int y); |
| 115 | | bool matches(const render_primitive &prim, const quad_setup_data &setup); |
| 113 | void set_data(const render_texinfo &texsource, const UINT32 flags); |
| 114 | void render_quad(const render_primitive *prim, const int x, const int y); |
| 115 | bool matches(const render_primitive &prim, const quad_setup_data &setup); |
| 116 | 116 | |
| 117 | | copy_info_t *compute_size_type(); |
| 117 | copy_info_t *compute_size_type(); |
| 118 | 118 | |
| 119 | 119 | void *m_pixels; // pixels for the texture |
| 120 | 120 | int m_pitch; |
| r243230 | r243231 | |
| 125 | 125 | osd_ticks_t m_last_access; |
| 126 | 126 | |
| 127 | 127 | int raw_width() const { return m_texinfo.width; } |
| 128 | | int raw_height() const { return m_texinfo.height; } |
| 128 | int raw_height() const { return m_texinfo.height; } |
| 129 | 129 | |
| 130 | | texture_info *next() { return m_next; } |
| 131 | | const render_texinfo &texinfo() const { return m_texinfo; } |
| 132 | | render_texinfo &texinfo() { return m_texinfo; } |
| 130 | texture_info *next() { return m_next; } |
| 131 | const render_texinfo &texinfo() const { return m_texinfo; } |
| 132 | render_texinfo &texinfo() { return m_texinfo; } |
| 133 | 133 | |
| 134 | | const HashT hash() const { return m_hash; } |
| 135 | | const UINT32 flags() const { return m_flags; } |
| 136 | | const bool is_pixels_owned() const { // do we own / allocated it ? |
| 137 | | return false && ((m_sdl_access == SDL_TEXTUREACCESS_STATIC) |
| 138 | | && (m_copyinfo->func != NULL)) ; |
| 139 | | } |
| 134 | const HashT hash() const { return m_hash; } |
| 135 | const UINT32 flags() const { return m_flags; } |
| 136 | const bool is_pixels_owned() const { // do we own / allocated it ? |
| 137 | return false && ((m_sdl_access == SDL_TEXTUREACCESS_STATIC) |
| 138 | && (m_copyinfo->func != NULL)) ; |
| 139 | } |
| 140 | 140 | |
| 141 | 141 | private: |
| 142 | | Uint32 m_sdl_access; |
| 143 | | SDL_Renderer * m_renderer; |
| 144 | | render_texinfo m_texinfo; // copy of the texture info |
| 145 | | HashT m_hash; // hash value for the texture (must be >= pointer size) |
| 146 | | UINT32 m_flags; // rendering flags |
| 142 | Uint32 m_sdl_access; |
| 143 | SDL_Renderer * m_renderer; |
| 144 | render_texinfo m_texinfo; // copy of the texture info |
| 145 | HashT m_hash; // hash value for the texture (must be >= pointer size) |
| 146 | UINT32 m_flags; // rendering flags |
| 147 | 147 | |
| 148 | | SDL_Texture * m_texture_id; |
| 149 | | int m_is_rotated; |
| 148 | SDL_Texture * m_texture_id; |
| 149 | int m_is_rotated; |
| 150 | 150 | |
| 151 | | int m_format; // texture format |
| 152 | | SDL_BlendMode m_sdl_blendmode; |
| 151 | int m_format; // texture format |
| 152 | SDL_BlendMode m_sdl_blendmode; |
| 153 | 153 | |
| 154 | | texture_info * m_next; // next texture in the list |
| 154 | texture_info * m_next; // next texture in the list |
| 155 | 155 | }; |
| 156 | 156 | |
| 157 | 157 | /* sdl_info is the information about SDL for the current screen */ |
| 158 | 158 | struct sdl_info |
| 159 | 159 | { |
| 160 | | sdl_info() |
| 161 | | : m_blittimer(0), m_renderer(NULL), |
| 162 | | m_hofs(0), m_vofs(0), |
| 163 | | m_resize_pending(0), m_resize_width(0), m_resize_height(0), |
| 164 | | m_last_blit_time(0), m_last_blit_pixels(0) |
| 165 | | {} |
| 160 | sdl_info() |
| 161 | : m_blittimer(0), m_renderer(NULL), |
| 162 | m_hofs(0), m_vofs(0), |
| 163 | m_resize_pending(0), m_resize_width(0), m_resize_height(0), |
| 164 | m_last_blit_time(0), m_last_blit_pixels(0) |
| 165 | {} |
| 166 | 166 | |
| 167 | | void render_quad(texture_info *texture, const render_primitive *prim, const int x, const int y); |
| 167 | void render_quad(texture_info *texture, const render_primitive *prim, const int x, const int y); |
| 168 | 168 | |
| 169 | | texture_info *texture_find(const render_primitive &prim, const quad_setup_data &setup); |
| 170 | | texture_info *texture_update(const render_primitive &prim); |
| 169 | texture_info *texture_find(const render_primitive &prim, const quad_setup_data &setup); |
| 170 | texture_info *texture_update(const render_primitive &prim); |
| 171 | 171 | |
| 172 | 172 | INT32 m_blittimer; |
| 173 | 173 | |
| r243230 | r243231 | |
| 389 | 389 | target_rect.w = round_nearest(prim->bounds.x1 - prim->bounds.x0); |
| 390 | 390 | target_rect.h = round_nearest(prim->bounds.y1 - prim->bounds.y0); |
| 391 | 391 | |
| 392 | | SDL_SetTextureBlendMode(m_texture_id, m_sdl_blendmode); |
| 393 | | set_coloralphamode(m_texture_id, &prim->color); |
| 394 | | SDL_RenderCopy(m_renderer, m_texture_id, NULL, &target_rect); |
| 392 | SDL_SetTextureBlendMode(m_texture_id, m_sdl_blendmode); |
| 393 | set_coloralphamode(m_texture_id, &prim->color); |
| 394 | SDL_RenderCopy(m_renderer, m_texture_id, NULL, &target_rect); |
| 395 | 395 | } |
| 396 | 396 | |
| 397 | 397 | void sdl_info::render_quad(texture_info *texture, const render_primitive *prim, const int x, const int y) |
| 398 | 398 | { |
| 399 | | SDL_Rect target_rect; |
| 399 | SDL_Rect target_rect; |
| 400 | 400 | |
| 401 | | target_rect.x = x; |
| 402 | | target_rect.y = y; |
| 403 | | target_rect.w = round_nearest(prim->bounds.x1 - prim->bounds.x0); |
| 404 | | target_rect.h = round_nearest(prim->bounds.y1 - prim->bounds.y0); |
| 401 | target_rect.x = x; |
| 402 | target_rect.y = y; |
| 403 | target_rect.w = round_nearest(prim->bounds.x1 - prim->bounds.x0); |
| 404 | target_rect.h = round_nearest(prim->bounds.y1 - prim->bounds.y0); |
| 405 | 405 | |
| 406 | | if (texture) |
| 407 | | { |
| 408 | | copy_info_t *copyinfo = texture->m_copyinfo; |
| 409 | | copyinfo->time -= osd_ticks(); |
| 410 | | texture->render_quad(prim, x, y); |
| 411 | | copyinfo->time += osd_ticks(); |
| 406 | if (texture) |
| 407 | { |
| 408 | copy_info_t *copyinfo = texture->m_copyinfo; |
| 409 | copyinfo->time -= osd_ticks(); |
| 410 | texture->render_quad(prim, x, y); |
| 411 | copyinfo->time += osd_ticks(); |
| 412 | 412 | |
| 413 | | copyinfo->pixel_count += MAX(STAT_PIXEL_THRESHOLD , (texture->raw_width() * texture->raw_height())); |
| 414 | | if (m_last_blit_pixels) |
| 415 | | { |
| 416 | | copyinfo->time += (m_last_blit_time * (INT64) (texture->raw_width() * texture->raw_height())) / (INT64) m_last_blit_pixels; |
| 417 | | } |
| 418 | | copyinfo->samples++; |
| 419 | | copyinfo->perf = ( texture->m_copyinfo->pixel_count * (osd_ticks_per_second()/1000)) / texture->m_copyinfo->time; |
| 420 | | } |
| 421 | | else |
| 422 | | { |
| 423 | | UINT32 sr = (UINT32)(255.0f * prim->color.r); |
| 424 | | UINT32 sg = (UINT32)(255.0f * prim->color.g); |
| 425 | | UINT32 sb = (UINT32)(255.0f * prim->color.b); |
| 426 | | UINT32 sa = (UINT32)(255.0f * prim->color.a); |
| 413 | copyinfo->pixel_count += MAX(STAT_PIXEL_THRESHOLD , (texture->raw_width() * texture->raw_height())); |
| 414 | if (m_last_blit_pixels) |
| 415 | { |
| 416 | copyinfo->time += (m_last_blit_time * (INT64) (texture->raw_width() * texture->raw_height())) / (INT64) m_last_blit_pixels; |
| 417 | } |
| 418 | copyinfo->samples++; |
| 419 | copyinfo->perf = ( texture->m_copyinfo->pixel_count * (osd_ticks_per_second()/1000)) / texture->m_copyinfo->time; |
| 420 | } |
| 421 | else |
| 422 | { |
| 423 | UINT32 sr = (UINT32)(255.0f * prim->color.r); |
| 424 | UINT32 sg = (UINT32)(255.0f * prim->color.g); |
| 425 | UINT32 sb = (UINT32)(255.0f * prim->color.b); |
| 426 | UINT32 sa = (UINT32)(255.0f * prim->color.a); |
| 427 | 427 | |
| 428 | | SDL_SetRenderDrawBlendMode(m_renderer, map_blendmode(PRIMFLAG_GET_BLENDMODE(prim->flags))); |
| 429 | | SDL_SetRenderDrawColor(m_renderer, sr, sg, sb, sa); |
| 430 | | SDL_RenderFillRect(m_renderer, &target_rect); |
| 431 | | } |
| 428 | SDL_SetRenderDrawBlendMode(m_renderer, map_blendmode(PRIMFLAG_GET_BLENDMODE(prim->flags))); |
| 429 | SDL_SetRenderDrawColor(m_renderer, sr, sg, sb, sa); |
| 430 | SDL_RenderFillRect(m_renderer, &target_rect); |
| 431 | } |
| 432 | 432 | } |
| 433 | 433 | |
| 434 | 434 | static int RendererSupportsFormat(SDL_Renderer *renderer, Uint32 format, Uint32 access, const char *sformat) |
| r243230 | r243231 | |
| 518 | 518 | else |
| 519 | 519 | osd_printf_verbose("Loaded opengl shared library: %s\n", stemp ? stemp : "<default>"); |
| 520 | 520 | |
| 521 | | /* Enable bilinear filtering in case it is supported. |
| 522 | | * This applies to all texture operations. However, artwort is pre-scaled |
| 523 | | * and thus shouldn't be affected. |
| 524 | | */ |
| 525 | | if (video_config.filter) |
| 526 | | { |
| 527 | | SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "1"); |
| 528 | | } |
| 529 | | else |
| 530 | | { |
| 531 | | SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "0"); |
| 532 | | } |
| 521 | /* Enable bilinear filtering in case it is supported. |
| 522 | * This applies to all texture operations. However, artwort is pre-scaled |
| 523 | * and thus shouldn't be affected. |
| 524 | */ |
| 525 | if (video_config.filter) |
| 526 | { |
| 527 | SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "1"); |
| 528 | } |
| 529 | else |
| 530 | { |
| 531 | SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "0"); |
| 532 | } |
| 533 | 533 | |
| 534 | 534 | return 0; |
| 535 | 535 | } |
| r243230 | r243231 | |
| 604 | 604 | { |
| 605 | 605 | SDL_DisplayMode mode; |
| 606 | 606 | //SDL_GetCurrentDisplayMode(window->monitor()->handle, &mode); |
| 607 | | SDL_GetWindowDisplayMode(window->sdl_window, &mode); |
| 607 | SDL_GetWindowDisplayMode(window->sdl_window, &mode); |
| 608 | 608 | sdl->m_original_mode = mode; |
| 609 | 609 | mode.w = width; |
| 610 | 610 | mode.h = height; |
| r243230 | r243231 | |
| 630 | 630 | osd_printf_warning("Ignoring depth %d\n", window->depth); |
| 631 | 631 | } |
| 632 | 632 | } |
| 633 | | SDL_SetWindowDisplayMode(window->sdl_window, &mode); // Try to set mode |
| 633 | SDL_SetWindowDisplayMode(window->sdl_window, &mode); // Try to set mode |
| 634 | 634 | #ifndef SDLMAME_WIN32 |
| 635 | | /* FIXME: Warp the mouse to 0,0 in case a virtual desktop resolution |
| 636 | | * is in place after the mode switch - which will most likely be the case |
| 637 | | * This is a hack to work around a deficiency in SDL2 |
| 638 | | */ |
| 639 | | SDL_WarpMouseInWindow(window->sdl_window, 1, 1); |
| 635 | /* FIXME: Warp the mouse to 0,0 in case a virtual desktop resolution |
| 636 | * is in place after the mode switch - which will most likely be the case |
| 637 | * This is a hack to work around a deficiency in SDL2 |
| 638 | */ |
| 639 | SDL_WarpMouseInWindow(window->sdl_window, 1, 1); |
| 640 | 640 | #endif |
| 641 | 641 | } |
| 642 | 642 | else |
| r243230 | r243231 | |
| 736 | 736 | SDL_GetWindowSize(window->sdl_window, &window->width, &window->height); |
| 737 | 737 | sdl->m_resize_pending = 0; |
| 738 | 738 | SDL_RenderSetViewport(sdl->m_renderer, NULL); |
| 739 | | //sdlvideo_monitor_refresh(window->monitor()); |
| 739 | //sdlvideo_monitor_refresh(window->monitor()); |
| 740 | 740 | |
| 741 | 741 | } |
| 742 | 742 | |
| r243230 | r243231 | |
| 855 | 855 | |
| 856 | 856 | drawsdl2_destroy_all_textures(window); |
| 857 | 857 | |
| 858 | | if (window->fullscreen() && video_config.switchres) |
| 859 | | { |
| 860 | | SDL_SetWindowFullscreen(window->sdl_window, 0); // Try to set mode |
| 861 | | SDL_SetWindowDisplayMode(window->sdl_window, &sdl->m_original_mode); // Try to set mode |
| 862 | | SDL_SetWindowFullscreen(window->sdl_window, SDL_WINDOW_FULLSCREEN); // Try to set mode |
| 863 | | } |
| 858 | if (window->fullscreen() && video_config.switchres) |
| 859 | { |
| 860 | SDL_SetWindowFullscreen(window->sdl_window, 0); // Try to set mode |
| 861 | SDL_SetWindowDisplayMode(window->sdl_window, &sdl->m_original_mode); // Try to set mode |
| 862 | SDL_SetWindowFullscreen(window->sdl_window, SDL_WINDOW_FULLSCREEN); // Try to set mode |
| 863 | } |
| 864 | 864 | |
| 865 | | SDL_DestroyWindow(window->sdl_window); |
| 865 | SDL_DestroyWindow(window->sdl_window); |
| 866 | 866 | |
| 867 | 867 | global_free(sdl); |
| 868 | 868 | window->dxdata = NULL; |
| r243230 | r243231 | |
| 889 | 889 | { |
| 890 | 890 | if (RendererSupportsFormat(m_renderer, bi->dst_fmt, m_sdl_access, bi->dstname)) |
| 891 | 891 | { |
| 892 | | int perf = bi->perf; |
| 892 | int perf = bi->perf; |
| 893 | 893 | if (perf == 0) |
| 894 | 894 | return bi; |
| 895 | 895 | else if (perf > (maxperf * 102) / 100) |
| r243230 | r243231 | |
| 920 | 920 | |
| 921 | 921 | bool texture_info::matches(const render_primitive &prim, const quad_setup_data &setup) |
| 922 | 922 | { |
| 923 | | return texinfo().base == prim.texture.base && |
| 924 | | texinfo().width == prim.texture.width && |
| 925 | | texinfo().height == prim.texture.height && |
| 926 | | texinfo().rowpixels == prim.texture.rowpixels && |
| 927 | | m_setup.dudx == setup.dudx && |
| 928 | | m_setup.dvdx == setup.dvdx && |
| 929 | | m_setup.dudy == setup.dudy && |
| 930 | | m_setup.dvdy == setup.dvdy && |
| 931 | | ((flags() ^ prim.flags) & (PRIMFLAG_BLENDMODE_MASK | PRIMFLAG_TEXFORMAT_MASK)) == 0; |
| 923 | return texinfo().base == prim.texture.base && |
| 924 | texinfo().width == prim.texture.width && |
| 925 | texinfo().height == prim.texture.height && |
| 926 | texinfo().rowpixels == prim.texture.rowpixels && |
| 927 | m_setup.dudx == setup.dudx && |
| 928 | m_setup.dvdx == setup.dvdx && |
| 929 | m_setup.dudy == setup.dudy && |
| 930 | m_setup.dvdy == setup.dvdy && |
| 931 | ((flags() ^ prim.flags) & (PRIMFLAG_BLENDMODE_MASK | PRIMFLAG_TEXFORMAT_MASK)) == 0; |
| 932 | 932 | } |
| 933 | 933 | |
| 934 | 934 | //============================================================ |
| r243230 | r243231 | |
| 937 | 937 | |
| 938 | 938 | texture_info::texture_info(SDL_Renderer *renderer, const render_texinfo &texsource, const quad_setup_data &setup, UINT32 flags) |
| 939 | 939 | { |
| 940 | |
| 940 | 941 | // fill in the core data |
| 941 | | m_renderer = renderer; |
| 942 | m_renderer = renderer; |
| 942 | 943 | m_hash = texture_compute_hash(texsource, flags); |
| 943 | 944 | m_flags = flags; |
| 944 | 945 | m_texinfo = texsource; |
| r243230 | r243231 | |
| 996 | 997 | |
| 997 | 998 | if (m_sdl_access == SDL_TEXTUREACCESS_STATIC) |
| 998 | 999 | { |
| 999 | | if (m_copyinfo->func != NULL) |
| 1000 | | m_pixels = malloc(m_setup.rotwidth * m_setup.rotheight * m_copyinfo->dst_bpp); |
| 1001 | | else |
| 1002 | | m_pixels = NULL; |
| 1000 | if (m_copyinfo->func != NULL) |
| 1001 | m_pixels = malloc(m_setup.rotwidth * m_setup.rotheight * m_copyinfo->dst_bpp); |
| 1002 | else |
| 1003 | m_pixels = NULL; |
| 1003 | 1004 | } |
| 1004 | 1005 | m_last_access = osd_ticks(); |
| 1005 | 1006 | |
| r243230 | r243231 | |
| 1007 | 1008 | |
| 1008 | 1009 | texture_info::~texture_info() |
| 1009 | 1010 | { |
| 1010 | | if ( is_pixels_owned() && (m_pixels != NULL) ) |
| 1011 | | free(m_pixels); |
| 1012 | | SDL_DestroyTexture(m_texture_id); |
| 1011 | if ( is_pixels_owned() && (m_pixels != NULL) ) |
| 1012 | free(m_pixels); |
| 1013 | SDL_DestroyTexture(m_texture_id); |
| 1013 | 1014 | } |
| 1014 | 1015 | |
| 1015 | 1016 | //============================================================ |
| r243230 | r243231 | |
| 1081 | 1082 | |
| 1082 | 1083 | #if 0 |
| 1083 | 1084 | printf("tl.u %f tl.v %f\n", texcoords->tl.u, texcoords->tl.v); |
| 1084 | | printf("tr.u %f tr.v %f\n", texcoords->tr.u, texcoords->tr.v); |
| 1085 | | printf("bl.u %f bl.v %f\n", texcoords->bl.u, texcoords->bl.v); |
| 1086 | | printf("br.u %f br.v %f\n", texcoords->br.u, texcoords->br.v); |
| 1085 | printf("tr.u %f tr.v %f\n", texcoords->tr.u, texcoords->tr.v); |
| 1086 | printf("bl.u %f bl.v %f\n", texcoords->bl.u, texcoords->bl.v); |
| 1087 | printf("br.u %f br.v %f\n", texcoords->br.u, texcoords->br.v); |
| 1087 | 1088 | /* compute start and delta U,V coordinates now */ |
| 1088 | 1089 | #endif |
| 1089 | 1090 | |
| r243230 | r243231 | |
| 1161 | 1162 | if (texture == NULL && prim.texture.base != NULL) |
| 1162 | 1163 | { |
| 1163 | 1164 | texture = global_alloc(texture_info(m_renderer, prim.texture, setup, prim.flags)); |
| 1164 | | /* add us to the texture list */ |
| 1165 | /* add us to the texture list */ |
| 1165 | 1166 | m_texlist.prepend(*texture); |
| 1166 | 1167 | |
| 1167 | 1168 | } |
| r243230 | r243231 | |
| 1190 | 1191 | if(window->primlist) |
| 1191 | 1192 | { |
| 1192 | 1193 | window->primlist->acquire_lock(); |
| 1193 | | sdl->m_texlist.reset(); |
| 1194 | | window->primlist->release_lock(); |
| 1194 | sdl->m_texlist.reset(); |
| 1195 | window->primlist->release_lock(); |
| 1195 | 1196 | } |
| 1196 | 1197 | else |
| 1197 | | sdl->m_texlist.reset(); |
| 1198 | sdl->m_texlist.reset(); |
| 1198 | 1199 | } |