Great work Stef! ;D
I have tested it on Genesis Plus and it works ok. The sound looks to crap sometimes, but... what the hell, this is a really cool beta release! 8)
Printable View
Great work Stef! ;D
I have tested it on Genesis Plus and it works ok. The sound looks to crap sometimes, but... what the hell, this is a really cool beta release! 8)
Sound is better than the older in genesis plus ? ( loop etc ... )
It sounds just like the older one. I think it should improve tweaking other parts of sound core. Probably DC related stuff.
im surprised that this new z80 seems to output the same results as gp dc pvr3. With c68k, pvr3 looks fullspeed with loopyness and some other sound problems. With FAME, which is supposed to be faster than c68k, and this new CZ80 which is 2 times faster, no difference in sound is noticable? Why?
because the sound being loopy is an independant problem to speed.
I got the code worked out so that it compiles in NeoDC, but whenever I go to call for the execution of some Z80 cycles, it resets the DC. Any reason you can think of?
my cflags are : "-ml -m4-single-only -fomit-frame-pointer -falign-loops -fstrict-aliasing"
if anything is missing from there that it requires, or anything there that might break it, please tell me =P
here's my cpuz80 file (everything that i changed):
Edit: I trimmed out a lot of unnecessary things in an attempt to reveal the problem, but still nothing =\.Code:// Z80 CPU interface
#include <stdio.h>
#include "../types.h"
#include "cpuz80.h"
#include "cz80/cz80.h"
/********************************************/
//NeoDC Specific//
/********************************************/
#include "../memory/memory.h"
#include "../neocd.h"
U8 subcpu_memspace[65536] __attribute__((aligned(32)));
int sound_code = 0;
int pending_command = 0;
int result_code = 0;
int z80_cycles = Z80_VBL_CYCLES;
//---------------------------------------------------------------------------
u32 FASTCALL PortRead(u32 adr)
{
static int bank[4];
switch( adr & 0xff)
{
case 0x0:
pending_command = 0;
return sound_code;
break;
case 0x4:
return YM2610_status_port_0_A_r(0);
break;
case 0x5:
return YM2610_read_port_0_r(0);
break;
case 0x6:
return YM2610_status_port_0_B_r(0);
break;
case 0x08:
{
bank[3] = 0x0800 * ((adr >> 8) & 0x7f);
return 0;
break;
}
case 0x09:
{
bank[2] = 0x1000 * ((adr >> 8) & 0x3f);
return 0;
break;
}
case 0x0a:
{
bank[1] = 0x2000 * ((adr >> 8) & 0x1f);
return 0;
break;
}
case 0x0b:
{
bank[0] = 0x4000 * ((adr >> 8) & 0x0f);
return 0;
break;
}
default:
printf("Unimplemented Z80 Read Port: %d\n",adr&0xff);
break;
};
return 0;
}
void FASTCALL PortWrite(u32 adr, u32 data)
{
switch( adr & 0xff)
{
case 0x4:
YM2610_control_port_0_A_w(0,data);
break;
case 0x5:
YM2610_data_port_0_A_w(0,data);
break;
case 0x6:
YM2610_control_port_0_B_w(0,data);
break;
case 0x7:
YM2610_data_port_0_B_w(0,data);
break;
case 0x8:
/* NMI enable / acknowledge? (the data written doesn't matter) */
break;
case 0xc:
result_code = data;
break;
case 0x18:
/* NMI disable? (the data written doesn't matter) */
break;
default:
printf("Unimplemented Z80 Write Port: %x data: %x\n",adr&0xff,data);
break;
}
}
/*****************************/
/********************************************/
void Z80_Init(void)
{
printf("Z80 cpu init start... ");
Cz80_Init(&CZ80);
Cz80_Set_Fetch(&CZ80, 0xFFFF0000, 0xffffffff, (u32)subcpu_memspace);
//Cz80_Set_Fetch(&CZ80, 0x2000, 0x3FFF, (u32)subcpu_memspace);
Cz80_Set_ReadB(&CZ80, NULL);
Cz80_Set_WriteB(&CZ80, NULL);
Cz80_Set_INPort(&CZ80, PortRead);
Cz80_Set_OUTPort(&CZ80, PortWrite);
// Cz80_Set_IRQ_Callback(&CZ80, neogeo_sound_irq);
Cz80_Reset(&CZ80);
Cz80_Exec(&CZ80, 100000);
printf("end !\n");
}
s32 Z80_Reset(void)
{
printf("Z80 cpu reset\n");
return Cz80_Reset(&CZ80);
}
s32 Z80_Exec(s32 cycles)
{
printf("Z80 cpu exec\n");
return Cz80_Exec(&CZ80, cycles);
}
void Z80_EndExec(void)
{
Cz80_Release_Cycle(&CZ80);
}
void Z80_SetIRQ(u32 vector)
{
printf("Z80 cpu set irq\n");
Cz80_Set_IRQ(&CZ80, vector);
}
void Z80_ClearIRQ(u32 vector)
{
printf("Z80 cpu clear irq\n");
Cz80_Clear_IRQ(&CZ80);
}
void Z80_SetNMI(void)
{
printf("Z80 cpu set nmi\n");
Cz80_Set_NMI(&CZ80);
}
void Z80_ClearNMI(void)
{
printf("Z80 cpu clear nmi\n");
Cz80_Clear_NMI(&CZ80);
}
I got it working in Genesis Plus (my DC still doesn't work right, so that took a while), but only if I hack CZ80 directly into the emulator. If I use the switching thingy, I just can't get anything to work. Crashes on the PC version, plain old doesn't work on the DC...
Otherwise, it seems to work pretty well.
The reason it won't help the sound is simple - the sound output is largely independent of the speed of the emulator. However, the current sound output expects the emulator to be running at exactly 60FPS, which it doesn't. The third preview version ran at probably 55 FPS on most games, because it dropped the odd frame here and there. With either FAME or CZ80, it tends to run at full speed, but that's still not 60FPS. It's actually something like 59.5FPS, which is enough difference to screw the sound output up. Just not as much. It's also horribly out of synch with everything else.
Don't these 2 lines have to set up a function pointer - setting them to null would probably cause the DC to reboot - I think.Code:Cz80_Set_ReadB(&CZ80, NULL);
Cz80_Set_WriteB(&CZ80, NULL);
[quote author=warmtoe link=board=dcemu;num=1106437151;start=15#17 date=01/25/05 at 14:22:23]Don't these 2 lines have to set up a function pointer - setting them to null would probably cause the DC to reboot - I think.[/quote]Code:Â* Â* Cz80_Set_ReadB(&CZ80, NULL);
Â* Â*Cz80_Set_WriteB(&CZ80, NULL);
You're right.
Atually you can't do that because i don't test if pointer is null before calling readmem or writemem (waste of time).
If you don't have any specials stuff to do on read or/and write, just don't call SetReadxxx & SetWritexxx functions. By default CZ80 uses dummies functions.
Soem functions need to be renamed in Genesis Plus : Z80 memories and irq functions.Quote:
I got it working in Genesis Plus (my DC still doesn't work right, so that took a while), but only if I hack CZ80 directly into the emulator. If I use the switching thingy, I just can't get anything to work. Crashes on the PC version, plain old doesn't work on the DC...
for instance i replaced readmem16 and writemem16 by readmem8 and writemem8 since they actually work on a byte, and that can be confusing since CZ80 can directly read or write word if definition is enabled in cz80.h
Also (at least on PC version), don't forget that CZ80 needs FASTCALL convention for IO functions.
Sakuragi>
Ca va accélérer l'émulateur légèrement et donc indirectement faire en sorte que le son fonctionne mieux, mais sans implémenter un auto frame skip correct, le son ne pourra jamais être parfait, même Ã* pleine vitesse...
Removing the Set Read and Write stopped it from crashing, now though I have a problem that the port calls arent happening correctly =\. I think it is a combination of me not setting up the z80 memory with the proper addressing (the original doesnt really specify in the same terms =\)
I think my problem is that I'm not translating the addresses correctly. In the interface, are the default addresses for the read/write handlers equivilant or are the pure examples? if they are examples, how would I set it properly?
I notice that for the port read/write the address is in u32 instead of u16 like for cmz80. Does this make a major difference?