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

1.0 dev #88

Merged
merged 35 commits into from
Dec 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
44d82c9
Update memory block implementation
BlockoS Sep 1, 2024
5c3a57d
Update log message output
BlockoS Sep 1, 2024
420b3c1
Update documentation
BlockoS Sep 1, 2024
90ce677
Add message printer unit tests
BlockoS Sep 2, 2024
513d0e3
Update message API
BlockoS Sep 3, 2024
e83edfc
Update memory map
BlockoS Sep 4, 2024
62a2c7f
Add Fake Function Framework
BlockoS Sep 4, 2024
dce0237
Start updating ROM loading
BlockoS Sep 4, 2024
7505b0b
Build fff and add symbol wrapping to ut targets
BlockoS Sep 6, 2024
da32f27
Start working on rom_load unit tests
BlockoS Sep 6, 2024
f6df750
Bring back label unit tests
BlockoS Sep 6, 2024
388b5cc
Revamped label repository
BlockoS Sep 7, 2024
efec9a3
Bring back comments (still have to work on loading)
BlockoS Sep 7, 2024
37b7ba1
Add comment repository load & save
BlockoS Sep 8, 2024
956cf40
Fix build
BlockoS Sep 8, 2024
e144f57
Update checkout version
BlockoS Sep 8, 2024
30591e3
Test label loading
BlockoS Sep 8, 2024
15ebcba
WIP
BlockoS Oct 12, 2024
c4c7cd5
Rework section
BlockoS Oct 12, 2024
6dc5473
Fix markdown
BlockoS Oct 12, 2024
dfbf35e
Update section unit tests
BlockoS Oct 13, 2024
4032bdd
Fix opcodes
BlockoS Oct 13, 2024
8820455
Add opcode unit tests
BlockoS Oct 13, 2024
34286d7
Add IPL unit test & fixes
BlockoS Oct 20, 2024
cd0b9cb
Remove Games Express bank 0 from examples (use the repo instead)
BlockoS Oct 20, 2024
352e370
Fix build
BlockoS Nov 1, 2024
1c0a06a
Section rework wip
BlockoS Nov 4, 2024
d4bdb0a
Fix cli
BlockoS Dec 1, 2024
358a2f9
Update submodules
BlockoS Dec 1, 2024
b167e74
Section update cont'd
BlockoS Dec 23, 2024
c5ee7f9
Adding a new section keeps the array sorted and merge sections if nec…
BlockoS Dec 25, 2024
a6853eb
Rework section delete
BlockoS Dec 26, 2024
c5f77b4
Rework section merge
BlockoS Dec 26, 2024
b697c18
Fix data section parsing
BlockoS Dec 26, 2024
3a0e208
Finish cleaning things up
BlockoS Dec 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 8 additions & 11 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,25 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: 'recursive'

- name: Setup Dependencies
run: |
sudo apt install -y -qq libjansson-dev

- name: Create Build Environment
run: cmake -E make_directory ${{github.workspace}}/build

- name: Configure CMake
- name: Configure
shell: bash
working-directory: ${{github.workspace}}/build
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE
working-directory: ${{github.workspace}}
run: cmake -Bbuild -S . -DCMAKE_BUILD_TYPE=$BUILD_TYPE

- name: Build
working-directory: ${{github.workspace}}/build
working-directory: ${{github.workspace}}
shell: bash
run: cmake --build . --config $BUILD_TYPE
run: cmake --build ./build --config $BUILD_TYPE

- name: Test
working-directory: ${{github.workspace}}/build
working-directory: ${{github.workspace}}
shell: bash
run: ctest -C $BUILD_TYPE
run: cmake --build ./build --target test
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@
[submodule "externals/cwalk"]
path = externals/cwalk
url = https://github.com/likle/cwalk.git
branch=v1.2.9
[submodule "externals/fff"]
path = externals/fff
url = https://github.com/meekrosoft/fff.git
19 changes: 10 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required (VERSION 3.16)
cmake_minimum_required (VERSION 3.30)

project(etripator
VERSION 0.9.0
Expand All @@ -8,7 +8,7 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
add_compile_definitions(_XOPEN_SOURCE=700)
endif()

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")

enable_testing()

Expand All @@ -17,17 +17,16 @@ include(CheckSymbolExists)
check_symbol_exists(strdup "string.h" HAVE_STRDUP)

if(NOT CMAKE_BUILD_TYPE)
message(STATUS, "No build type specified. Force build type to Debug.")
set(CMAKE_BUILD_TYPE "Debug")
endif()

set(EXECUTABLE_OUTPUT_PATH "${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}")

find_package(Doxygen)
find_package(Jansson)

set(CMAKE_C_STANDARDS 11)

add_subdirectory(externals)
add_subdirectory(externals EXCLUDE_FROM_ALL)

set(etripator_SRC
message.c
Expand All @@ -40,12 +39,14 @@ set(etripator_SRC
section/save.c
opcodes.c
comment.c
comment/load.c
comment/save.c
label.c
label/load.c
label/save.c
irq.c
memory.c
memorymap.c
memory_map.c
rom.c
cd.c
ipl.c
Expand All @@ -64,17 +65,16 @@ set(etripator_HDR
label.h
irq.h
memory.h
memorymap.h
memory_map.h
rom.h
cd.h
ipl.h
)

add_library(etripator STATIC ${etripator_SRC} ${etripator_HDR})
set_target_properties(etripator PROPERTIES C_STANDARD 11)
target_include_directories(etripator PUBLIC ${JANSSON_INCLUDE_DIRS} ${EXTRA_INCLUDE} externals)
target_compile_definitions(etripator PRIVATE _POSIX_C_SOURCE)
target_link_libraries(etripator PUBLIC ${JANSSON_LIBRARIES} cwalk)
target_link_libraries(etripator PUBLIC jansson cwalk)

add_executable(etripator_cli cli/etripator.c cli/options.c)
set_target_properties(etripator_cli
Expand All @@ -83,6 +83,7 @@ set_target_properties(etripator_cli
C_STANDARD 11
)
target_include_directories(etripator_cli PRIVATE ${CMAKE_SOURCE_DIR})
target_include_directories(etripator_cli PUBLIC externals)
target_link_libraries(etripator_cli etripator argparse)

set(DOXYFILE_IN ${CMAKE_CURRENT_SOURCE_DIR}/doxyfile.in)
Expand Down
27 changes: 12 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* [Gfx unpacking](examples/maerchen_maze) in Maerchen Maze - メルヘンメイズ .
* [Memory Base 128 detection](examples/tadaima) in Taidama Yusha Boshuchu - ただいま勇者募集中.
* [Joypad routine](examples/sf2) of Street Fighter II' Champion Edition - ストリートファイターII'.
* [Games Express CD Card bank #0](examples/games_express).
* [Games Express CD Card](https://github.com/BlockoS/GamesExpressCDCard).
* [Password check](examples/youkai_douchuuki) in Youkai Douchuuki - 妖怪道中記.

## Usage
Expand All @@ -22,7 +22,7 @@ The options are :
* **--help** or **-h** : displays help.
* **--out** or **-o < file >** : main asm file containing includes for all sections as long the irq vector table if the irq-detect option is enabled.
* **--labels** or **-l < file >** : labels definition filename.
* **--labels-out <file>** : extracted labels output filename. Otherwise the labels will be written to <in>.YYMMDDhhmmss.lbl.\n"
* **--labels-out <file>** : extracted labels output filename. Otherwise the labels will be written to `"<in>.YYMMDDhhmmss.lbl"`
* **--comments <file>** : comments description filename.
* **--address** : print statement logical address and page in an inline comment.
* **cfg** : configuration file. It is optional if irq detection is enabled.
Expand Down Expand Up @@ -189,27 +189,24 @@ This can be acheived using a package manager (apt, brew, chocolate, pacman, ...)
wget https://github.com/akheron/jansson/archive/v2.12.zip
unzip v2.12.zip
cd jansson-2.12
mkdir -p build/cmake
mkdir -p build/install
cd build/cmake
cmake ../.. -DJANSSON_BUILD_DOCS=OFF \
-DJANSSON_WITHOUT_TESTS=ON \
-DCMAKE_INSTALL_PREFIX=../install
cmake --build . --target install
cd ../../..
mkdir -p build
cmake -Bbuild/cmake -S . \
-DJANSSON_BUILD_DOCS=OFF \
-DJANSSON_WITHOUT_TESTS=ON \
-DCMAKE_INSTALL_PREFIX=build/install
cmake --build build/cmake --target install
```

Now on to building etripator.
```
cd etripator
mkdir -p build/cmake
cd build/cmake
cmake ../.. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../install
mkdir -p build
cmake -Bbuild/cmake -S . -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=cmake/install
```

If you build jansson as shown earlier you may configure the project with
```
cmake ../.. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../install \
cmake -Bbuild/cmake -S . -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=build/install \
-DJANSSON_INCLUDE_DIR=../../jansson-2.12/build/install/include \
-DJANSSON_LIBRARY=../../jansson-2.12/build/install/lib/jansson.lib
```
Expand All @@ -218,7 +215,7 @@ cmake ../.. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../install \

If everything went right, you can now compile the project with:
```
cmake --build . --config Release --target install
cmake --build build/cmake --target install
```

## Authors
Expand Down
23 changes: 10 additions & 13 deletions README.nfo
Original file line number Diff line number Diff line change
Expand Up @@ -246,35 +246,32 @@ or by building it from source.
wget https://github.com/akheron/jansson/archive/v2.12.zip
unzip v2.12.zip
cd jansson-2.12
mkdir -p build/cmake
mkdir -p build/install
cd build/cmake
cmake ../.. -DJANSSON_BUILD_DOCS=OFF \
-DJANSSON_WITHOUT_TESTS=ON \
-DCMAKE_INSTALL_PREFIX=../install
cmake --build . --target install
cd ../../..
mkdir -p build
cmake -Bbuild/cmake -S . \
-DJANSSON_BUILD_DOCS=OFF \
-DJANSSON_WITHOUT_TESTS=ON \
-DCMAKE_INSTALL_PREFIX=build/install
cmake --build build/cmake --target install


Now on to building etripator.

cd etripator
mkdir -p build/cmake
cd build/cmake
cmake ../.. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../install
mkdir -p build
cmake -Bbuild/cmake -S . -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=cmake/install


If you build jansson as shown earlier you may configure the project with

cmake ../.. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../install \
cmake -Bbuild/cmake -S . -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=build/install \
-DJANSSON_INCLUDE_DIR=../../jansson-2.12/build/install/include \
-DJANSSON_LIBRARY=../../jansson-2.12/build/install/lib/jansson.lib

* Build

If everything went right, you can now compile the project with:

cmake --build . --config Release --target install
cmake --build build/cmake --target install

¬°¤*,¸¸,*¤°¬¯¬°¤*,¸_¸,*¤°¬°¤*,¸,*¤°¬¯¬°¤*,¸_¸,*¤°¬°¤*,¸,*¤°¬¯¬°¤*,¸_¸,*¤°¬°¤*,¸
¸,*¤°¬¯¬°¤*,¸_¸,*¤°¬°¤*,¸,*¤°¬¯¬°¤*,¸_¸,*¤°¬°¤*,¸,*¤°¬¯¬°¤*,¸_¸,*¤°¬°¤*,¸,*¤°¬¯
Expand Down
66 changes: 37 additions & 29 deletions cd.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
¸,*¤°¬¯¬°¤*,¸_¸,*¤°¬°¤*,¸,*¤°¬¯¬°¤*,¸_¸,*¤°¬°¤*,¸,*¤°¬¯¬°¤*,¸_¸,*¤°¬°¤*,¸,*¤°¬¯

This file is part of Etripator,
copyright (c) 2009--2023 Vincent Cruz.
copyright (c) 2009--2024 Vincent Cruz.

Etripator is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand All @@ -36,42 +36,46 @@
#include "cd.h"
#include "message.h"

/* Adds CD RAM to memory map. */
int cd_memmap(memmap_t *map) {
int i, ret = 0;
/* Allocate CD RAM */
if(!mem_create(&map->mem[PCE_MEM_CD_RAM], 8 * 8192)) {
ERROR_MSG("Failed to allocate cd memory!\n");
memmap_destroy(map);
/// Adds CD RAM to memory map.
bool cd_memory_map(MemoryMap *map) {
int i;
bool ret = false;
// Allocate CD RAM
if(!memory_create(&map->memory[PCE_MEMORY_CD_RAM], PCE_CD_RAM_BANK_COUNT * PCE_BANK_SIZE)) {
ERROR_MSG("Failed to allocate cd memory!");
// Allocate System Card RAM
} else if (!memory_create(&map->memory[PCE_MEMORY_SYSCARD_RAM], PCE_SYSCARD_RAM_BANK_COUNT * PCE_BANK_SIZE)) {
ERROR_MSG("Failed to allocate system card memory!");
} else {
/* CD RAM is mapped to pages 0x80-0x88 (included). */
for (i = 0; i <= 8; i++) {
map->page[0x80 + i] = &map->mem[PCE_MEM_CD_RAM].data[i * 8192];
// CD RAM is mapped to pages 0x80-0x88 (included).
for (i = 0; i <= PCE_CD_RAM_BANK_COUNT; i++) {
map->page[PCE_CD_RAM_FIRST_PAGE + i].id = PCE_MEMORY_CD_RAM;
map->page[PCE_CD_RAM_FIRST_PAGE + i].bank = i;
}
/* Allocate System Card RAM */
if (!mem_create(&map->mem[PCE_MEM_SYSCARD_RAM], 24 * 8192)) {
ERROR_MSG("Failed to allocate system card memory!\n");
memmap_destroy(map);
} else {
/* System Card RAM is mapped to pages 0x68-0x86. */
for (i = 0; i < 24; i++) {
map->page[0x68 + i] = &map->mem[PCE_MEM_SYSCARD_RAM].data[i * 8192];
}
ret = 1;
// System Card RAM is mapped to pages 0x68-0x86.
for (i = 0; i < PCE_SYSCARD_RAM_BANK_COUNT; i++) {
map->page[PCE_SYSCARD_RAM_FIRST_PAGE + i].id = PCE_MEMORY_SYSCARD_RAM;
map->page[PCE_SYSCARD_RAM_FIRST_PAGE + i].bank = i;
}
ret = true;
}

if(ret == false) {
memory_map_destroy(map);
}
return ret;
}
/* Load CDROM data from file. */
int cd_load(const char* filename, size_t start, size_t len, size_t sector_size, uint8_t page, size_t offset, memmap_t* map) {
int ret = 0;

/// Load CDROM data from file.
bool cd_load(const char* filename, size_t start, size_t len, size_t sector_size, uint8_t page, size_t offset, MemoryMap* map) {
bool ret = false;
FILE *in = fopen(filename, "rb");
if(in == NULL) {
ERROR_MSG("Unable to open %s : %s", filename, strerror(errno));
} else {
size_t remaining = len;
size_t physical = (offset & 0x1FFFU) | (page << 0x0D);
for(ret=1; ret && remaining; ) {
for(ret=true; ret && remaining; ) {
size_t count = 2048 - (start % 2048);
if(count > remaining) {
count = remaining;
Expand All @@ -85,13 +89,17 @@ int cd_load(const char* filename, size_t start, size_t len, size_t sector_size,
size_t current_page = physical >> 0x0D;
size_t current_addr = physical & 0x1FFF;

ret = 0;
if(fseek(in, (long int)file_offset, SEEK_SET)) {
size_t bank_offset = current_addr + (map->page[current_page].bank * PCE_BANK_SIZE);

// [todo] test that map->page[current_page].id != PCE_MEMORY_NONE

ret = false;
if(fseek(in, (long int)file_offset, SEEK_SET) < 0) {
ERROR_MSG("Offset out of bound : %s", strerror(errno));
} else if(fread(map->page[current_page] + current_addr, 1, count, in) != count) {
} else if(fread(map->memory[map->page[current_page].id].data+bank_offset, 1, count, in) != count) {
ERROR_MSG("Failed to read %d bytes : %s", count, strerror(errno));
} else {
ret = 1;
ret = true;
}
start += count;
physical += count;
Expand Down
48 changes: 26 additions & 22 deletions cd.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
¸,*¤°¬¯¬°¤*,¸_¸,*¤°¬°¤*,¸,*¤°¬¯¬°¤*,¸_¸,*¤°¬°¤*,¸,*¤°¬¯¬°¤*,¸_¸,*¤°¬°¤*,¸,*¤°¬¯

This file is part of Etripator,
copyright (c) 2009--2023 Vincent Cruz.
copyright (c) 2009--2024 Vincent Cruz.

Etripator is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand All @@ -37,26 +37,30 @@
#define ETRIPATOR_CD_H

#include "config.h"
#include "memorymap.h"

/**
* Adds CD RAM to memory map.
* \param map Memory map.
* \return 1 upon success, 0 if an error occured.
*/
int cd_memmap(memmap_t *map);

/**
* Load CDROM data from file.
* \param [in] filename CDROM data filename.
* \param [in] start CDROM data offset.
* \param [in] len CDROM data length (in bytes).
* \param [in] sector_size CD sector size.
* \param [in] page Memory page.
* \param [in] offset memory page offset.
* \param [out] memmap Memory map.
* \return 1 upon success, 0 if an error occured.
*/
int cd_load(const char* filename, size_t start, size_t len, size_t sector_size, uint8_t page, size_t offset, memmap_t* map);
#include "memory_map.h"

#define PCE_CD_RAM_BANK_COUNT 8U
#define PCE_SYSCARD_RAM_BANK_COUNT 24U

#define PCE_CD_RAM_FIRST_PAGE 0x80U
#define PCE_SYSCARD_RAM_FIRST_PAGE 0x68U

/// Adds CD RAM to memory map.
/// \param map Memory map.
/// \return true if the CD RAM and SYSCARD RAM memory areas were successfully created.
/// \return false if an error occured.
bool cd_memory_map(MemoryMap *map);

/// Load CDROM data from file.
/// \param [in] filename CDROM data filename.
/// \param [in] start CDROM data offset.
/// \param [in] len CDROM data length (in bytes).
/// \param [in] sector_size CD sector size.
/// \param [in] page Memory page.
/// \param [in] offset Memory page offset.
/// \param [out] map Memory map.
/// \return true
/// \return false
bool cd_load(const char* filename, size_t start, size_t len, size_t sector_size, uint8_t page, size_t offset, MemoryMap* map);

#endif // ETRIPATOR_CD_H
Loading
Loading