Skip to content

Commit

Permalink
Edits so that make works; also some style changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Rangi42 committed Dec 8, 2023
1 parent 6a45681 commit 3e32bf4
Show file tree
Hide file tree
Showing 11 changed files with 118 additions and 1,613 deletions.
7 changes: 4 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,14 @@ rgbasm_obj := \
src/asm/rpn.o \
src/asm/section.o \
src/asm/symbol.o \
src/asm/util.o \
src/asm/warning.o \
src/extern/getopt.o \
src/extern/utf8decoder.o \
src/error.o \
src/hashmap.o \
src/linkdefs.o \
src/opmath.o
src/opmath.o \
src/util.o

src/asm/lexer.o src/asm/main.o: src/asm/parser.hpp

Expand Down Expand Up @@ -134,9 +134,9 @@ test/gfx/rgbgfx_test: test/gfx/rgbgfx_test.cpp
.y.o:

# Bison-generated C++ files have an accompanying header
# (The linkerscript parser contains its own lexer, though)
src/asm/parser.hpp: src/asm/parser.cpp
$Qtouch $@
# The linkerscript parser contains its own lexer, though.

.y.cpp:
$Q${BISON} $@ $<
Expand Down Expand Up @@ -173,6 +173,7 @@ clean:
$Qfind . -type f \( -name "*.gcno" -o -name "*.gcda" -o -name "*.gcov" \) -exec rm {} \;
$Q${RM} rgbshim.sh
$Q${RM} src/asm/parser.cpp src/asm/parser.hpp
$Q${RM} src/link/script.cpp src/link/script.hpp src/link/stack.hh
$Q${RM} test/gfx/randtilegen test/gfx/rgbgfx_test

# Target used to install the binaries and man pages.
Expand Down
1 change: 1 addition & 0 deletions include/util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#ifndef RGBDS_UTIL_H
#define RGBDS_UTIL_H

#include <stddef.h>
#include <stdint.h>

char const *printChar(int c);
Expand Down
6 changes: 3 additions & 3 deletions src/asm/section.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ static void mergeSections(struct Section *sect, enum SectionType type, uint32_t
unsigned int nbSectErrors = 0;

if (type != sect->type)
fail("Section already exists but with type %s\n", sectionTypeInfo[sect->type].name);
fail("Section already exists but with type %s\n", sectionTypeInfo[sect->type].name.c_str());

if (sect->modifier != mod) {
fail("Section already declared as %s section\n", sectionModNames[sect->modifier]);
Expand Down Expand Up @@ -314,7 +314,7 @@ static struct Section *getSection(char const *name, enum SectionType type, uint3
error("BANK only allowed for ROMX, WRAMX, SRAM, or VRAM sections\n");
else if (bank < sectionTypeInfo[type].firstBank || bank > sectionTypeInfo[type].lastBank)
error("%s bank value $%04" PRIx32 " out of range ($%04" PRIx32 " to $%04"
PRIx32 ")\n", sectionTypeInfo[type].name, bank,
PRIx32 ")\n", sectionTypeInfo[type].name.c_str(), bank,
sectionTypeInfo[type].firstBank, sectionTypeInfo[type].lastBank);
} else if (nbbanks(type) == 1) {
// If the section type only has a single bank, implicitly force it
Expand Down Expand Up @@ -349,7 +349,7 @@ static struct Section *getSection(char const *name, enum SectionType type, uint3
alignment = 0; // Ignore it if it's satisfied
} else if (sectionTypeInfo[type].startAddr & mask) {
error("Section \"%s\"'s alignment cannot be attained in %s\n",
name, sectionTypeInfo[type].name);
name, sectionTypeInfo[type].name.c_str());
alignment = 0; // Ignore it if it's unattainable
org = 0;
} else if (alignment == 16) {
Expand Down
3 changes: 3 additions & 0 deletions src/link/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/script.cpp
/script.hpp
/stack.hh
6 changes: 3 additions & 3 deletions src/link/assign.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,16 +298,16 @@ static void placeSection(struct Section *section)
// If a section failed to go to several places, nothing we can report
if (!section->isBankFixed || !section->isAddressFixed)
errx("Unable to place \"%s\" (%s section) %s",
section->name, sectionTypeInfo[section->type].name, where);
section->name, sectionTypeInfo[section->type].name.c_str(), where);
// If the section just can't fit the bank, report that
else if (section->org + section->size > endaddr(section->type) + 1)
errx("Unable to place \"%s\" (%s section) %s: section runs past end of region ($%04x > $%04x)",
section->name, sectionTypeInfo[section->type].name, where,
section->name, sectionTypeInfo[section->type].name.c_str(), where,
section->org + section->size, endaddr(section->type) + 1);
// Otherwise there is overlap with another section
else
errx("Unable to place \"%s\" (%s section) %s: section overlaps with \"%s\"",
section->name, sectionTypeInfo[section->type].name, where,
section->name, sectionTypeInfo[section->type].name.c_str(), where,
out_OverlappingSection(section)->name);
}

Expand Down
4 changes: 3 additions & 1 deletion src/link/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include "version.hpp"

bool isDmgMode; // -d
char *linkerScriptName; // -l
char *linkerScriptName; // -l
char const *mapFileName; // -m
bool noSymInMap; // -M
char const *symFileName; // -n
Expand All @@ -45,6 +45,8 @@ bool beVerbose; // -v
bool isWRA0Mode; // -w
bool disablePadding; // -x

FILE *linkerScript;

static uint32_t nbErrors = 0;

// Helper function to dump a file stack to stderr
Expand Down
4 changes: 2 additions & 2 deletions src/link/output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ static void writeEmptySpace(uint16_t begin, uint16_t end)
static void writeMapBank(struct SortedSections const *sectList, enum SectionType type,
uint32_t bank)
{
fprintf(mapFile, "\n%s bank #%" PRIu32 ":\n", sectionTypeInfo[type].name,
fprintf(mapFile, "\n%s bank #%" PRIu32 ":\n", sectionTypeInfo[type].name.c_str(),
bank + sectionTypeInfo[type].firstBank);

uint16_t used = 0;
Expand Down Expand Up @@ -540,7 +540,7 @@ static void writeMapSummary(void)
}

fprintf(mapFile, "\t%s: %" PRId32 " byte%s used / %" PRId32 " free",
sectionTypeInfo[type].name, usedTotal, usedTotal == 1 ? "" : "s",
sectionTypeInfo[type].name.c_str(), usedTotal, usedTotal == 1 ? "" : "s",
nbBanks * sectionTypeInfo[type].size - usedTotal);
if (sectionTypeInfo[type].firstBank != sectionTypeInfo[type].lastBank
|| nbBanks > 1)
Expand Down
Loading

0 comments on commit 3e32bf4

Please sign in to comment.