SMS: early Nuked-PSG modding

This commit is contained in:
tildearrow 2022-05-26 19:00:14 -05:00
parent e3ebe0cb92
commit 0577aa3569
3 changed files with 9 additions and 5 deletions

View File

@ -125,10 +125,10 @@ static void YMPSG_ClockInternal1(ympsg_t *chip)
}
else if (noise_of && !chip->noise_of)
{
noise_bit1 = (chip->noise >> 15) & 1;
noise_bit1 = (chip->noise >> chip->noise_tap2) & 1;
noise_bit2 = (chip->noise >> 12) & 1;
noise_bit1 ^= noise_bit2;
noise_next = ((noise_bit1 && ((chip->noise_data >> 2) & 1)) || ((chip->noise & 32767) == 0));
noise_next = ((noise_bit1 && ((chip->noise_data >> 2) & 1)) || ((chip->noise & chip->noise_size) == 0));
chip->noise <<= 1;
chip->noise |= noise_next;
}
@ -253,11 +253,13 @@ uint16_t YMPSG_Read(ympsg_t *chip)
return data;
}
void YMPSG_Init(ympsg_t *chip)
void YMPSG_Init(ympsg_t *chip, uint8_t real_sn)
{
uint32_t i;
memset(chip, 0, sizeof(ympsg_t));
YMPSG_SetIC(chip, 1);
chip->noise_tap2 = real_sn ? 13 : 15;
chip->noise_size = real_sn ? 16383 : 32767;
for (i = 0; i < 16; i++)
{
YMPSG_Clock(chip);

View File

@ -46,6 +46,8 @@ typedef struct {
uint8_t sign_l;
uint8_t noise_sign_l;
uint16_t noise;
uint8_t noise_tap2;
uint16_t noise_size;
uint8_t test;
uint8_t volume_out[4];
@ -62,7 +64,7 @@ typedef struct {
void YMPSG_Write(ympsg_t *chip, uint8_t data);
uint16_t YMPSG_Read(ympsg_t *chip);
void YMPSG_Init(ympsg_t *chip);
void YMPSG_Init(ympsg_t *chip, uint8_t real_sn);
void YMPSG_SetIC(ympsg_t *chip, uint32_t ic);
void YMPSG_Clock(ympsg_t *chip);
float YMPSG_GetOutput(ympsg_t *chip);

View File

@ -358,7 +358,7 @@ void DivPlatformSMS::reset() {
addWrite(0xffffffff,0);
}
sn->device_start();
YMPSG_Init(&sn_nuked);
YMPSG_Init(&sn_nuked,isRealSN);
snNoiseMode=3;
rWrite(0xe7);
updateSNMode=false;