diff --git a/core/deps/picotcp/include/arch/pico_posix.h b/core/deps/picotcp/include/arch/pico_posix.h index 5ddd1fa6d..de9bab022 100644 --- a/core/deps/picotcp/include/arch/pico_posix.h +++ b/core/deps/picotcp/include/arch/pico_posix.h @@ -16,7 +16,7 @@ #define TIME_PRESCALE #define PICO_SUPPORT_THREADING */ -#ifdef RELEASE +#if defined(RELEASE) && !defined(DEBUGFAST) #define dbg(...) #else #define dbg printf diff --git a/core/deps/picotcp/modules/pico_dev_ppp.c b/core/deps/picotcp/modules/pico_dev_ppp.c index e1ba6384a..bc3902448 100644 --- a/core/deps/picotcp/modules/pico_dev_ppp.c +++ b/core/deps/picotcp/modules/pico_dev_ppp.c @@ -543,7 +543,7 @@ static int ppp_fcs_verify(uint8_t *buf, uint32_t len) } /* Serial send (DTE->DCE) functions */ -static int pico_ppp_ctl_send(struct pico_device *dev, uint16_t code, uint8_t *pkt, uint32_t len) +static int pico_ppp_ctl_send(struct pico_device *dev, uint16_t code, uint8_t *pkt, uint32_t len, uint32_t no_escape) { struct pico_device_ppp *ppp = (struct pico_device_ppp *) dev; uint16_t fcs; @@ -567,7 +567,15 @@ static int pico_ppp_ctl_send(struct pico_device *dev, uint16_t code, uint8_t *pk pkt[len - 3] = (uint8_t)(fcs & 0xFFu); pkt[len - 2] = (uint8_t)((fcs & 0xFF00u) >> 8); pkt[len - 1] = PPPF_FLAG_SEQ; + uint32_t asyncmap; + if (no_escape) + { + asyncmap = ppp->asyncmap; + ppp->asyncmap = 0xffffffff; + } ppp_serial_send_escape(ppp, pkt, (int)len); + if (no_escape) + ppp->asyncmap = asyncmap; return (int)len; } @@ -912,7 +920,8 @@ static void lcp_send_configure_request(struct pico_device_ppp *ppp) sizeof(struct pico_lcp_hdr) + /* LCP HDR */ optsize + /* Actual options size */ PPP_FCS_SIZE + /* FCS at the end of the frame */ - 1u) /* STOP Byte */ + 1u), /* STOP Byte */ + 1 /* no escape */ ); PICO_FREE(lcpbuf); ppp->timer_val = PICO_PPP_DEFAULT_TIMER; @@ -1007,8 +1016,9 @@ static void lcp_send_configure_ack(struct pico_device_ppp *ppp) PPP_HDR_SIZE + PPP_PROTO_SLOT_SIZE + /* PPP Header, etc. */ short_be(lcpreq->len) + /* Actual options size + hdr (whole lcp packet) */ PPP_FCS_SIZE + /* FCS at the end of the frame */ - 1 /* STOP Byte */ - ); + 1, /* STOP Byte */ + 1 /* no escape */ + ); } static void lcp_send_terminate_request(struct pico_device_ppp *ppp) @@ -1023,7 +1033,8 @@ static void lcp_send_terminate_request(struct pico_device_ppp *ppp) PPP_HDR_SIZE + PPP_PROTO_SLOT_SIZE + /* PPP Header, etc. */ sizeof(struct pico_lcp_hdr) + /* Actual options size + hdr (whole lcp packet) */ PPP_FCS_SIZE + /* FCS at the end of the frame */ - 1 /* STOP Byte */ + 1, /* STOP Byte */ + 1 /* no escape */ ); lcp_timer_start(ppp, PPP_TIMER_ON_LCPTERM); } @@ -1042,7 +1053,8 @@ static void lcp_send_terminate_ack(struct pico_device_ppp *ppp) PPP_HDR_SIZE + PPP_PROTO_SLOT_SIZE + /* PPP Header, etc. */ short_be(lcpreq->len) + /* Actual options size + hdr (whole lcp packet) */ PPP_FCS_SIZE + /* FCS at the end of the frame */ - 1 /* STOP Byte */ + 1, /* STOP Byte */ + 1 /* no escape */ ); } @@ -1088,7 +1100,8 @@ static void lcp_send_configure_nack(struct pico_device_ppp *ppp) sizeof(struct pico_lcp_hdr) + /* LCP HDR */ dstopts_len + /* Actual options size */ PPP_FCS_SIZE + /* FCS at the end of the frame */ - 1u) /* STOP Byte */ + 1u), /* STOP Byte */ + 1 /* no escape */ ); } @@ -1216,7 +1229,8 @@ static void ipcp_send_ack(struct pico_device_ppp *ppp) PPP_HDR_SIZE + PPP_PROTO_SLOT_SIZE + /* PPP Header, etc. */ short_be(ipcpreq->len) + /* Actual options size + hdr (whole ipcp packet) */ PPP_FCS_SIZE + /* FCS at the end of the frame */ - 1 /* STOP Byte */ + 1, /* STOP Byte */ + 0 /* escape */ ); } @@ -1267,7 +1281,8 @@ static void ipcp_send_req(struct pico_device_ppp *ppp) (uint32_t)(prefix + /* PPP Header, etc. */ (uint32_t)len + /* IPCP Header + options */ PPP_FCS_SIZE + /* FCS at the end of the frame */ - 1u) /* STOP Byte */ + 1u), /* STOP Byte */ + 0 /* escape */ ); } @@ -1295,7 +1310,8 @@ static void ipcp_reject_vj(struct pico_device_ppp *ppp, uint8_t *comp_req) sizeof(struct pico_ipcp_hdr) + /* LCP HDR */ IPCP_VJ_LEN + /* Actual options size */ PPP_FCS_SIZE + /* FCS at the end of the frame */ - 1u) /* STOP Byte */ + 1u), /* STOP Byte */ + 0 /* escape */ ); } @@ -1574,8 +1590,9 @@ static void lcp_send_echo_reply(struct pico_device_ppp *ppp) PPP_HDR_SIZE + PPP_PROTO_SLOT_SIZE + /* PPP Header, etc. */ short_be(lcpreq->len) + /* Actual options size + hdr (whole lcp packet) */ PPP_FCS_SIZE + /* FCS at the end of the frame */ - 1 /* STOP Byte */ - ); + 1, /* STOP Byte */ + 0 /* escape */ + ); } static const struct pico_ppp_fsm ppp_lcp_fsm[PPP_LCP_STATE_MAX][PPP_LCP_EVENT_MAX] = { @@ -1618,7 +1635,7 @@ static const struct pico_ppp_fsm ppp_lcp_fsm[PPP_LCP_STATE_MAX][PPP_LCP_EVENT_MA [PPP_LCP_STATE_CLOSED] = { [PPP_LCP_EVENT_UP] = { PPP_LCP_STATE_CLOSED, {} }, [PPP_LCP_EVENT_DOWN] = { PPP_LCP_STATE_INITIAL, {} }, - [PPP_LCP_EVENT_OPEN] = { PPP_LCP_STATE_REQ_SENT, { lcp_send_configure_request} }, + [PPP_LCP_EVENT_OPEN] = { PPP_LCP_STATE_REQ_SENT, { lcp_send_configure_request } }, [PPP_LCP_EVENT_CLOSE] = { PPP_LCP_STATE_CLOSED, {} }, [PPP_LCP_EVENT_TO_POS] = { PPP_LCP_STATE_CLOSED, {} }, [PPP_LCP_EVENT_TO_NEG] = { PPP_LCP_STATE_CLOSED, {} }, @@ -1871,7 +1888,8 @@ static void auth_req(struct pico_device_ppp *ppp) PPP_HDR_SIZE + PPP_PROTO_SLOT_SIZE + /* PPP Header, etc. */ pap_len + /* Authentication packet len */ PPP_FCS_SIZE + /* FCS */ - 1) /* STOP Byte */ + 1), /* STOP Byte */ + 0 /* escape */ ); PICO_FREE(req); } @@ -1916,7 +1934,8 @@ static void auth_rsp(struct pico_device_ppp *ppp) 1 + /* Value length */ CHAP_MD5_SIZE + /* Actual payload size */ PPP_FCS_SIZE + /* FCS at the end of the frame */ - 1) /* STOP Byte */ + 1), /* STOP Byte */ + 0 /* escape */ ); } @@ -2051,7 +2070,8 @@ static void ipcp_send_nack(struct pico_device_ppp *ppp) ppp_dbg("Sending IPCP CONF NAK\n"); pico_ppp_ctl_send(&ppp->dev, PPP_PROTO_IPCP, ipcp_req, /* Start of PPP packet */ - (uint32_t)sizeof(ipcp_req)); + (uint32_t)sizeof(ipcp_req), + 0); /* escape */ } static void ipcp_bring_up(struct pico_device_ppp *ppp) @@ -2329,6 +2349,7 @@ struct pico_device *pico_ppp_create(void) ppp->lcp_state = PPP_LCP_STATE_INITIAL; ppp->auth_state = PPP_AUTH_STATE_INITIAL; ppp->ipcp_state = PPP_IPCP_STATE_INITIAL; + ppp->asyncmap = 0xffffffff; ppp->timer = pico_timer_add(1000, pico_ppp_tick, ppp); if (!ppp->timer) { diff --git a/core/deps/picotcp/modules/pico_tcp.c b/core/deps/picotcp/modules/pico_tcp.c index 8792e49aa..0384c8f5b 100644 --- a/core/deps/picotcp/modules/pico_tcp.c +++ b/core/deps/picotcp/modules/pico_tcp.c @@ -2770,7 +2770,7 @@ static uint8_t invalid_flags(struct pico_socket *s, uint8_t flags) static const uint8_t valid_flags[PICO_SOCKET_STATE_TCP_ARRAYSIZ][MAX_VALID_FLAGS] = { { /* PICO_SOCKET_STATE_TCP_UNDEF */ 0, }, { /* PICO_SOCKET_STATE_TCP_CLOSED */ 0, }, - { /* PICO_SOCKET_STATE_TCP_LISTEN */ PICO_TCP_SYN }, + { /* PICO_SOCKET_STATE_TCP_LISTEN */ PICO_TCP_SYN, PICO_TCP_SYN | PICO_TCP_PSH }, { /* PICO_SOCKET_STATE_TCP_SYN_SENT */ PICO_TCP_SYNACK, PICO_TCP_RST, PICO_TCP_RSTACK}, { /* PICO_SOCKET_STATE_TCP_SYN_RECV */ PICO_TCP_SYN, PICO_TCP_ACK, PICO_TCP_PSH, PICO_TCP_PSHACK, PICO_TCP_FINACK, PICO_TCP_FINPSHACK, PICO_TCP_RST}, { /* PICO_SOCKET_STATE_TCP_ESTABLISHED*/ PICO_TCP_SYN, PICO_TCP_SYNACK, PICO_TCP_ACK, PICO_TCP_PSH, PICO_TCP_PSHACK, PICO_TCP_FIN, PICO_TCP_FINACK, PICO_TCP_FINPSHACK, PICO_TCP_RST, PICO_TCP_RSTACK}, @@ -2850,7 +2850,7 @@ int pico_tcp_input(struct pico_socket *s, struct pico_frame *f) if(invalid_flags(s, flags)) { pico_tcp_reply_rst(f); } - else if (flags == PICO_TCP_SYN) { + else if (flags == PICO_TCP_SYN || flags == (PICO_TCP_SYN | PICO_TCP_PSH)) { tcp_action_call(action->syn, s, f); } else if (flags == (PICO_TCP_SYN | PICO_TCP_ACK)) { tcp_action_call(action->synack, s, f); diff --git a/core/hw/modem/modem.cpp b/core/hw/modem/modem.cpp index 6ac7541fd..a4f970137 100644 --- a/core/hw/modem/modem.cpp +++ b/core/hw/modem/modem.cpp @@ -121,7 +121,8 @@ static void ControllerTestEnd(); static void DSPTestStart(); static void DSPTestEnd(); -static double last_dial_time; +static u64 last_dial_time; +static u64 connected_time; #ifndef RELEASE static double last_comm_stats; @@ -131,7 +132,7 @@ static FILE *recv_fp; static FILE *sent_fp; #endif -static int modem_sched_func(int tag, int c, int j) +static int modem_sched_func(int tag, int cycles, int jitter) { #ifndef RELEASE if (os_GetSeconds() - last_comm_stats >= 2) @@ -166,7 +167,7 @@ static int modem_sched_func(int tag, int c, int j) switch (connect_state) { case DIALING: - if (last_dial_time != 0 && os_GetSeconds() - last_dial_time > 0.99) + if (last_dial_time != 0 && sh4_sched_now64() - last_dial_time >= SH4_MAIN_CLOCK + jitter) { LOG("Switching to RINGING state"); connect_state = RINGING; @@ -174,7 +175,7 @@ static int modem_sched_func(int tag, int c, int j) } else { - last_dial_time = os_GetSeconds(); + last_dial_time = sh4_sched_now64(); modem_regs.reg1e.TDBE = 1; schedule_callback(1000); // To switch to Ringing state @@ -201,7 +202,7 @@ static int modem_sched_func(int tag, int c, int j) SET_STATUS_BIT(0x0f, modem_regs.reg0f.RI, 0); SET_STATUS_BIT(0x0b, modem_regs.reg0b.ATV25, 0); - callback_cycles = SH4_MAIN_CLOCK / 1000000 * 500; // 500 ms + callback_cycles = SH4_MAIN_CLOCK / 1000 * 500; // 500 ms connect_state = PRE_CONNECTED; break; @@ -214,10 +215,13 @@ static int modem_sched_func(int tag, int c, int j) { // V8 AUTO mode dspram[0x302] |= 1 << 4; // protocol octet received + dspram[0x302] = (dspram[0x302] & 0x1f) | (dspram[0x304] & 0xe0); // Received Call Function dspram[0x301] |= 1 << 4; // JM detected dspram[0x303] |= 0xE0; // Received protocol bits (?) - dspram[0x2e3] |= 5; // Symbol rate 3429 - dspram[0x239] |= 12; // RTD 0 @ 3429 sym rate + dspram[0x2e3] = 5; // Symbol rate 3429 + dspram[0x2e4] = 0xe; // V.34 Receiver Speed 33.6 + dspram[0x2e5] = 0xe; // V.34 Transmitter Speed 33.6 + dspram[0x239] = 12; // RTD 0 @ 3429 sym rate if (modem_regs.reg08.ASYN) { modem_regs.reg12 = 0xce; // CONF V34 - K56flex @@ -253,7 +257,7 @@ static int modem_sched_func(int tag, int c, int j) if (modem_regs.reg02.v0.RTSDE) SET_STATUS_BIT(0x0f, modem_regs.reg0f.RTSDT, 1); - // What is this? This is required for games to detect the connection + // Energy detected. Required for games to detect the connection SET_STATUS_BIT(0x0f, modem_regs.reg0f.FED, 1); // V.34 Remote Modem Data Rate Capability @@ -263,6 +267,7 @@ static int modem_sched_func(int tag, int c, int j) start_pppd(); connect_state = CONNECTED; callback_cycles = SH4_MAIN_CLOCK / 1000000 * 238; // 238 us + connected_time = 0; break; @@ -276,10 +281,13 @@ static int modem_sched_func(int tag, int c, int j) LOG("modem_regs %02x == %02x", i, modem_regs.ptr[i]); } #endif + if (connected_time == 0) + connected_time = sh4_sched_now64(); if (!modem_regs.reg1e.RDBF) { int c = read_pppd(); - if (c >= 0) + // Delay reading from ppp to avoid choking WinCE + if (c >= 0 && sh4_sched_now64() - connected_time >= SH4_MAIN_CLOCK / 4) { //LOG("pppd received %02x", c); #ifndef RELEASE @@ -572,10 +580,7 @@ static void ModemNormalWrite(u32 reg, u32 data) u32 dspram_addr = modem_regs.reg1c_1d.MEMADD_l | (modem_regs.reg1c_1d.MEMADD_h << 8); if (modem_regs.reg1c_1d.MEMW) { - //LOG("DSP mem Write%s address %08x = %x", - // word_dspram_write ? " (w)" : "", - // dspram_addr, - // modem_regs.reg18_19 ); + LOG("DSP mem Write%s address %08x = %x", word_dspram_write ? " (w)" : "", dspram_addr, modem_regs.reg18_19); if (word_dspram_write) { if (dspram_addr & 1) @@ -595,9 +600,7 @@ static void ModemNormalWrite(u32 reg, u32 data) modem_regs.reg18_19 = dspram[dspram_addr] | (dspram[dspram_addr + 1] << 8); else modem_regs.reg18_19 = *(u16*)&dspram[dspram_addr]; - //LOG("DSP mem Read address %08x == %x", - // dspram_addr, - // modem_regs.reg18_19 ); + LOG("DSP mem Read address %08x == %x", dspram_addr, modem_regs.reg18_19 ); } } break; @@ -631,7 +634,7 @@ static void ModemNormalWrite(u32 reg, u32 data) break; default: - //printf("ModemNormalWrite : undef %03X=%X\n",reg,data); + //LOG("ModemNormalWrite : undef %03X = %X", reg, data); break; } update_interrupt(); diff --git a/core/hw/modem/modem_regs.h b/core/hw/modem/modem_regs.h index 2c013e65c..08e739c59 100644 --- a/core/hw/modem/modem_regs.h +++ b/core/hw/modem/modem_regs.h @@ -22,7 +22,7 @@ */ #pragma once -#pragma pack(1) +#pragma pack(push, 1) union modemreg_t { u8 ptr[0x21]; @@ -318,6 +318,7 @@ union modemreg_t } reg1f; }; }; +#pragma pack(pop) u8 regs_write_mask[] = { //00 Receive Data Buffer (RBUFFER)/Voice Receive Data Buffer (VBUFR) @@ -433,7 +434,7 @@ static const u8 por_dspram[] = /* 0x060 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x070 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x080 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -/* 0x090 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +/* 0x090 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 9F avail mod type (wince): 80, 30, 00? /* 0x0A0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0B0 */ 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0C0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -458,10 +459,10 @@ static const u8 por_dspram[] = /* 0x1E0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1F0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -/* 0x200 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +/* 0x200 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 204-5 rate_seq_R2, 208-209 rate_seq_R3 /* 0x210 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xDD, 0xAD, 0x08, 0x07, 0x99, 0x00, 0x23, 0xA0, /* 0x220 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x56, 0x00, 0x00, 0x00, -/* 0x230 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +/* 0x230 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 239 Round Trip Far Echo Delay /* 0x240 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x250 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x260 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 26F Saved Filtered EQM (???) diff --git a/core/nullDC.cpp b/core/nullDC.cpp index 51ea0b5f6..a2bedf745 100755 --- a/core/nullDC.cpp +++ b/core/nullDC.cpp @@ -141,7 +141,7 @@ void LoadSpecialSettings() full_mmu_game = false; disable_vmem32_game = false; - if (reios_windows_ce) + if (reios_windows_ce || !strncmp("T26702N", reios_product_number, 7)) // PBA Tour Bowling 2001 { INFO_LOG(BOOT, "Enabling Full MMU and Extra depth scaling for Windows CE game"); settings.rend.ExtraDepthScale = 0.1; @@ -216,7 +216,14 @@ void LoadSpecialSettings() // Marionette Company || !strncmp("T5202M", reios_product_number, 6) // Marionette Company 2 - || !strncmp("T5203M", reios_product_number, 6)) + || !strncmp("T5203M", reios_product_number, 6) + // Maximum Pool (for online support) + || !strncmp("T11010N", reios_product_number, 7) + // StarLancer (US) (for online support) + || !strncmp("T40209N", reios_product_number, 7) + // StarLancer (EU) (for online support) + || !strncmp("T17723D 05", reios_product_number, 10) + ) { INFO_LOG(BOOT, "Disabling 32-bit virtual memory for game %s", reios_product_number); settings.dynarec.disable_vmem32 = true;