| 161 | */ |
| 162 | |
| 163 | static int __Deci2Call(int call, u32 *addr) |
| 164 | { |
| 165 | if (call > 0x10) |
| 166 | return -1; |
| 167 | |
| 168 | switch (call) |
| 169 | { |
| 170 | case 1: // open |
| 171 | if( addr != NULL ) |
| 172 | { |
| 173 | deci2addr = addr[1]; |
| 174 | BIOS_LOG("deci2open: %x,%x,%x,%x", |
| 175 | addr[3], addr[2], addr[1], addr[0]); |
| 176 | deci2handler = addr[2]; |
| 177 | } |
| 178 | else |
| 179 | { |
| 180 | deci2handler = 0; |
| 181 | DevCon.Warning( "Deci2Call.Open > NULL address ignored." ); |
| 182 | } |
| 183 | return 1; |
| 184 | |
| 185 | case 2: // close |
| 186 | deci2addr = 0; |
| 187 | deci2handler = 0; |
| 188 | return 1; |
| 189 | |
| 190 | case 3: // reqsend |
| 191 | { |
| 192 | char reqaddr[128]; |
| 193 | if( addr != NULL ) |
| 194 | std::snprintf(reqaddr, std::size(reqaddr), "%x %x %x %x", addr[3], addr[2], addr[1], addr[0]); |
| 195 | |
| 196 | if (!deci2addr) return 1; |
| 197 | |
| 198 | const u32* d2ptr = (u32*)PSM(deci2addr); |
| 199 | |
| 200 | BIOS_LOG("deci2reqsend: %s: deci2addr: %x,%x,%x,buf=%x %x,%x,len=%x,%x", |
| 201 | (( addr == NULL ) ? "NULL" : reqaddr), |
| 202 | d2ptr[7], d2ptr[6], d2ptr[5], d2ptr[4], |
| 203 | d2ptr[3], d2ptr[2], d2ptr[1], d2ptr[0]); |
| 204 | |
| 205 | // cpuRegs.pc = deci2handler; |
| 206 | // Console.WriteLn("deci2msg: %s", (char*)PSM(d2ptr[4]+0xc)); |
| 207 | |
| 208 | if (d2ptr[1]>0xc){ |
| 209 | // this looks horribly wrong, justification please? |
| 210 | u8* pdeciaddr = (u8*)dmaGetAddr(d2ptr[4]+0xc, false); |
| 211 | if( pdeciaddr == NULL ) |
| 212 | pdeciaddr = (u8*)PSM(d2ptr[4]+0xc); |
| 213 | else |
| 214 | pdeciaddr += (d2ptr[4]+0xc) % 16; |
| 215 | |
| 216 | const int copylen = std::min<uint>(255, d2ptr[1]-0xc); |
| 217 | memcpy(deci2buffer, pdeciaddr, copylen ); |
| 218 | deci2buffer[copylen] = '\0'; |
| 219 | |
| 220 | eeConLog( ShiftJIS_ConvertString(deci2buffer) ); |
no test coverage detected