mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-27 05:22:07 +00:00
Cleanup code of rbglink
Follow Linux kernel coding style. Signed-off-by: Antonio Niño Díaz <antonio_nd@outlook.com>
This commit is contained in:
@@ -5,39 +5,35 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "extern/err.h"
|
||||
|
||||
#include "link/main.h"
|
||||
#include "link/mylink.h"
|
||||
#include "link/assign.h"
|
||||
|
||||
FILE *mf = NULL;
|
||||
FILE *sf = NULL;
|
||||
int32_t currentbank = 0;
|
||||
int32_t sfbank;
|
||||
static int32_t currentbank;
|
||||
static int32_t sfbank;
|
||||
static FILE *mf;
|
||||
static FILE *sf;
|
||||
|
||||
void
|
||||
SetMapfileName(char *name)
|
||||
void SetMapfileName(char *name)
|
||||
{
|
||||
mf = fopen(name, "w");
|
||||
|
||||
if (mf == NULL) {
|
||||
if (mf == NULL)
|
||||
err(1, "Cannot open mapfile '%s'", name);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SetSymfileName(char *name)
|
||||
void SetSymfileName(char *name)
|
||||
{
|
||||
sf = fopen(name, "w");
|
||||
|
||||
if (sf == NULL) {
|
||||
if (sf == NULL)
|
||||
err(1, "Cannot open symfile '%s'", name);
|
||||
}
|
||||
|
||||
fprintf(sf, ";File generated by rgblink\n\n");
|
||||
fprintf(sf, "; File generated by rgblink\n\n");
|
||||
}
|
||||
|
||||
void
|
||||
CloseMapfile(void)
|
||||
void CloseMapfile(void)
|
||||
{
|
||||
if (mf) {
|
||||
fclose(mf);
|
||||
@@ -49,8 +45,7 @@ CloseMapfile(void)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
MapfileInitBank(int32_t bank)
|
||||
void MapfileInitBank(int32_t bank)
|
||||
{
|
||||
if (mf) {
|
||||
currentbank = bank;
|
||||
@@ -91,8 +86,7 @@ MapfileInitBank(int32_t bank)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
MapfileWriteSection(struct sSection * pSect)
|
||||
void MapfileWriteSection(const struct sSection *pSect)
|
||||
{
|
||||
int32_t i;
|
||||
|
||||
@@ -108,26 +102,24 @@ MapfileWriteSection(struct sSection * pSect)
|
||||
}
|
||||
|
||||
for (i = 0; i < pSect->nNumberOfSymbols; i += 1) {
|
||||
struct sSymbol *pSym;
|
||||
pSym = pSect->tSymbols[i];
|
||||
if ((pSym->pSection == pSect)
|
||||
&& (pSym->Type != SYM_IMPORT)) {
|
||||
const struct sSymbol *pSym = pSect->tSymbols[i];
|
||||
|
||||
if ((pSym->pSection == pSect) && (pSym->Type != SYM_IMPORT)) {
|
||||
if (mf) {
|
||||
fprintf(mf, " $%04X = %s\n",
|
||||
pSym->nOffset + pSect->nOrg,
|
||||
pSym->pzName);
|
||||
pSym->nOffset + pSect->nOrg,
|
||||
pSym->pzName);
|
||||
}
|
||||
if (sf) {
|
||||
fprintf(sf, "%02X:%04X %s\n", sfbank,
|
||||
pSym->nOffset + pSect->nOrg,
|
||||
pSym->pzName);
|
||||
pSym->nOffset + pSect->nOrg,
|
||||
pSym->pzName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
MapfileCloseBank(int32_t slack)
|
||||
void MapfileCloseBank(int32_t slack)
|
||||
{
|
||||
if (!mf)
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user