Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/mcume #38

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft

Feature/mcume #38

wants to merge 8 commits into from

Conversation

finger563
Copy link
Contributor

Description

Motivation and Context

How has this been tested?

Screenshots (if appropriate, e.g. schematic, board, console logs, lab pictures):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update
  • Hardware (schematic, board, system design) change
  • Software change

Checklist:

  • My change requires a change to the documentation.
  • I have added / updated the documentation related to this change via either README or WIKI

Software

  • I have added tests to cover my changes.
  • I have updated the .github/workflows/build.yml file to add my new test to the automated cloud build github action.
  • All new and existing tests passed.
  • My code follows the code style of this project.

Hardware

  • I have updated the design files (schematic, board, libraries).
  • I have attached the PDFs of the SCH / BRD to this PR
  • I have updated the design output (GERBER, BOM) files.

@finger563 finger563 marked this pull request as draft November 26, 2023 23:07
Copy link

github-actions bot commented Dec 28, 2023

⚡ Static analysis result ⚡

🔴 cppcheck found 35 issues! Click here to see details.

class AudioPlaySystem
{
public:
AudioPlaySystem(void) { begin(); }
void begin(void);
void setSampleParameters(float clockfreq, float samplerate);

!Line: 7 - error: Code 'classAudioPlaySystem{' is invalid C code. Use --std or --language to configure the language. [syntaxError]

printf("failled to allocate %d\n",size);
}
else {
printf("could allocate %d\n",size);
}

!Line: 38 - warning: %d in format string (no. 1) requires 'int' but the argument type is 'unsigned int'. [invalidPrintfArgType_sint]

printf("could allocate %d\n",size);
}
return retval;
}

!Line: 41 - warning: %d in format string (no. 1) requires 'int' but the argument type is 'unsigned int'. [invalidPrintfArgType_sint]

void emu_printf(char * text)
{
printf("%s\n",text);
}

!Line: 23 - style: Parameter 'text' can be declared as pointer to const [constParameterPointer]

long s;
//len = len >> 1;
short v0=chan[0].vol;
short v1=chan[1].vol;
short v2=chan[2].vol;

!Line: 107 - style: The scope of the variable 's' can be reduced. [variableScope]

cpu_readmap[4] = ((sms.fcr[3] % cart.pages) << 14) + 0x0000;
cpu_readmap[5] = ((sms.fcr[3] % cart.pages) << 14) + 0x2000;
cpu_writemap[4] = sms.dummy;
cpu_writemap[5] = sms.dummy;
}
break;

!Line: 287 - portability: Assigning an integer to a pointer is not portable. [AssignmentIntegerToAddress]

cpu_readmap[5] = ((sms.fcr[3] % cart.pages) << 14) + 0x2000;
cpu_writemap[4] = sms.dummy;
cpu_writemap[5] = sms.dummy;
}
break;

!Line: 288 - portability: Assigning an integer to a pointer is not portable. [AssignmentIntegerToAddress]

cpu_readmap[0] = (page << 14) + 0x0000;
cpu_readmap[1] = (page << 14) + 0x2000;
break;
case 2:
cpu_readmap[2] = (page << 14) + 0x0000;

!Line: 295 - portability: Assigning an integer to a pointer is not portable. [AssignmentIntegerToAddress]

cpu_readmap[1] = (page << 14) + 0x2000;
break;
case 2:
cpu_readmap[2] = (page << 14) + 0x0000;
cpu_readmap[3] = (page << 14) + 0x2000;

!Line: 296 - portability: Assigning an integer to a pointer is not portable. [AssignmentIntegerToAddress]

cpu_readmap[2] = (page << 14) + 0x0000;
cpu_readmap[3] = (page << 14) + 0x2000;
break;
case 3:
if(!(sms.fcr[0] & 0x08))

!Line: 300 - portability: Assigning an integer to a pointer is not portable. [AssignmentIntegerToAddress]

cpu_readmap[3] = (page << 14) + 0x2000;
break;
case 3:
if(!(sms.fcr[0] & 0x08))
{

!Line: 301 - portability: Assigning an integer to a pointer is not portable. [AssignmentIntegerToAddress]

cpu_readmap[4] = (page << 14) + 0x0000;
cpu_readmap[5] = (page << 14) + 0x2000;
}
break;
}
}

!Line: 307 - portability: Assigning an integer to a pointer is not portable. [AssignmentIntegerToAddress]

cpu_readmap[5] = (page << 14) + 0x2000;
}
break;
}
}

!Line: 308 - portability: Assigning an integer to a pointer is not portable. [AssignmentIntegerToAddress]

slot1->TLL = slot1->TL + (CH->ksl_base>>slot1->ksl);
/* key on */
CH->op1_out[0] = CH->op1_out[1] = 0;
OPL_KEYON(slot1);
OPL_KEYON(slot2);
}

!Line: 696 - style: Variable 'slot1->TLL' is reassigned a value before the old one has been used. [redundantAssignment]

!Line: 695 - note: slot1->TLL is assigned
!Line: 696 - note: slot1->TLL is overwritten

double rate;
int i,j;
double pom;
/* allocate dynamic tables */
if( (TL_TABLE = emu_Malloc(TL_MAX*2*sizeof(INT32))) == NULL)

!Line: 587 - style: The scope of the variable 'rate' can be reduced. [variableScope]

int i,j;
double pom;
/* allocate dynamic tables */
if( (TL_TABLE = emu_Malloc(TL_MAX*2*sizeof(INT32))) == NULL)
return 0;

!Line: 588 - style: The scope of the variable 'j' can be reduced. [variableScope]

int data;
FMSAMPLE *buf = buffer;
UINT32 amsCnt = OPL->amsCnt;
UINT32 vibCnt = OPL->vibCnt;
UINT8 rythm = OPL->rythm&0x20;
OPL_CH *CH,*R_CH;

!Line: 1016 - style: The scope of the variable 'data' can be reduced. [variableScope]

data = Limit( outd[0] , OPL_MAXOUT, OPL_MINOUT );
/* store to sound buffer */
buf[i] = data >> OPL_OUTSB;
}
OPL->amsCnt = amsCnt;

!Line: 1054 - portability: Shifting a negative value is technically undefined behaviour [shiftNegativeLHS]

static __inline__ void CALC_FCSLOT(OPL_CH *CH,OPL_SLOT *SLOT)
{
int ksr;
/* frequency step counter */
SLOT->Incr = CH->fc * SLOT->mul;

!Line: 340 - style: Parameter 'CH' can be declared as pointer to const [constParameterPointer]

int data;
FMSAMPLE *buf = buffer;
UINT32 amsCnt = OPL->amsCnt;
UINT32 vibCnt = OPL->vibCnt;
UINT8 rythm = OPL->rythm&0x20;
OPL_CH *CH,*R_CH;

!Line: 1069 - style: The scope of the variable 'data' can be reduced. [variableScope]

data = Limit( outd[0] , OPL_MAXOUT, OPL_MINOUT );
/* store to sound buffer */
buf[i] = data >> OPL_OUTSB;
}
OPL->amsCnt = amsCnt;
OPL->vibCnt = vibCnt;

!Line: 1114 - portability: Shifting a negative value is technically undefined behaviour [shiftNegativeLHS]

int yp = st[i];
/* End of sprite list marker? */
if(yp == 208) return;
/* Actual Y position is +1 */

!Line: 333 - warning: The address of local variable 'vram' might be accessed at non-zero index. [objectIndex]

!Line: 320 - note: Address of variable taken here.
!Line: 333 - note: The address of local variable 'vram' might be accessed at non-zero index.

int xp = st[0x80 + (i << 1)];
/* Pattern name */
int n = st[0x81 + (i << 1)];
/* Bump sprite count */

!Line: 354 - warning: The address of local variable 'vram' might be accessed at non-zero index. [objectIndex]

!Line: 320 - note: Address of variable taken here.
!Line: 336 - note: Assuming condition is false
!Line: 354 - note: The address of local variable 'vram' might be accessed at non-zero index.

int n = st[0x81 + (i << 1)];
/* Bump sprite count */
count += 1;
/* Too many sprites on this line ? */

!Line: 357 - warning: The address of local variable 'vram' might be accessed at non-zero index. [objectIndex]

!Line: 320 - note: Address of variable taken here.
!Line: 336 - note: Assuming condition is false
!Line: 357 - note: The address of local variable 'vram' might be accessed at non-zero index.

b0 = vdp.vram[(i << 5) | (y << 2) | (0)];
b1 = vdp.vram[(i << 5) | (y << 2) | (1)];
b2 = vdp.vram[(i << 5) | (y << 2) | (2)];
b3 = vdp.vram[(i << 5) | (y << 2) | (3)];
for(x = 0; x < 8; x += 1)

!Line: 463 - style: Operator '|' with one operand equal to zero is redundant. [badBitmaskCheck]

cache[0x00000 | (i << 6) | ((y ) << 3) | (x )] = c;
cache[0x08000 | (i << 6) | ((y ) << 3) | (7-x)] = c;
cache[0x10000 | (i << 6) | ((7-y) << 3) | (x )] = c;
cache[0x18000 | (i << 6) | ((7-y) << 3) | (7-x)] = c;
}
}

!Line: 477 - style: Operator '|' with one operand equal to zero is redundant. [badBitmaskCheck]

r = ((vdp.cram[(index << 1) | 0] >> 1) & 7) << 5;
g = ((vdp.cram[(index << 1) | 0] >> 5) & 7) << 5;
b = ((vdp.cram[(index << 1) | 1] >> 1) & 7) << 5;
}
else
{

!Line: 494 - style: Operator '|' with one operand equal to zero is redundant. [badBitmaskCheck]

g = ((vdp.cram[(index << 1) | 0] >> 5) & 7) << 5;
b = ((vdp.cram[(index << 1) | 1] >> 1) & 7) << 5;
}
else
{
r = ((vdp.cram[index] >> 0) & 3) << 6;

!Line: 495 - style: Operator '|' with one operand equal to zero is redundant. [badBitmaskCheck]

UINT16 *nt = (UINT16 *)&vdp.vram[vdp.ntab + ((v_line >> 3) << 6)];
int nt_scroll = (hscroll >> 3);
UINT32 atex_mask;
UINT32 *cache_ptr;
UINT32 *linebuf_ptr = (UINT32 *)&linebuf[0 - (hscroll & 7)];

!Line: 277 - style: Variable 'nt' can be declared as pointer to const [constVariablePointer]

byte *st = (byte *)&vdp.vram[vdp.satb];
/* Adjust dimensions for double size sprites */
if(vdp.reg[1] & 0x01)
{
width *= 2;

!Line: 320 - style: Variable 'st' can be declared as pointer to const [constVariablePointer]

byte *cache_ptr = (byte *)&cache[(n << 6) | (((line - yp) >> 1) << 3)];
/* Draw sprite line */
for(x = start; x < end; x += 1)
{
/* Source pixel from cache */

!Line: 393 - style: Variable 'cache_ptr' can be declared as pointer to const [constVariablePointer]

byte *cache_ptr = (byte *)&cache[(n << 6) | ((line - yp) << 3)];
/* Draw sprite line */
for(x = start; x < end; x += 1)
{
/* Source pixel from cache */

!Line: 418 - style: Variable 'cache_ptr' can be declared as pointer to const [constVariablePointer]

t_ym2413 *opll = &ym2413[chip];
/* Load instrument settings for channel seven. (Bass drum) */
OPL_WRITE(chip, 0x30, 0x13);
OPL_WRITE(chip, 0x33, 0x11);
OPL_WRITE(chip, 0x50, 0x25);

!Line: 312 - style: Variable 'opll' can be declared as pointer to const [constVariablePointer]

unsigned char *param = (inst == 0) ? &opll->user[0] : &table[inst][0];
/* Maps channels to operator registers */
unsigned char ch2op[] = {0, 1, 2, 8, 9, 10, 16, 17, 18};
/* Make operator offset from requested channel */

!Line: 371 - style: Variable 'param' can be declared as pointer to const [constVariablePointer]

unsigned char ch2op[] = {0, 1, 2, 8, 9, 10, 16, 17, 18};
/* Make operator offset from requested channel */
int op = ch2op[ch];
/* Store volume level */

!Line: 374 - style: Variable 'ch2op' can be declared as const array [constVariable]


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant