Compare commits

...
Sign in to create a new pull request.

14 commits

Author SHA1 Message Date
07fe60536a rickjr: makefile changes "make overlay" command has been added and works, but this is definitely messy right now 2024-02-05 19:02:29 -05:00
5d67b21baa changes for overlay helper to compile in WSL 2024-02-05 19:01:18 -05:00
b9d6fb26fd import: makefile for the overlay helper, now officially renamed "oh" 2024-02-05 19:00:49 -05:00
5296a2e9d6 import asm library, written in merlin32 2024-02-04 07:14:14 -05:00
e0056e1f59 import: overlay helper tool, for generating linker script symbols 2024-02-03 14:07:46 -05:00
0279da40c1 rickjr: import credit screen data, update the mapper function to use the f256lib to map in high memory 2024-01-28 11:57:03 -05:00
630f52167f ignore annoying files 2024-01-28 11:55:01 -05:00
9a706ecc52 rickjr: import the blockgen tool, so I can generate blocks.h headerfile 2024-01-27 12:36:34 -05:00
d4eb96bdb8 PGZ link fix-ups, an actual binary file is linked in now. 2024-01-25 08:57:39 -05:00
ee40696470 mapper: rename the mapper macros, and only include overlay sections that we are actually using right now 2024-01-21 14:47:18 -05:00
4e26ce7a55 rickhr.ld -> add the launch address into the PGZ output 2024-01-21 14:34:45 -05:00
88a44ca1f0 rickjr.ld -> export .pgZ natively (WIP) 2024-01-21 14:15:41 -05:00
56648300fc bank mapping that works for code 2024-01-21 10:17:48 -05:00
73e899f9a4 add mapper.h, and move some data out into physical memory 2024-01-21 09:20:03 -05:00
31 changed files with 1868 additions and 32 deletions

11
.gitignore vendored
View file

@ -2,3 +2,14 @@
*.vpw
*.vpwhistxml
*.vtg
dep/
lst/
obj/
bin/blockgen/.vs/
*.user
bin/blockgen/vcxproj/.vs/
bin/blockgen/vcxproj/x64/
*.pdb
bin/overlayhelper/.vs/
bin/overlayhelper/vcxproj/.vs/
bin/overlayhelper/vcxproj/x64/

View file

@ -29,7 +29,8 @@ F256 = $(HOME)/code/f256
#SYSLIBDIR = $(SYSTEM)/lib
#SYSINCDIR = $(SYSTEM)/include
TMPFLAGS = -D F256=1 -Wno-unknown-pragmas
#TMPFLAGS = -D F256=1 -include src/mapper.h -include blocks.h -Wno-unknown-pragmas
TMPFLAGS = -D F256=1 -include src/mapper.h -Wno-unknown-pragmas
INCCMD = -I$(SYSINCDIR)
@ -40,7 +41,6 @@ INCCMD += -I$(F256)/f256lib
OBJDIR = $(PROJROOT)/obj
DEPDIR = $(PROJROOT)/dep
LSTDIR = $(PROJROOT)/lst
#
# Special GnuMake Search Path Directive
@ -95,7 +95,13 @@ OBJS += syssnd.o
OBJS += system.o
OBJS += sysvid.o
OBJS += util.o
OBJS += f256.o
#OBJS += f256.o
OBJS += dat_spritesJR.o
LIBS := $(OBJDIR)/f256.o
# Data Objects
#OBJS += splash.o
# change list of .o's into a list of .d's
@ -105,12 +111,14 @@ DEPS := $(OBJS:%.o=%.d)
AS = merlin32
CC = mos-f256k-clang
LD = mos-f256k-clang
OBJCOPY = llvm-objcopy
RM = /bin/rm -rfv
CFLAGS = -Os -Wall -Werror -Wa,-al -fno-common
CXXFLAGS = -Os -Wall -Werror -Wa,-al -fno-common
#ASFLAGS = -c -xassembler-with-cpp -Wa,-al
#LDFLAGS = -Wl,-Map,$(TARGET).map $(LIBCMD)
LDFLAGS = -Trickjr.ld --verbose
# Clear Default Suffixes
.SUFFIXES:
@ -119,20 +127,23 @@ CXXFLAGS = -Os -Wall -Werror -Wa,-al -fno-common
all: $(TARGET)
$(TARGET): $(DEPS) $(OBJS) $(LIBS)
${CC} $(CFLAGS) $(TMPFLAGS) $(INCCMD) -c ${F256}/f256lib/f256.c -o $(OBJDIR)/f256.o > $(LSTDIR)/$*.lst
#$(TARGET): $(DEPS) $(OBJS) $(LIBS)
$(TARGET): $(DEPS) $(OBJS) overlay
${CC} $(CFLAGS) $(TMPFLAGS) $(INCCMD) -c ${F256}/f256lib/f256.c -o $(OBJDIR)/f256.o
$(LD) -o $@ $(addprefix $(OBJDIR)/,$(OBJS)) $(LIBS) $(LDFLAGS)
llvm-objdump --syms -d --print-imm-hex $(TARGET).elf > $(TARGET).lst
# Object Rules
.s.o:
$(AS) $(ASFLAGS) $(TMPFLAGS) $(INCCMD) -o $(OBJDIR)/$@ $< > $(LSTDIR)/$*.lst
$(AS) $(ASFLAGS) $(TMPFLAGS) $(INCCMD) -o $(OBJDIR)/$@ $<
.c.o:
$(CC) $(CFLAGS) $(TMPFLAGS) $(INCCMD) -c $< -o $(OBJDIR)/$*.o > $(LSTDIR)/$*.lst
$(CC) $(CFLAGS) $(TMPFLAGS) $(INCCMD) -c $< -o $(OBJDIR)/$*.o
.cc.o:
$(CC) $(CXXFLAGS) $(TMPFLAGS) $(INCCMD) -c $< -o $(OBJDIR)/$*.o > $(LSTDIR)/$*.lst
$(CC) $(CXXFLAGS) $(TMPFLAGS) $(INCCMD) -c $< -o $(OBJDIR)/$*.o
# Dependencie Rules
#
@ -157,7 +168,20 @@ $(TARGET): $(DEPS) $(OBJS) $(LIBS)
.PHONY: clean
clean:
$(RM) $(OBJDIR) *.o $(DEPDIR) *.map $(LSTDIR) $(TARGET) $(TARGET).elf $(TARGET).pgz
$(RM) $(OBJDIR) *.o $(DEPDIR) *.map $(TARGET) $(TARGET).elf $(TARGET).pgz $(TARGET).lst
# needed for the overlay input
HELPER = $(HOME)/code/rickjr/bin/oh
CFILES = $(patsubst %.o,src/%.c,$(OBJS))
.PHONY: overlay
overlay_reset:
@echo '/* Overlay Helper Generated Linker Script */' > overlay.ld
overlay: overlay_reset $(CFILES)
$(foreach cfile,$(CFILES),$(shell $(HELPER) $(cfile) >> $(HOME)/code/rickjr/overlay.ld))
########################################
@ -176,7 +200,7 @@ $(DEPS) : Makefile
# Targets that create the output object directory if it doesn't already exist
#
Makefile : $(OBJDIR) $(DEPDIR) $(LSTDIR)
Makefile : $(OBJDIR) $(DEPDIR)
$(OBJDIR) :
$(MKDIR) $(OBJDIR)
@ -188,16 +212,8 @@ $(OBJDIR) :
$(DEPDIR) :
$(MKDIR) $(DEPDIR)
#
# Targets that create the output list directory if it doesn't already exist
#
$(LSTDIR) :
$(MKDIR) $(LSTDIR)
#
# Generated Dependencie Files
#
-include $(wildcard $(DEPDIR)/*.d)

BIN
bin/blockgen.exe Normal file

Binary file not shown.

View file

@ -0,0 +1,48 @@
/*
bctypes.h
Because I need Standard Types
*/
#ifndef _bctypes_h
#define _bctypes_h
typedef signed char i8;
typedef unsigned char u8;
typedef signed short i16;
typedef unsigned short u16;
typedef signed long i32;
typedef unsigned long u32;
typedef signed long long i64;
typedef unsigned long long u64;
// If we're using C, I still like having a bool around
#ifndef __cplusplus
typedef i32 bool;
#define false (0)
#define true (!false)
#define nullptr 0
#endif
typedef float f32;
typedef float r32;
typedef double f64;
typedef double r64;
#define null (0)
// Odd Types
typedef union {
// u128 ul128;
u64 ul64[2];
u32 ui32[4];
} QWdata;
#endif // _bctypes_h
// EOF - bctypes.h

View file

@ -0,0 +1,68 @@
// omf2hex.cpp : This file contains the 'main' function. Program execution begins and ends there.
//
#include <stdio.h>
#include <stdlib.h>
#include "symfile.h"
//------------------------------------------------------------------------------
void helpText()
{
printf("blockgen - v1.0\n");
printf("--------------\n");
printf("Convert mos-llvm elf file symboles into a C header file\n");
printf("\nblock [options] <file.elf>\n");
printf(" -v verbose\n\n");
exit(-1);
}
//------------------------------------------------------------------------------
int main(int argc, char* argv[])
{
char* pInfilePath = nullptr;
bool bVerbose = false;
for (int idx = 1; idx < argc; ++idx )
{
char* arg = argv[ idx ];
if ('-' == arg[0])
{
// Parse as an option
if ('v'==arg[1])
{
bVerbose = true;
}
}
else if (nullptr == pInfilePath)
{
// Assume the first non-option is an input file path
pInfilePath = argv[ idx ];
}
else
{
// Oh Crap, we have a non-option, but we don't know what to do with
// it
printf("ERROR: Invalid option, Arg %d = %s\n\n", idx, argv[ idx ]);
helpText();
}
}
if (pInfilePath)
{
// Load the .sym File
SYMFile *pSymFile = new SYMFile(std::string(pInfilePath));
delete pSymFile;
}
else
{
helpText();
}
return 0;
}

View file

@ -0,0 +1,164 @@
//
// Jason's Memory Stream Helper thing
// Serialize a byte stream into real types
//
// Currently only support Little Endian
//
#ifndef MEMSTREAM_H_
#define MEMSTREAM_H_
#include <string>
// Prototypes
void *memcpy(void *dest, const void *src, size_t n);
class MemoryStream
{
public:
MemoryStream(unsigned char* pStreamStart, size_t streamSize)
: m_pStreamStart( pStreamStart )
, m_streamSize(streamSize)
, m_pStreamCurrent( pStreamStart )
{}
~MemoryStream()
{
m_pStreamStart = nullptr;
m_streamSize = 0;
m_pStreamCurrent = nullptr;
}
// Really Dumb Reader Template
template <class T>
T Read()
{
T result;
memcpy(&result, m_pStreamCurrent, sizeof(T));
m_pStreamCurrent += sizeof(T);
return result;
}
template <class T>
void Read(T& result)
{
memcpy(&result, m_pStreamCurrent, sizeof(result));
m_pStreamCurrent += sizeof(result);
}
void ReadBytes(u8* pDest, size_t numBytes)
{
memcpy(pDest, m_pStreamCurrent, numBytes);
m_pStreamCurrent += numBytes;
}
std::string ReadPString()
{
std::string result;
u8 length = *m_pStreamCurrent++;
result.insert(0, (char*)m_pStreamCurrent, (size_t)length);
m_pStreamCurrent += length;
return result;
}
std::string ReadLine()
{
unsigned char* pStreamEnd = m_pStreamStart + m_streamSize;
std::string result;
u8 *pEndOfLine = m_pStreamCurrent;
while (pEndOfLine < pStreamEnd)
{
if ((0x0a != *pEndOfLine) && (0x0d != *pEndOfLine))
{
pEndOfLine++;
}
else
{
break;
}
}
size_t length = pEndOfLine - m_pStreamCurrent;
if (length)
{
// Capture the line
result.insert(0, (char*)m_pStreamCurrent, (size_t)length);
m_pStreamCurrent += length;
}
// Figure out if that loop broke out because we hit the end of the file
while (pEndOfLine < pStreamEnd)
{
if ((0x0a == *pEndOfLine) || (0x0d == *pEndOfLine))
{
pEndOfLine++;
}
else
{
break;
}
}
m_pStreamCurrent = pEndOfLine;
if (m_pStreamCurrent > pStreamEnd)
{
m_pStreamCurrent = pStreamEnd;
}
return result;
}
size_t SeekCurrent(int delta)
{
m_pStreamCurrent += delta;
return m_pStreamCurrent - m_pStreamStart;
}
size_t SeekSet(size_t offset)
{
m_pStreamCurrent = m_pStreamStart + offset;
return m_pStreamCurrent - m_pStreamStart;
}
unsigned char* GetPointer() { return m_pStreamCurrent; }
size_t NumBytesAvailable() {
unsigned char* pStreamEnd = m_pStreamStart + m_streamSize;
if (pStreamEnd - m_pStreamCurrent >= 0)
{
return pStreamEnd - m_pStreamCurrent;
}
else
{
return 0;
}
}
private:
unsigned char* m_pStreamStart;
size_t m_streamSize;
unsigned char* m_pStreamCurrent;
};
#endif // MEMSTREAM_H_

View file

@ -0,0 +1,231 @@
//
// symfile.cpp
//
#include "symfile.h"
#include <stdio.h>
//------------------------------------------------------------------------------
// Static Helpers
static bool contains(char x, const char* pSeparators)
{
while (*pSeparators)
{
if (x == *pSeparators)
{
return true;
}
pSeparators++;
}
return false;
}
static std::vector<std::string> split(const std::string& s, const char* separators)
{
std::vector<std::string> output;
std::string::size_type prev_pos = 0, pos = 0;
for (int index = 0; index < s.length(); ++index)
{
pos = index;
// if the index is a separator
if (contains(s[index], separators))
{
// if we've skipped a token, collect it
if (prev_pos != index)
{
output.push_back(s.substr(prev_pos, index-prev_pos));
// skip white space here
while (index < s.length())
{
if (contains(s[index], separators))
{
++index;
}
else
{
prev_pos = index;
pos = index;
break;
}
}
}
else
{
prev_pos++;
}
}
}
output.push_back(s.substr(prev_pos, pos-prev_pos+1)); // Last word
return output;
}
// make this string lowercase
static void tolower(std::string& s)
{
for (int index = 0; index < s.length(); ++index)
{
s[index] = tolower( s[index] );
}
}
//------------------------------------------------------------------------------
SYMFile::SYMFile( std::string filepath )
: m_filepath( filepath )
{
FILE* pFile = nullptr;
errno_t err = fopen_s(&pFile, filepath.c_str(), "rb");
if (0==err)
{
fseek(pFile, 0, SEEK_END);
size_t length = ftell(pFile);
fseek(pFile, 0, SEEK_SET);
printf("\n// SYMFile %s - %lld bytes\n", filepath.c_str(), length);
printf("// Reading %s\n", filepath.c_str());
printf("//\n");
printf("// This file generated by blockgen.exe\n");
printf("//\n");
printf("//\n");
u8* pData = new u8[ length ];
fread(pData, sizeof(u8), length / sizeof(u8), pFile);
// Now we have a buffer, with the whole SYM File
// Read in the Sections
{
MemoryStream memStream(pData, length);
while (memStream.NumBytesAvailable())
{
std::string lineData = memStream.ReadLine();
// symbols are case sensitive
// we care about the first 32 bit value in hex, and the last value on the line, the symbol
std::vector<std::string> tokens = split(lineData, " \t");
if (tokens.size() >= 3)
{
if (IsHexAddress(tokens[0]))
{
// We're only interested in lines that start with a hex address
std::string sym_name = tokens[ tokens.size() - 1 ];
u32 address = strtoul(tokens[0].c_str(), nullptr, 16);
//printf("address = %08x\n", address);
if (0 != (address >> 24))
{
printf("#define %s_BLOCK %d\n", sym_name.c_str(), address>>24);
}
else if (0 != (address & 0xFF0000))
{
printf("#define %s_high %d\n", sym_name.c_str(), (address>>16) & 0xFF);
printf("#define %s_BLOCK %d\n", sym_name.c_str(), ((address&0xFFFFFF) / 0x2000));
}
}
}
}
}
delete[] pData;
fclose(pFile);
printf("\n// Read Completed\n");
}
else
{
printf("// SYMFile could not open %s\n", filepath.c_str());
printf("//\n");
printf("Feed in a symbol dump file, and I will print out a header file\n");
printf("Capture my output with a pipe.\n");
printf("\nGenerate a .sym file like this:\n");
printf("\nllvm-objdump --syms <program>.elf > program.sym\n");
}
}
//------------------------------------------------------------------------------
SYMFile::~SYMFile()
{
}
//------------------------------------------------------------------------------
u32 SYMFile::GetAddress(std::string symbolName)
{
u32 result_address = 0;
// If the address is in there, return it
// First remove trailing spaces from the sectionName
const size_t strEnd = symbolName.find_last_not_of(" ");
if (strEnd != std::string::npos)
{
if ((strEnd+1) != symbolName.length())
{
symbolName.resize(strEnd+1);
}
}
// Make sure not case sensitive
tolower(symbolName);
for (int labelIndex = 0; labelIndex < m_symbols.size(); ++labelIndex)
{
if (symbolName == m_symbols[labelIndex])
{
result_address = m_addresses[labelIndex];
break;
}
}
return result_address;
}
//------------------------------------------------------------------------------
bool SYMFile::IsHexAddress(const std::string& address)
{
if (8 == address.size())
{
for (int idx = 0; idx < 8; ++idx)
{
if ((address[idx] >= '0')&&(address[idx] <= '9'))
{
continue; // this is good
}
else if ((address[idx] >= 'a')&&(address[idx] <= 'f'))
{
continue; // this is good
}
else if ((address[idx] >= 'A')&&(address[idx] <= 'F'))
{
continue; // this is good
}
else
{
return false;
}
}
return true;
}
return false;
}
//------------------------------------------------------------------------------

View file

@ -0,0 +1,34 @@
//
// SYMFile Class
//
#ifndef SYMFILE_H_
#define SYMFILE_H_
#include <string>
#include <vector>
#include "bctypes.h"
#include "memstream.h"
//------------------------------------------------------------------------------
class SYMFile
{
public:
SYMFile( std::string filepath );
~SYMFile();
u32 GetAddress(std::string symbolName);
bool IsHexAddress(const std::string& address);
private:
std::string m_filepath;
std::vector<std::string> m_symbols;
std::vector<u32> m_addresses;
};
#endif // SYMFILE_H_

View file

@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.8.34309.116
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "blockgen", "blockgen.vcxproj", "{3E291D4B-EB9C-439B-8090-A0F1D0BD21EB}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{3E291D4B-EB9C-439B-8090-A0F1D0BD21EB}.Debug|x64.ActiveCfg = Debug|x64
{3E291D4B-EB9C-439B-8090-A0F1D0BD21EB}.Debug|x64.Build.0 = Debug|x64
{3E291D4B-EB9C-439B-8090-A0F1D0BD21EB}.Debug|x86.ActiveCfg = Debug|Win32
{3E291D4B-EB9C-439B-8090-A0F1D0BD21EB}.Debug|x86.Build.0 = Debug|Win32
{3E291D4B-EB9C-439B-8090-A0F1D0BD21EB}.Release|x64.ActiveCfg = Release|x64
{3E291D4B-EB9C-439B-8090-A0F1D0BD21EB}.Release|x64.Build.0 = Release|x64
{3E291D4B-EB9C-439B-8090-A0F1D0BD21EB}.Release|x86.ActiveCfg = Release|Win32
{3E291D4B-EB9C-439B-8090-A0F1D0BD21EB}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {43F6DB44-6241-4F87-B55D-35450E50405E}
EndGlobalSection
EndGlobal

View file

@ -0,0 +1,141 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>17.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{3e291d4b-eb9c-439b-8090-a0f1d0bd21eb}</ProjectGuid>
<RootNamespace>blockgen</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\source\blockgen.cpp" />
<ClCompile Include="..\source\symfile.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\source\bctypes.h" />
<ClInclude Include="..\source\memstream.h" />
<ClInclude Include="..\source\symfile.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View file

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\source\blockgen.cpp" />
<ClCompile Include="..\source\symfile.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\source\bctypes.h">
<Filter>Source Files</Filter>
</ClInclude>
<ClInclude Include="..\source\memstream.h">
<Filter>Source Files</Filter>
</ClInclude>
<ClInclude Include="..\source\symfile.h">
<Filter>Source Files</Filter>
</ClInclude>
</ItemGroup>
</Project>

BIN
bin/overlayhelper.exe Normal file

Binary file not shown.

View file

@ -0,0 +1,49 @@
#
# overlayhelper/Makefile
#
# Make and Build Variables
VPATH = source:obj
SOURCEFILES = $(wildcard source/*.cpp)
OBJFILES = $(patsubst source/%.cpp,obj/%.o,$(SOURCEFILES))
CC = clang++
INCCMD = -Isource
# List of directories to create
DIRS=obj
CFLAGS = -std=c++17 -Os -Wall -Werror
#CFLAGS = -Os -Wall -Werror -S
help:
@echo
@echo overlayhelper Makefile
@echo -------------------------------------------------
@echo build commands:
@echo make install - Compile / Install
@echo make clean - Clean intermediate/target files
@echo -------------------------------------------------
@echo
overlayhelper: $(OBJFILES)
install: overlayhelper
$(CC) -o ../oh $(OBJFILES)
# $(CC) -o ../overlayhelper $(OBJFILES) -Wl,-Map,overlayhelper.map
clean:
@echo Remove overlayhelper
$(shell if exist overlayhelper echo Y | rm overlayhelper)
@echo Remove Intermediate Files
@rm obj\*
# Goofy Object File Rule
obj/%.o : source/%.cpp
@echo Compiling $(<F)
$(CC) $(CFLAGS) $(INCCMD) -c $< -o obj/$*.o
# Create all the directories
$(shell if not exist $(DIRS) mkdir $(DIRS))

View file

@ -0,0 +1,48 @@
/*
bctypes.h
Because I need Standard Types
*/
#ifndef _bctypes_h
#define _bctypes_h
typedef signed char i8;
typedef unsigned char u8;
typedef signed short i16;
typedef unsigned short u16;
typedef signed long i32;
typedef unsigned long u32;
typedef signed long long i64;
typedef unsigned long long u64;
// If we're using C, I still like having a bool around
#ifndef __cplusplus
typedef i32 bool;
#define false (0)
#define true (!false)
#define nullptr 0
#endif
typedef float f32;
typedef float r32;
typedef double f64;
typedef double r64;
#define null (0)
// Odd Types
typedef union {
// u128 ul128;
u64 ul64[2];
u32 ui32[4];
} QWdata;
#endif // _bctypes_h
// EOF - bctypes.h

View file

@ -0,0 +1,220 @@
//
// cfile.cpp
//
#include "cfile.h"
#ifdef __STDC_LIB_EXT1__
#define __STDC_WANT_LIB_EXT1__ 1
#endif
#include <stdio.h>
//------------------------------------------------------------------------------
// Static Helpers
static bool contains(char x, const char* pSeparators)
{
while (*pSeparators)
{
if (x == *pSeparators)
{
return true;
}
pSeparators++;
}
return false;
}
static std::vector<std::string> split(const std::string& s, const char* separators)
{
std::vector<std::string> output;
std::string::size_type prev_pos = 0, pos = 0;
for (int index = 0; index < s.length(); ++index)
{
pos = index;
// if the index is a separator
if (contains(s[index], separators))
{
// if we've skipped a token, collect it
if (prev_pos != index)
{
output.push_back(s.substr(prev_pos, index-prev_pos));
// skip white space here
while (index < s.length())
{
if (contains(s[index], separators))
{
++index;
}
else
{
prev_pos = index;
pos = index;
break;
}
}
}
else
{
prev_pos++;
}
}
}
output.push_back(s.substr(prev_pos, pos-prev_pos+1)); // Last word
return output;
}
#if 0
// make this string lowercase
static void tolower(std::string& s)
{
for (int index = 0; index < s.length(); ++index)
{
s[index] = tolower( s[index] );
}
}
#endif
static std::string next_token(std::vector<std::string>& tokens, MemoryStream& memStream)
{
std::string result = "";
if (tokens.size() >= 1)
{
result = tokens[0];
tokens.erase(tokens.cbegin());
}
else
{
while (memStream.NumBytesAvailable())
{
std::string lineData = memStream.ReadLine();
tokens = split(lineData, "[](), \t");
if (tokens.size() >= 1)
{
return next_token(tokens, memStream);
}
}
}
return result;
}
//------------------------------------------------------------------------------
CFile::CFile( std::string filepath )
: m_filepath( filepath )
{
FILE* pFile = nullptr;
#ifdef __STDC_LIB_EXT1__
int err = fopen_s(&pFile, filepath.c_str(), "rb");
#else
int err = 0;
pFile = fopen(filepath.c_str(), "rb");
#endif
if ((0==err) && (nullptr!=pFile))
{
fseek(pFile, 0, SEEK_END);
size_t length = ftell(pFile);
fseek(pFile, 0, SEEK_SET);
//printf("\n// CFile %s - %lld bytes\n", filepath.c_str(), length);
//printf("// Reading %s\n", filepath.c_str());
//printf("//\n");
//printf("// This file generated by overlayhelper.exe\n");
//printf("//\n");
//printf("//\n");
u8* pData = new u8[ length ];
fread(pData, sizeof(u8), length / sizeof(u8), pFile);
// Now we have a buffer, with the whole C File
// Looking to parse 2 types of things
// CODE_BLOCK macros
// DATA_BLOCK macros
// INCBIN macros
{
MemoryStream memStream(pData, length);
while (memStream.NumBytesAvailable())
{
std::string lineData = memStream.ReadLine();
// symbols are case sensitive
// we care about the first 32 bit value in hex, and the last value on the line, the symbol
std::vector<std::string> tokens = split(lineData, "[](), \t");
if (tokens.size() >= 2)
{
std::string token = next_token(tokens, memStream);
if (token == "INCBIN")
{
// section
token = next_token(tokens, memStream);
token = next_token(tokens, memStream);
printf("incbin_%s_start_high = incbin_%s_start>>16;\n", token.c_str(),token.c_str());
printf("incbin_%s_start_BLOCK = incbin_%s_start/0x2000;\n", token.c_str(),token.c_str());
printf("incbin_%s_length = incbin_%s_end-incbin_%s_start;\n", token.c_str(),token.c_str(),token.c_str());
printf("incbin_%s_length_high = incbin_%s_length>>16;\n", token.c_str(),token.c_str());
}
else if ( (token == "CODE_BLOCK") ||
(token == "DATA_BLOCK") )
{
// We aren't as good as the C Preprocessor, but we will allow this
// to span 1 line, because RickJr has weird syntax
// First get the block number
token = next_token(tokens, memStream);
u32 block_num = strtoul(token.c_str(), nullptr, 0);
// Next we need the function name
do
{
token = next_token(tokens, memStream);
} while (token=="static" || token =="volatile");
// now token has return type
token = next_token(tokens, memStream);
// now token finally has our function or data name
printf("%s_BLOCK = %lu;\n", token.c_str(), block_num); // just need the block number for mapper
}
}
}
}
delete[] pData;
fclose(pFile);
//printf("\n// Read Completed\n");
}
else
{
printf("// CFile could not open %s\n", filepath.c_str());
printf("//\n");
}
}
//------------------------------------------------------------------------------
CFile::~CFile()
{
}
//------------------------------------------------------------------------------

View file

@ -0,0 +1,27 @@
//
// CFile Class
//
#ifndef CFILE_H_
#define CFILE_H_
#include <string>
#include <vector>
#include "bctypes.h"
#include "memstream.h"
//------------------------------------------------------------------------------
class CFile
{
public:
CFile( std::string filepath );
~CFile();
private:
std::string m_filepath;
};
#endif // CFILE_H_

View file

@ -0,0 +1,164 @@
//
// Jason's Memory Stream Helper thing
// Serialize a byte stream into real types
//
// Currently only support Little Endian
//
#ifndef MEMSTREAM_H_
#define MEMSTREAM_H_
#include <string>
// Prototypes
void *memcpy(void *dest, const void *src, size_t n);
class MemoryStream
{
public:
MemoryStream(unsigned char* pStreamStart, size_t streamSize)
: m_pStreamStart( pStreamStart )
, m_streamSize(streamSize)
, m_pStreamCurrent( pStreamStart )
{}
~MemoryStream()
{
m_pStreamStart = nullptr;
m_streamSize = 0;
m_pStreamCurrent = nullptr;
}
// Really Dumb Reader Template
template <class T>
T Read()
{
T result;
memcpy(&result, m_pStreamCurrent, sizeof(T));
m_pStreamCurrent += sizeof(T);
return result;
}
template <class T>
void Read(T& result)
{
memcpy(&result, m_pStreamCurrent, sizeof(result));
m_pStreamCurrent += sizeof(result);
}
void ReadBytes(u8* pDest, size_t numBytes)
{
memcpy(pDest, m_pStreamCurrent, numBytes);
m_pStreamCurrent += numBytes;
}
std::string ReadPString()
{
std::string result;
u8 length = *m_pStreamCurrent++;
result.insert(0, (char*)m_pStreamCurrent, (size_t)length);
m_pStreamCurrent += length;
return result;
}
std::string ReadLine()
{
unsigned char* pStreamEnd = m_pStreamStart + m_streamSize;
std::string result;
u8 *pEndOfLine = m_pStreamCurrent;
while (pEndOfLine < pStreamEnd)
{
if ((0x0a != *pEndOfLine) && (0x0d != *pEndOfLine))
{
pEndOfLine++;
}
else
{
break;
}
}
size_t length = pEndOfLine - m_pStreamCurrent;
if (length)
{
// Capture the line
result.insert(0, (char*)m_pStreamCurrent, (size_t)length);
m_pStreamCurrent += length;
}
// Figure out if that loop broke out because we hit the end of the file
while (pEndOfLine < pStreamEnd)
{
if ((0x0a == *pEndOfLine) || (0x0d == *pEndOfLine))
{
pEndOfLine++;
}
else
{
break;
}
}
m_pStreamCurrent = pEndOfLine;
if (m_pStreamCurrent > pStreamEnd)
{
m_pStreamCurrent = pStreamEnd;
}
return result;
}
size_t SeekCurrent(int delta)
{
m_pStreamCurrent += delta;
return m_pStreamCurrent - m_pStreamStart;
}
size_t SeekSet(size_t offset)
{
m_pStreamCurrent = m_pStreamStart + offset;
return m_pStreamCurrent - m_pStreamStart;
}
unsigned char* GetPointer() { return m_pStreamCurrent; }
size_t NumBytesAvailable() {
unsigned char* pStreamEnd = m_pStreamStart + m_streamSize;
if (pStreamEnd - m_pStreamCurrent >= 0)
{
return pStreamEnd - m_pStreamCurrent;
}
else
{
return 0;
}
}
private:
unsigned char* m_pStreamStart;
size_t m_streamSize;
unsigned char* m_pStreamCurrent;
};
#endif // MEMSTREAM_H_

View file

@ -0,0 +1,70 @@
// overlayhelper
//
// - generate linker script crap, so that we can resolve addresses larger
// than 32-bit with mos llvm (hacky work around for 16 bit address linker)
#include <stdio.h>
#include <stdlib.h>
#include "cfile.h"
//------------------------------------------------------------------------------
void helpText()
{
printf("overlayhelper - v1.0\n");
printf("--------------------\n");
printf("Convert macros found in C code, into mos-llvm .ld linker format\n");
printf("\noverlayhelper [options] <file.c>\n");
printf(" -v verbose\n\n");
exit(-1);
}
//------------------------------------------------------------------------------
int main(int argc, char* argv[])
{
char* pInfilePath = nullptr;
bool bVerbose = false;
for (int idx = 1; idx < argc; ++idx )
{
char* arg = argv[ idx ];
if ('-' == arg[0])
{
// Parse as an option
if ('v'==arg[1])
{
bVerbose = true;
}
}
else if (nullptr == pInfilePath)
{
// Assume the first non-option is an input file path
pInfilePath = argv[ idx ];
}
else
{
// Oh Crap, we have a non-option, but we don't know what to do with
// it
printf("ERROR: Invalid option, Arg %d = %s\n\n", idx, argv[ idx ]);
helpText();
}
}
if (pInfilePath)
{
// Load the .c File
CFile *pCFile = new CFile(std::string(pInfilePath));
delete pCFile;
}
else
{
helpText();
}
return 0;
}

View file

@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.8.34309.116
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "overlayhelper", "overlayhelper.vcxproj", "{77D5186F-C388-4740-8BA7-23997A659FB8}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{77D5186F-C388-4740-8BA7-23997A659FB8}.Debug|x64.ActiveCfg = Debug|x64
{77D5186F-C388-4740-8BA7-23997A659FB8}.Debug|x64.Build.0 = Debug|x64
{77D5186F-C388-4740-8BA7-23997A659FB8}.Debug|x86.ActiveCfg = Debug|Win32
{77D5186F-C388-4740-8BA7-23997A659FB8}.Debug|x86.Build.0 = Debug|Win32
{77D5186F-C388-4740-8BA7-23997A659FB8}.Release|x64.ActiveCfg = Release|x64
{77D5186F-C388-4740-8BA7-23997A659FB8}.Release|x64.Build.0 = Release|x64
{77D5186F-C388-4740-8BA7-23997A659FB8}.Release|x86.ActiveCfg = Release|Win32
{77D5186F-C388-4740-8BA7-23997A659FB8}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {4AE0A6E5-5981-4BAE-96E2-DDD5656B0B2E}
EndGlobalSection
EndGlobal

View file

@ -0,0 +1,147 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>17.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{77d5186f-c388-4740-8ba7-23997a659fb8}</ProjectGuid>
<RootNamespace>overlayhelper</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<OutDir>$(SolutionDir)\..\..</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<OutDir>$(SolutionDir)\..\..</OutDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="..\source\bctypes.h" />
<ClInclude Include="..\source\cfile.h" />
<ClInclude Include="..\source\memstream.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\source\cfile.cpp" />
<ClCompile Include="..\source\overlayhelper.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View file

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\source\bctypes.h">
<Filter>Source Files</Filter>
</ClInclude>
<ClInclude Include="..\source\cfile.h">
<Filter>Source Files</Filter>
</ClInclude>
<ClInclude Include="..\source\memstream.h">
<Filter>Source Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\source\cfile.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\source\overlayhelper.cpp" />
</ItemGroup>
</Project>

BIN
data/credits.256 Normal file

Binary file not shown.

BIN
data/credits.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

BIN
lib/i256.flib Normal file

Binary file not shown.

183
rickjr.ld Normal file
View file

@ -0,0 +1,183 @@
/* RickJr Linker Script
*/
/*
TARGET(binary)
INPUT(./data/congrats.256)
INPUT(./data/haf.256)
INPUT(./data/splash.256)
INPUT(./data/sprites_data.256)
INPUT(./data/tiles_data.256)
*/
/* fake C Stack */
PROVIDE(__stack = 0xA000);
/* entry point to my program */
PROVIDE(__f256_start = 0x300);
/* page size of a block of memory */
PROVIDE(__BLOCK_SIZE = 0x2000);
/* swappable block address */
PROVIDE(__SLOT_ADDR = 0xA000);
/* f256k uses first 16 bytes of ZP for mmu control? */
__rc0 = 0x10;
INCLUDE imag-regs.ld
ASSERT(__rc0 == 0x10, "Inconsistent zero page map.")
ASSERT(__rc31 == 0x2f, "Inconsistent zero page map.")
MEMORY {
/* kernel uses 0xf0-0xff for parameter passing */
zp : ORIGIN = __rc31 + 1, LENGTH = 0xF0 - (__rc31 + 1)
ram (rw) : ORIGIN = __f256_start, LENGTH = 0xA000-__f256_start
}
/* LMAs */
__block8_lma = ( 8<<24)|__SLOT_ADDR;
__block9_lma = ( 9<<24)|__SLOT_ADDR;
__block10_lma = (10<<24)|__SLOT_ADDR;
__block11_lma = (11<<24)|__SLOT_ADDR;
__block12_lma = (12<<24)|__SLOT_ADDR;
__block13_lma = (13<<24)|__SLOT_ADDR;
__block14_lma = (14<<24)|__SLOT_ADDR;
__block15_lma = (15<<24)|__SLOT_ADDR;
__block16_lma = (16<<24)|__SLOT_ADDR;
__block17_lma = (17<<24)|__SLOT_ADDR;
__block18_lma = (18<<24)|__SLOT_ADDR;
__block19_lma = (19<<24)|__SLOT_ADDR;
__block20_lma = (20<<24)|__SLOT_ADDR;
__block21_lma = (21<<24)|__SLOT_ADDR;
__block22_lma = (22<<24)|__SLOT_ADDR;
__block23_lma = (23<<24)|__SLOT_ADDR;
/* Stash preloaded binary data */
__binarydata_lma = 0x70000; /* At least now, its less than 64k */
__BINARYDATA_SIZE = 0x10000;
MEMORY {
binarydata : ORIGIN = __binarydata_lma, LENGTH = __BINARYDATA_SIZE
block8 : ORIGIN = __block8_lma, LENGTH = __BLOCK_SIZE
block9 : ORIGIN = __block9_lma, LENGTH = __BLOCK_SIZE
block10 : ORIGIN = __block10_lma, LENGTH = __BLOCK_SIZE
block11 : ORIGIN = __block11_lma, LENGTH = __BLOCK_SIZE
block12 : ORIGIN = __block12_lma, LENGTH = __BLOCK_SIZE
block13 : ORIGIN = __block13_lma, LENGTH = __BLOCK_SIZE
block14 : ORIGIN = __block14_lma, LENGTH = __BLOCK_SIZE
block15 : ORIGIN = __block15_lma, LENGTH = __BLOCK_SIZE
block16 : ORIGIN = __block16_lma, LENGTH = __BLOCK_SIZE
block17 : ORIGIN = __block17_lma, LENGTH = __BLOCK_SIZE
block18 : ORIGIN = __block18_lma, LENGTH = __BLOCK_SIZE
block19 : ORIGIN = __block19_lma, LENGTH = __BLOCK_SIZE
block20 : ORIGIN = __block20_lma, LENGTH = __BLOCK_SIZE
block21 : ORIGIN = __block21_lma, LENGTH = __BLOCK_SIZE
block22 : ORIGIN = __block22_lma, LENGTH = __BLOCK_SIZE
block23 : ORIGIN = __block23_lma, LENGTH = __BLOCK_SIZE
}
REGION_ALIAS("c_writeable", ram)
/* REGION_ALIAS("c_readonly", fixed) */
/* I want to use the lower 40k */
REGION_ALIAS("c_readonly", ram)
SECTIONS {
INCLUDE c.ld
.binarydata : { *(.binarydata .binarydata.*) } >binarydata end_binarydata = .;
.block8 : { *(.block8 .block8.*) } >block8 end_block8 = .;
.block9 : { *(.block9 .block9.*) } >block9 end_block9 = .;
.block10 : { *(.block10 .block10.*) } >block10 end_block10 = .;
.block11 : { *(.block11 .block11.*) } >block11 end_block11 = .;
.block12 : { *(.block12 .block12.*) } >block12 end_block12 = .;
.block13 : { *(.block13 .block13.*) } >block13 end_block13 = .;
.block14 : { *(.block14 .block14.*) } >block14 end_block14 = .;
.block15 : { *(.block15 .block15.*) } >block15 end_block15 = .;
.block16 : { *(.block16 .block16.*) } >block16 end_block16 = .;
.block17 : { *(.block17 .block17.*) } >block17 end_block17 = .;
.block18 : { *(.block18 .block18.*) } >block18 end_block18 = .;
.block19 : { *(.block19 .block19.*) } >block19 end_block19 = .;
.block20 : { *(.block20 .block20.*) } >block20 end_block20 = .;
.block21 : { *(.block21 .block21.*) } >block21 end_block21 = .;
.block22 : { *(.block22 .block22.*) } >block22 end_block22 = .;
.block23 : { *(.block23 .block23.*) } >block23 end_block23 = .;
}
/* Trick linker into exposing symbols with values larger than 16 bits */
INCLUDE overlay.ld
/* OUTPUT_FORMAT { FULL(cart_rom) } */
OUTPUT_FORMAT {
BYTE(0x5A) /* pgZ */
/* ram segment */
SHORT(ORIGIN(ram)) /* where to load it, 24 bits */
BYTE(0x00)
SHORT(__bss_start-ORIGIN(ram)) /* size to load */
BYTE(0x00)
TRIM(ram)
/* block8 */
SHORT(8*0x2000)
BYTE(8/8) /* block#/8 = the actual system high byte */
SHORT(end_block8 - __block8_lma)
BYTE(0x00)
TRIM(block8)
/* block9 */
SHORT(9*0x2000)
BYTE(9/8) /* block#/8 = the actual system high byte */
SHORT(end_block9 - __block9_lma)
BYTE(0x00)
TRIM(block9)
/* block10 */
SHORT(10*0x2000)
BYTE(10/8) /* block#/8 = the actual system high byte */
SHORT(end_block10 - __block10_lma)
BYTE(0x00)
TRIM(block10)
/* block11 */
SHORT(11*0x2000)
BYTE(11/8) /* block#/8 = the actual system high byte */
SHORT(end_block11 - __block11_lma)
BYTE(0x00)
TRIM(block11)
/*
Empty Blocks are not allowed, bring these in as you use them
TRIM(block12)
TRIM(block13)
TRIM(block14)
TRIM(block15)
TRIM(block16)
TRIM(block17)
TRIM(block18)
TRIM(block19)
TRIM(block20)
TRIM(block21)
TRIM(block22)
TRIM(block23)
*/
/* Compressed Data */
SHORT(ORIGIN(binarydata))
BYTE(ORIGIN(binarydata)>>16)
SHORT(end_binarydata - __binarydata_lma)
BYTE((end_binarydata - __binarydata_lma)>>16)
TRIM(binarydata)
/* Launch the program, at _start */
SHORT(_start)
LONG(0)
}

View file

@ -19,7 +19,7 @@
segment "dat";
#endif
entdata_t ent_entdata[ENT_NBR_ENTDATA] = {
DATA_BLOCK(10) entdata_t ent_entdata[ENT_NBR_ENTDATA] = {
{0000, 0000, 000000, 000000, 0000, 0000, 0x00},
{0x18, 0x15, 000000, 000000, 0000, 0000, 0x00},
{0000, 0000, 000000, 000000, 0000, 0000, 0x00},
@ -101,7 +101,7 @@ entdata_t ent_entdata[ENT_NBR_ENTDATA] = {
{0x18, 0x10, 0x000c, 0x0005, 0x04, 0x04, 0x14},
};
U8 ent_sprseq[ENT_NBR_SPRSEQ] = {
DATA_BLOCK(10) U8 ent_sprseq[ENT_NBR_SPRSEQ] = {
0000, 0x01, 0000, 0x02, 0x05, 0x03, 0x04, 0x03,
0x65, 0xff, 0x66, 0xff, 0x55, 0xff, 0000, 0x56,
0xff, 0000, 0x57, 0xff, 0000, 0x58, 0x59, 0xff,
@ -122,7 +122,7 @@ U8 ent_sprseq[ENT_NBR_SPRSEQ] = {
0xff, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xff, 0x00,
};
mvstep_t ent_mvstep[ENT_NBR_MVSTEP] = {
DATA_BLOCK(10) mvstep_t ent_mvstep[ENT_NBR_MVSTEP] = {
{ 0x10, 0, 0 } ,
{ 0x0c, 0, 4 } ,
{ 0xfa, 0, 0 } ,

View file

@ -19,7 +19,7 @@ segment "dat";
#include "system.h"
#include "maps.h"
map_t map_maps[MAP_NBR_MAPS] = {
DATA_BLOCK(9) map_t map_maps[MAP_NBR_MAPS] = {
#ifdef IIGS
{0x0008, 0x008b, 0x0008, 000000, &samerica_lz4},
{0x0008, 0x008b, 0x0068, 0x0009, &egypt_lz4},
@ -35,7 +35,7 @@ map_t map_maps[MAP_NBR_MAPS] = {
#endif
};
submap_t map_submaps[MAP_NBR_SUBMAPS] = {
DATA_BLOCK(9) submap_t map_submaps[MAP_NBR_SUBMAPS] = {
{000000, 000000, 000000, 000000},
{000000, 0x0078, 0x0003, 0x0005},
{000000, 0x0150, 0x0006, 0x0011},
@ -85,7 +85,7 @@ submap_t map_submaps[MAP_NBR_SUBMAPS] = {
{0x0001, 0x1f5a, 0x0096, 0x0202},
};
connect_t map_connect[MAP_NBR_CONNECT] = {
DATA_BLOCK(9) connect_t map_connect[MAP_NBR_CONNECT] = {
/* map 0 */
@ -1322,7 +1322,7 @@ U8 map_bnums[MAP_NBR_BNUMS] = {
0xc0, 0xc0, 0000, 0000, 0000, 0000, 0000, 0000,
};
block_t map_blocks[MAP_NBR_BLOCKS] = {
DATA_BLOCK(9) block_t map_blocks[MAP_NBR_BLOCKS] = {
{0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000,
0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000},
{0x29, 0x2a, 0x2d, 0x2e, 0x2b, 0x2c, 0x2f, 0x30,
@ -1837,7 +1837,7 @@ block_t map_blocks[MAP_NBR_BLOCKS] = {
0x22, 0x2d, 0x2e, 0xe7, 0x28, 0x2b, 0x2c, 0xea},
};
mark_t map_marks[MAP_NBR_MARKS] = {
DATA_BLOCK(9) mark_t map_marks[MAP_NBR_MARKS] = {
{0x18, 0x16, 0000, 0x08, 0x08}, /* 0 */
{0x18, 0x2a, 0x88, 0x01, 0x28},
{0x38, 0x04, 0xf0, 0x15, 0x29},
@ -2363,7 +2363,7 @@ mark_t map_marks[MAP_NBR_MARKS] = {
{0xff, 0000, 0000, 0000, 0000},
};
U8 map_eflg_c[MAP_NBR_EFLGC] = {
DATA_BLOCK(9) U8 map_eflg_c[MAP_NBR_EFLGC] = {
0x4d, 0000, 0x0e, 0x02, 0x04, 0x04, 0x57, 0x08,
0x08, 0x18, 0x03, 0x68, 0x3b, 0x48, 0x04, 0x80,
0x37, 0000, 0x04, 0x02, 0x04, 0x04, 0x90, 0x08,

57
src/dat_spritesJR.c Normal file
View file

@ -0,0 +1,57 @@
/*
* xrick/data/dat-sprites.c
*
* Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net). All rights reserved.
*
* The use and distribution terms for this software are contained in the file
* named README, which can be found in the root of this distribution. By
* using this software in any fashion, you are agreeing to be bound by the
* terms of this license.
*
* You must not remove this notice, or any other, from this software.
*/
#include "config.h"
#ifdef GFXF256
// $$TODO - move this macro into it's own header
#define STR2(x) #x
#define STR(x) STR2(x)
// this aligns start address to 16 and terminates byte array with explict 0
// which is not really needed, feel free to change it to whatever you want/need
#define INCBIN(INCBIN_SECTION, name, file) \
__asm__(".section " INCBIN_SECTION ",\"aR\" \n" \
".global incbin_" STR(name) "_start\n" \
".balign 16\n" \
"incbin_" STR(name) "_start:\n" \
".incbin \"" file "\"\n" \
\
".global incbin_" STR(name) "_end\n" \
".balign 1\n" \
"incbin_" STR(name) "_end:\n" \
".byte 0\n" \
); \
extern __attribute__((aligned(16))) const char incbin_ ## name ## _start[]; \
extern const char incbin_ ## name ## _end[]
// Credits/Jr Title
INCBIN(".binarydata.credits", credits_256, "data/credits.256");
// Title Page
INCBIN(".binarydata.splash", splash_256, "data/splash.256");
// Map Tiles
INCBIN(".binarydata.tiles", tiles_256, "data/tiles_data.256");
// Sprite Frames (32x32 sprites)
INCBIN(".binarydata.sprites", sprites_256, "data/sprites_data.256");
// Hall of Fame
INCBIN(".binarydata.haf", haf_256, "data/haf.256");
// Congrats
INCBIN(".binarydata.haf", congrats_256, "data/congrats.256");
INCBIN(".block11.i256", i256lib, "lib/i256.flib");
#endif /* GFXF256 */
/* eof */

29
src/mapper.h Normal file
View file

@ -0,0 +1,29 @@
/*
Special mapper macros for the F256 + mos-llvm, so we can put code
anywhere in physical ram
Currently only blocks 8-23 are defined in the linker file
If you need to go beyond the 128k of extra code, just add more definitions
into rickjr.ld
*/
#if defined(F256) && F256
/*
$$JGA TODO, sort out how to mark an entire file
*/
#define CODE_BLOCK(index) __attribute__((noinline, section(".block"#index)))
#define DATA_BLOCK(index) __attribute__((section(".block"#index)))
#define PAGEIN(_function_BLOCK) POKE(SWAP_SLOT, _function_BLOCK)
#else
#define CODE_BLOCK(index)
#define DATA_BLOCK(index)
#define PAGEIN(_function_BLOCK)
#endif

View file

@ -13,9 +13,27 @@ segment "screen";
#endif
extern char credits_lz4;
extern char incbin_sprites_256_start[];
extern char incbin_sprites_256_start_high[];
extern char incbin_tiles_256_start[];
extern char incbin_splash_256_start[];
extern char __block23_lma_high[];
//extern char scr_credit_BLOCK[];
extern const char scr_credit_BLOCK;
void scr_credit()
CODE_BLOCK(8) void scr_credit()
{
#ifdef F256
//$$JGA TODO - fix this
*((char*)0x200) = (char)(((long)(&incbin_sprites_256_start)));
*((char*)0x201) = (char)(((long)(&incbin_sprites_256_start))>>8);
*((char*)0x202) = (char)(((long)(&incbin_sprites_256_start_high)));
// *((char*)0x203) = (char)(((long)(&scr_credit_BLOCK)));
*((char*)0x203) = scr_credit_BLOCK;
// *((char*)0x203) = (char)(((long)(__block23_lma_high))>>8);
#endif
#ifdef IIGS
// Keep the Screen on
*VIDEO_REGISTER|=0xC0;

View file

@ -34,9 +34,6 @@
void puts(char* c_str)
{
}
void __putchar(char c)
{
}
#endif
@ -141,7 +138,7 @@ sys_sleep(int s)
/*
* Initialize system
*/
void
CODE_BLOCK(8) void
sys_init(int argc, char **argv)
{
sysarg_init(argc, argv);