Skip to content

Commit

Permalink
Cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
inactive123 committed Nov 2, 2021
1 parent 1a663a1 commit c039e83
Show file tree
Hide file tree
Showing 7 changed files with 633 additions and 644 deletions.
26 changes: 13 additions & 13 deletions allegrowrapper/wrapalleg.c
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@

#include "wrapalleg.h"

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void alleg_downcase(char *p)
{
while(*p != '\0')
{
if(*p >= 97-32 && *p <= 122-32)
*p += 32;
++p;
}
while(*p != '\0')
{
if(*p >= 97-32 && *p <= 122-32)
*p += 32;
++p;
}
}

ALLEGRO_BITMAP *create_bitmap(int w,int h)
{
ALLEGRO_BITMAP *buff = malloc(sizeof (ALLEGRO_BITMAP));
ALLEGRO_BITMAP *buff = (ALLEGRO_BITMAP*)
malloc(sizeof (ALLEGRO_BITMAP));

if (!buff)
return NULL;

buff->line = malloc(1*w*h);

buff->w = w;
buff->h = h;
buff->pitch = w;
buff->depth = 1;
buff->w = w;
buff->h = h;
buff->pitch = w;
buff->depth = 1;

return buff;
}
Expand All @@ -38,7 +38,7 @@ int destroy_bitmap(ALLEGRO_BITMAP *buff)
{
if (buff->line)
free(buff->line);

buff->line = NULL;
free(buff);
}

Expand Down
1 change: 0 additions & 1 deletion libretro.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#include <stdbool.h>
#endif
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
Expand Down
3 changes: 1 addition & 2 deletions src/crc32.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,8 @@ unsigned long crc32_buf(const void *buf, long len){

unsigned long crc32_file(const char *filename){
unsigned /*long*/ crc = crc ^ 0xffffffffUL;//crc = ~0;
FILE *f;
int c;
f = fopen(filename,"rb");
FILE *f = fopen(filename,"rb");
if (f){
while ((c=fgetc(f)) != EOF) crc = (crc >> 8) ^ crc32tab[(crc ^ c) & 0xff];
fclose(f);
Expand Down
53 changes: 8 additions & 45 deletions src/dis48.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@


#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "types.h"
Expand All @@ -14,53 +13,17 @@
#define BIOSLEN 1024
#define MAXLEN 8192


Byte rom[MAXLEN+BIOSLEN];
ADDRESS pc;

int parse_option(char *attr, char *val);

static int disasm(ADDRESS p) {
Byte op,d;
ADDRESS adr;

op=rom[p++];
printf("%04x %02x",p-1,op);
if (lookup[op].bytes == 2) printf(" %02x",rom[p]); else printf(" ");
printf(" %s",lookup[op].mnemonic);
switch(lookup[op].type) {
case 0:
printf("\n");
break;
case 1:
d=rom[p];
printf(" #%02x\n",d);
break;
case 2:
adr=rom[p];
adr = adr | ((op & 0xE0) << 3);
printf(" $%03x\n",adr);
break;
case 3:
printf(" $%02x\n",rom[p]);
break;
}
if (op == 0x83 || op == 0x93 || (((p-2+lookup[op].bytes) & 0xff) == 0xff)) printf("\n"); // Linebreak after ret, retr and end of page
return lookup[op].bytes;
}

int parse_option(char *attr, char *val){

if (!strcmp(attr,"bios"))
{
pc = 0;
}
else
{
fprintf(stderr,"Invalid option : %s\n",attr);
return 0;
}
return 1;
int parse_option(char *attr, char *val)
{
if (!strcmp(attr,"bios"))
{
pc = 0;
return 1;
}
return 0;
}


Expand Down
1 change: 0 additions & 1 deletion src/keyboard.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/


#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
Expand Down
66 changes: 21 additions & 45 deletions src/score.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,16 @@ int get_score(int scoretype, int scoreaddress)

if (scoretype!=0)
{
int position;
int i;
uint8_t *RAM;

int count = scoretype%10;
int direction = ((scoretype/10)%10)==1?1:-1;
int count = scoretype%10;
int direction = ((scoretype/10)%10)==1?1:-1;
float valuetype = (float) (3-((scoretype/100)%10))/2;
int ramtype = scoretype/1000;

position = scoreaddress+ (direction==1?0:(count*valuetype-1));
RAM = ramtype==1?extRAM:intRAM;
int ramtype = scoretype/1000;
int position = scoreaddress+ (direction==1?0:(count*valuetype-1));
uint8_t *RAM = ramtype==1?extRAM:intRAM;

for(i=0;i<count;i++)
{
score = score*10+((RAM[position+(int)(valuetype*i*direction)]>>(((i+1)%2)*4)*(abs((int) ((valuetype-1)*2))))&15);
}
}

return(score);
Expand All @@ -68,7 +62,6 @@ int get_score(int scoretype, int scoreaddress)

void set_score(int scoretype, int scoreaddress, int score)
{

if (scoretype!=0 && score>0)
{
int i;
Expand All @@ -95,23 +88,15 @@ void set_score(int scoretype, int scoreaddress, int score)
-------------------------------------------------------*/
void save_highscore(int highscore, char *scorefile)
{
FILE *fn;
FILE *fn;

highscore = highscore==app_data.default_highscore?0:highscore;
highscore = highscore==app_data.default_highscore?0:highscore;

fn = fopen(scorefile,"w");
if (fn==NULL) {
fprintf(stderr,"Error opening highscore-file %s: %i\n",scorefile,errno);
exit(EXIT_FAILURE);
}

if (fprintf(fn,"%i",highscore)<=0)
{
fprintf(stderr,"Error writing to highscore-file %s: %i\n",scorefile,errno);
exit(EXIT_FAILURE);
}
if (!(fn = fopen(scorefile,"w")))
return;

fclose(fn);
fprintf(fn,"%i",highscore);
fclose(fn);
}
#endif

Expand All @@ -120,23 +105,14 @@ void save_highscore(int highscore, char *scorefile)
***********************************/
int power(int base, int higher)
{
if (higher==0)
{
return(1);
}
else if (higher==1)
{
return(base);
}
else
{
int i;
int value=base;

for (i=2;i<=higher;i++)
{
value = value*base;
}
return(value);
}
int i;
int value=base;
if (higher==0)
return(1);
else if (higher==1)
return(base);

for (i=2;i<=higher;i++)
value = value*base;
return(value);
}

0 comments on commit c039e83

Please sign in to comment.