Skip to content

Commit

Permalink
some more work to ym2610
Browse files Browse the repository at this point in the history
  • Loading branch information
georgemoralis committed Jul 30, 2015
1 parent ed3fdbf commit e636eed
Show file tree
Hide file tree
Showing 4 changed files with 332 additions and 165 deletions.
26 changes: 13 additions & 13 deletions emulator/src/drivers/WIP/superman.java
Expand Up @@ -135,9 +135,9 @@ public void handler(int offset, int data) {
new MemoryReadAddress(0x0000, 0x3fff, MRA_ROM),
new MemoryReadAddress(0x4000, 0x7fff, MRA_BANK2),
new MemoryReadAddress(0xc000, 0xdfff, MRA_RAM),
/*TODO*/// new MemoryReadAddress(0xe000, 0xe000, YM2610_status_port_0_A_r),
/*TODO*/// new MemoryReadAddress(0xe001, 0xe001, YM2610_read_port_0_r),
/*TODO*/// new MemoryReadAddress(0xe002, 0xe002, YM2610_status_port_0_B_r),
new MemoryReadAddress(0xe000, 0xe000, YM2610_status_port_0_A_r),
new MemoryReadAddress(0xe001, 0xe001, YM2610_read_port_0_r),
new MemoryReadAddress(0xe002, 0xe002, YM2610_status_port_0_B_r),
new MemoryReadAddress(0xe200, 0xe200, MRA_NOP),
new MemoryReadAddress(0xe201, 0xe201, r_rd_a001),
new MemoryReadAddress(0xea00, 0xea00, MRA_NOP),
Expand All @@ -147,10 +147,10 @@ public void handler(int offset, int data) {
= {
new MemoryWriteAddress(0x0000, 0x7fff, MWA_ROM),
new MemoryWriteAddress(0xc000, 0xdfff, MWA_RAM),
/*TODO*/// new MemoryWriteAddress(0xe000, 0xe000, YM2610_control_port_0_A_w),
/*TODO*/// new MemoryWriteAddress(0xe001, 0xe001, YM2610_data_port_0_A_w),
/*TODO*/// new MemoryWriteAddress(0xe002, 0xe002, YM2610_control_port_0_B_w),
/*TODO*/// new MemoryWriteAddress(0xe003, 0xe003, YM2610_data_port_0_B_w),
new MemoryWriteAddress(0xe000, 0xe000, YM2610_control_port_0_A_w),
new MemoryWriteAddress(0xe001, 0xe001, YM2610_data_port_0_A_w),
new MemoryWriteAddress(0xe002, 0xe002, YM2610_control_port_0_B_w),
new MemoryWriteAddress(0xe003, 0xe003, YM2610_data_port_0_B_w),
new MemoryWriteAddress(0xe200, 0xe200, r_wr_a000),
new MemoryWriteAddress(0xe201, 0xe201, r_wr_a001),
new MemoryWriteAddress(0xe400, 0xe403, MWA_NOP), /* pan */
Expand Down Expand Up @@ -335,12 +335,12 @@ public void handler(int irq) {
superman_vh_screenrefresh,
/* sound hardware */
0, 0, 0, 0,//SOUND_SUPPORTS_STEREO,0,0,0,
new MachineSound[] {
new MachineSound(
SOUND_YM2610,
ym2610_interface
)
}
new MachineSound[]{
new MachineSound(
SOUND_YM2610,
ym2610_interface
)
}
);

/**
Expand Down
252 changes: 200 additions & 52 deletions emulator/src/sound/_2610intf.java
Expand Up @@ -102,61 +102,63 @@ public static void YM2610UpdateRequest(int chip) {

@Override
public int start(MachineSound msound) {
int i,j;
int rate = Machine.sample_rate;
//char buf[YM2610_NUMBUF][40];
String[] name = new String[YM2610_NUMBUF];
int mixed_vol;
int[] vol=new int[YM2610_NUMBUF];
UBytePtr[] pcmbufa=new UBytePtr[YM2610_NUMBUF];
UBytePtr[] pcmbufb=new UBytePtr[YM2610_NUMBUF];
int[] pcmsizea=new int[YM2610_NUMBUF];
int[] pcmsizeb=new int[YM2610_NUMBUF];

for(int k=0; k<YM2610_NUMBUF; k++)
{
pcmbufa[k]=new UBytePtr();
pcmbufb[k]=new UBytePtr();
}
intf = (YM2610interface)msound.sound_interface;
if( intf.num > MAX_2610 ) return 1;

if (sndintf[SOUND_AY8910].start(msound) != 0) {
int i, j;
int rate = Machine.sample_rate;
//char buf[YM2610_NUMBUF][40];
String[] name = new String[YM2610_NUMBUF];
int mixed_vol;
int[] vol = new int[YM2610_NUMBUF];
UBytePtr[] pcmbufa = new UBytePtr[YM2610_NUMBUF];
UBytePtr[] pcmbufb = new UBytePtr[YM2610_NUMBUF];
int[] pcmsizea = new int[YM2610_NUMBUF];
int[] pcmsizeb = new int[YM2610_NUMBUF];

for (int k = 0; k < YM2610_NUMBUF; k++) {
pcmbufa[k] = new UBytePtr();
pcmbufb[k] = new UBytePtr();
}
intf = (YM2610interface) msound.sound_interface;
if (intf.num > MAX_2610) {
return 1;
}

/* Timer Handler set */
FMTimerInit();

/* stream system initialize */
for (i = 0;i < intf.num;i++)
{
/* stream setup */
mixed_vol = intf.volumeFM[i];
/* stream setup */
for (j = 0 ; j < YM2610_NUMBUF ; j++)
{
//name[j]=buf[j];
vol[j] = mixed_vol & 0xffff;
mixed_vol>>=16;
name[j]=sprintf("%s #%d Ch%d",sound_name(msound),i,j+1);
}
stream[i] = stream_init_multi(YM2610_NUMBUF,name,vol,rate,i,YM2610UpdateOne);
/* setup adpcm buffers */
pcmbufa[i] = memory_region(intf.pcmroma[i]);
pcmsizea[i] = memory_region_length(intf.pcmroma[i]);
pcmbufb[i] = memory_region(intf.pcmromb[i]);
pcmsizeb[i] = memory_region_length(intf.pcmromb[i]);
}

/**** initialize YM2610 ****/
if (YM2610Init(intf.num,intf.baseclock,rate,
pcmbufa,pcmsizea,pcmbufb,pcmsizeb,
TimerHandler,IRQHandler) == 0)
return 0;

/* error */
return 1;
if (sndintf[SOUND_AY8910].start(msound) != 0) {
return 1;
}

/* Timer Handler set */
FMTimerInit();

/* stream system initialize */
for (i = 0; i < intf.num; i++) {
/* stream setup */
mixed_vol = intf.volumeFM[i];
/* stream setup */
for (j = 0; j < YM2610_NUMBUF; j++) {
//name[j]=buf[j];
vol[j] = mixed_vol & 0xffff;
mixed_vol >>= 16;
name[j] = sprintf("%s #%d Ch%d", sound_name(msound), i, j + 1);
}
stream[i] = stream_init_multi(YM2610_NUMBUF, name, vol, rate, i, YM2610UpdateOne);
/* setup adpcm buffers */
pcmbufa[i] = memory_region(intf.pcmroma[i]);
pcmsizea[i] = memory_region_length(intf.pcmroma[i]);
pcmbufb[i] = memory_region(intf.pcmromb[i]);
pcmsizeb[i] = memory_region_length(intf.pcmromb[i]);
}

/**
* ** initialize YM2610 ***
*/
if (YM2610Init(intf.num, intf.baseclock, rate,
pcmbufa, pcmsizea, pcmbufb, pcmsizeb,
TimerHandler, IRQHandler) == 0) {
return 0;
}

/* error */
return 1;
}

@Override
Expand All @@ -177,5 +179,151 @@ public void reset() {
YM2610ResetChip(i);
}
}
/**
* *********************************************
*/
/* Status Read for YM2610 - Chip 0 */
/**
* *********************************************
*/
public static ReadHandlerPtr YM2610_status_port_0_A_r = new ReadHandlerPtr() {
public int handler(int offset) {
//if(errorlog) fprintf(errorlog,"PC %04x: 2610 S0A=%02X\n",cpu_get_pc(),YM2610Read(0,0));
return YM2610Read(0, 0);
}
};
public static ReadHandlerPtr YM2610_status_port_0_B_r = new ReadHandlerPtr() {
public int handler(int offset) {
//if(errorlog) fprintf(errorlog,"PC %04x: 2610 S0B=%02X\n",cpu_get_pc(),YM2610Read(0,2));
return YM2610Read(0, 2);
}
};

/**
* *********************************************
*/
/* Status Read for YM2610 - Chip 1 */
/**
* *********************************************
*/
public static ReadHandlerPtr YM2610_status_port_1_A_r = new ReadHandlerPtr() {
public int handler(int offset) {
return YM2610Read(1, 0);
}
};

public static ReadHandlerPtr YM2610_status_port_1_B_r = new ReadHandlerPtr() {
public int handler(int offset) {
return YM2610Read(1, 2);
}
};

/**
* *********************************************
*/
/* Port Read for YM2610 - Chip 0 */
/**
* *********************************************
*/
public static ReadHandlerPtr YM2610_read_port_0_r = new ReadHandlerPtr() {
public int handler(int offset) {
return YM2610Read(0, 1);
}
};

/**
* *********************************************
*/
/* Port Read for YM2610 - Chip 1 */
/**
* *********************************************
*/
public static ReadHandlerPtr YM2610_read_port_1_r = new ReadHandlerPtr() {
public int handler(int offset) {
return YM2610Read(1, 1);
}
};

/**
* *********************************************
*/
/* Control Write for YM2610 - Chip 0 */
/* Consists of 2 addresses */
/**
* *********************************************
*/
public static WriteHandlerPtr YM2610_control_port_0_A_w = new WriteHandlerPtr() {
public void handler(int offset, int data) {
//if(errorlog) fprintf(errorlog,"PC %04x: 2610 Reg A %02X",cpu_get_pc(),data);
YM2610Write(0, 0, data);
}
};

public static WriteHandlerPtr YM2610_control_port_0_B_w = new WriteHandlerPtr() {
public void handler(int offset, int data) {
//if(errorlog) fprintf(errorlog,"PC %04x: 2610 Reg B %02X",cpu_get_pc(),data);
YM2610Write(0, 2, data);
}
};

/**
* *********************************************
*/
/* Control Write for YM2610 - Chip 1 */
/* Consists of 2 addresses */
/**
* *********************************************
*/
public static WriteHandlerPtr YM2610_control_port_1_A_w = new WriteHandlerPtr() {
public void handler(int offset, int data) {
YM2610Write(1, 0, data);
}
};

public static WriteHandlerPtr YM2610_control_port_1_B_w = new WriteHandlerPtr() {
public void handler(int offset, int data) {
YM2610Write(1, 2, data);
}
};

/**
* *********************************************
*/
/* Data Write for YM2610 - Chip 0 */
/* Consists of 2 addresses */
/**
* *********************************************
*/
public static WriteHandlerPtr YM2610_data_port_0_A_w = new WriteHandlerPtr() {
public void handler(int offset, int data) {
//if(errorlog) fprintf(errorlog," =%02X\n",data);
YM2610Write(0, 1, data);
}
};

public static WriteHandlerPtr YM2610_data_port_0_B_w = new WriteHandlerPtr() {
public void handler(int offset, int data) {
//if(errorlog) fprintf(errorlog," =%02X\n",data);
YM2610Write(0, 3, data);
}
};

/**
* *********************************************
*/
/* Data Write for YM2610 - Chip 1 */
/* Consists of 2 addresses */
/**
* *********************************************
*/
public static WriteHandlerPtr YM2610_data_port_1_A_w = new WriteHandlerPtr() {
public void handler(int offset, int data) {
YM2610Write(1, 1, data);
}
};
public static WriteHandlerPtr YM2610_data_port_1_B_w = new WriteHandlerPtr() {
public void handler(int offset, int data) {
YM2610Write(1, 3, data);
}
};
}

0 comments on commit e636eed

Please sign in to comment.