115
static const UINT8 dc_controller_id[0x70] =
117
0x00, 0x00, 0x00, 0x01, 0x00, 0x0f, 0x06, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
118
0xff, 0x00, 0x44, 0x72, 0x65, 0x61, 0x6d, 0x63, 0x61, 0x73, 0x74, 0x20, 0x43, 0x6f, 0x6e, 0x74,
119
0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
120
0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x65, 0x64, 0x20, 0x42, 0x79, 0x20, 0x6f, 0x72, 0x20, 0x55,
121
0x6e, 0x64, 0x65, 0x72, 0x20, 0x4c, 0x69, 0x63, 0x65, 0x6e, 0x73, 0x65, 0x20, 0x46, 0x72, 0x6f,
122
0x6d, 0x20, 0x53, 0x45, 0x47, 0x41, 0x20, 0x45, 0x4e, 0x54, 0x45, 0x52, 0x50, 0x52, 0x49, 0x53,
123
0x45, 0x53, 0x2c, 0x4c, 0x54, 0x44, 0x2e, 0x20, 0x20, 0x20, 0x20, 0x20, 0xae, 0x01, 0xf4, 0x01
126
static const UINT8 dc_controller_version[0x50] =
128
0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x20, 0x31, 0x2e, 0x30, 0x31, 0x30, 0x2c, 0x31, 0x39,
129
0x39, 0x38, 0x2f, 0x30, 0x39, 0x2f, 0x32, 0x38, 0x2c, 0x33, 0x31, 0x35, 0x2d, 0x36, 0x32, 0x31,
130
0x31, 0x2d, 0x41, 0x42, 0x20, 0x20, 0x20, 0x2c, 0x41, 0x6e, 0x61, 0x6c, 0x6f, 0x67, 0x20, 0x4d,
131
0x6f, 0x64, 0x75, 0x6c, 0x65, 0x20, 0x3a, 0x20, 0x54, 0x68, 0x65, 0x20, 0x34, 0x74, 0x68, 0x20,
132
0x45, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x35, 0x2f, 0x38, 0x20, 0x20, 0x2b, 0x44, 0x46
115
135
// selected Maple registers
867
#if 1 //ENABLE_MAPLE_IRQ
868
/*TODO: this fixes moeru but breaks other games, understand why.*/
869
dc_sysctrl_regs[SB_ISTNRM] |= IST_DMA_MAPLE;
870
dc_update_interrupt_status(space->machine);
874
// skip fixed packet header
876
// skip transfer data
877
dat += (length + 1) * 4;
884
printf("MAPLE: hardware trigger not supported yet\n");
892
// implementation for Dreamcast and Atomiswave supports only standard Sega Dreamcast Maple commands and peripherals
893
READ64_HANDLER( dc_maple_r )
898
reg = decode_reg32_64(space->machine, offset, mem_mask, &shift);
901
mame_printf_verbose("MAPLE: Unmapped read %08x\n", 0x5f6c00+reg*4);
903
return (UINT64)maple_regs[reg] << shift;
906
WRITE64_HANDLER( dc_maple_w )
911
struct sh4_ddt_dma ddtdata;
913
UINT32 endflag,port,pattern,length,command,dap,sap,destination;
915
reg = decode_reg32_64(space->machine, offset, mem_mask, &shift);
916
dat = (UINT32)(data >> shift);
917
old = maple_regs[reg];
920
mame_printf_verbose("MAPLE: [%08x=%x] write %" I64FMT "x to %x (reg %x: %s), mask %" I64FMT "x\n", 0x5f6c00+reg*4, dat, data >> shift, offset, reg, maple_names[reg], mem_mask);
923
maple_regs[reg] = dat; // 5f6c00+reg*4=dat
927
maple_regs[reg] = old;
928
if (!(old & 1) && (dat & 1) && maple_regs[SB_MDEN] & 1) // 0 -> 1
930
if (!(maple_regs[SB_MDTSEL] & 1))
933
dat=maple_regs[SB_MDSTAR];
934
// printf("Maple DMA: %08x %08x %08x %08x\n",maple_regs[SB_MDSTAR],maple_regs[SB_MDTSEL],maple_regs[SB_MDEN],maple_regs[SB_MDST]);
935
// printf(" %08x %08x %08x %08x\n",maple_regs[SB_MSYS],maple_regs[SB_MST],maple_regs[SB_MSHTCL],maple_regs[SB_MMSEL]);
936
while (1) // do transfers
938
ddtdata.source=dat; // source address
939
ddtdata.length=3; // words to transfer
940
ddtdata.size=4; // bytes per word
941
ddtdata.buffer=buff; // destination buffer
942
ddtdata.direction=0; // 0 source to buffer, 1 buffer to source
943
ddtdata.channel= -1; // not used
944
ddtdata.mode= -1; // copy from/to buffer
945
sh4_dma_ddt(cputag_get_cpu(space->machine, "maincpu"), &ddtdata);
948
endflag=buff[0] & 0x80000000;
949
port=(buff[0] >> 16) & 3;
950
pattern=(buff[0] >> 8) & 7;
951
length=buff[0] & 255;
955
command=buff[2] & 255;
956
dap=(buff[2] >> 8) & 255;
957
sap=(buff[2] >> 16) & 255;
960
//if(buff[1] == 0x700)
961
// printf("%08x %08x",buff[0],buff[2]);
972
case 1: // AW/DC MAPLE_CMD_INFO
973
ddtdata.length = sizeof(dc_controller_id)/4;
975
buff[0] = 5; // MAPLE_RESP_INFO
976
memcpy(&buff[1], dc_controller_id, sizeof(dc_controller_id));
979
case 2: // AW/DC MAPLE_CMD_EXT_INFO
980
ddtdata.length = sizeof(dc_controller_id)+sizeof(dc_controller_version)/4;
982
buff[0] = 6; // MAPLE_RESP_EXT_INFO
983
memcpy(&buff[1], dc_controller_id, sizeof(dc_controller_id));
984
memcpy(&buff[1+(0x70/4)], dc_controller_version, sizeof(dc_controller_version));
987
case 3: // AW/DC MAPLE_CMD_RESET
990
printf("MAPLE: transfer command %x port %x length %x\n", command, port, length);
994
case 9: // AW/DC MAPLE_CMD_GET_COND
995
buff[0] = 8; // MAPLE_RESP_DATA
997
sprintf(pL, "P%dL", port+1);
998
sprintf(pH, "P%dH", port+1);
1001
buff[2] = input_port_read(space->machine, pH)<<8 | input_port_read(space->machine, pL) | 0xffff0000;
1002
buff[3] = 0xffffffff;
1003
ddtdata.length=(8/4)+1;
1007
printf("MAPLE: unknown transfer command %x port %x\n", command, port);
1010
endflag = 1; /*TODO: check this */
1011
//buff[0]=0xffffffff;
1015
ddtdata.destination=destination;
1016
ddtdata.buffer=buff;
1017
ddtdata.direction=1;
1018
sh4_dma_ddt(cputag_get_cpu(space->machine, "maincpu"),&ddtdata);
845
1022
#if ENABLE_MAPLE_IRQ
846
/*TODO: this fixes moeru but breaks other games, understand why.*/
847
1023
dc_sysctrl_regs[SB_ISTNRM] |= IST_DMA_MAPLE;
848
1024
dc_update_interrupt_status(space->machine);