Initial commit.
This commit is contained in:
4
re-bba-test/.gitignore
vendored
Normal file
4
re-bba-test/.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
build
|
||||
*.dol
|
||||
*.elf
|
||||
.cache
|
||||
133
re-bba-test/Makefile
Normal file
133
re-bba-test/Makefile
Normal file
@@ -0,0 +1,133 @@
|
||||
#---------------------------------------------------------------------------------
|
||||
# Clear the implicit built in rules
|
||||
#---------------------------------------------------------------------------------
|
||||
.SUFFIXES:
|
||||
#---------------------------------------------------------------------------------
|
||||
ifeq ($(strip $(DEVKITPPC)),)
|
||||
$(error "Please set DEVKITPPC in your environment. export DEVKITPPC=<path to>devkitPPC")
|
||||
endif
|
||||
|
||||
include $(DEVKITPPC)/gamecube_rules
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# TARGET is the name of the output
|
||||
# BUILD is the directory where object files & intermediate files will be placed
|
||||
# SOURCES is a list of directories containing source code
|
||||
# INCLUDES is a list of directories containing extra header files
|
||||
#---------------------------------------------------------------------------------
|
||||
TARGET := $(notdir $(CURDIR))
|
||||
BUILD := build
|
||||
SOURCES := src
|
||||
DATA := data
|
||||
INCLUDES :=
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# options for code generation
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
CFLAGS = -g -O2 -Wall $(MACHDEP) $(INCLUDE)
|
||||
CXXFLAGS = $(CFLAGS)
|
||||
|
||||
LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# any extra libraries we wish to link with the project
|
||||
#---------------------------------------------------------------------------------
|
||||
LIBS := -logc -lm
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# list of directories containing libraries, this must be the top level containing
|
||||
# include and lib
|
||||
#---------------------------------------------------------------------------------
|
||||
LIBDIRS :=
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# no real need to edit anything past this point unless you need to add additional
|
||||
# rules for different file extensions
|
||||
#---------------------------------------------------------------------------------
|
||||
ifneq ($(BUILD),$(notdir $(CURDIR)))
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
export OUTPUT := $(CURDIR)/$(TARGET)
|
||||
|
||||
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
|
||||
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
|
||||
|
||||
export DEPSDIR := $(CURDIR)/$(BUILD)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# automatically build a list of object files for our project
|
||||
#---------------------------------------------------------------------------------
|
||||
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
|
||||
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
|
||||
sFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
|
||||
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.S)))
|
||||
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# use CXX for linking C++ projects, CC for standard C
|
||||
#---------------------------------------------------------------------------------
|
||||
ifeq ($(strip $(CPPFILES)),)
|
||||
export LD := $(CC)
|
||||
else
|
||||
export LD := $(CXX)
|
||||
endif
|
||||
|
||||
export OFILES_BIN := $(addsuffix .o,$(BINFILES))
|
||||
export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(sFILES:.s=.o) $(SFILES:.S=.o)
|
||||
export OFILES := $(OFILES_BIN) $(OFILES_SOURCES)
|
||||
|
||||
export HFILES := $(addsuffix .h,$(subst .,_,$(BINFILES)))
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# build a list of include paths
|
||||
#---------------------------------------------------------------------------------
|
||||
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
|
||||
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
|
||||
-I$(CURDIR)/$(BUILD) \
|
||||
-I$(LIBOGC_INC)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# build a list of library paths
|
||||
#---------------------------------------------------------------------------------
|
||||
export LIBPATHS := -L$(LIBOGC_LIB) $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
|
||||
|
||||
export OUTPUT := $(CURDIR)/$(TARGET)
|
||||
.PHONY: $(BUILD) clean
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
$(BUILD):
|
||||
@[ -d $@ ] || mkdir -p $@
|
||||
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
clean:
|
||||
@echo clean ...
|
||||
@rm -fr $(BUILD) $(OUTPUT).elf $(OUTPUT).dol
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
else
|
||||
|
||||
DEPENDS := $(OFILES:.o=.d)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# main targets
|
||||
#---------------------------------------------------------------------------------
|
||||
$(OUTPUT).dol: $(OUTPUT).elf
|
||||
$(OUTPUT).elf: $(OFILES)
|
||||
|
||||
$(OFILES_SOURCES) : $(HFILES)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# This rule links in binary data with the .jpg extension
|
||||
#---------------------------------------------------------------------------------
|
||||
%.jpg.o %_jpg.h : %.jpg
|
||||
#---------------------------------------------------------------------------------
|
||||
@echo $(notdir $<)
|
||||
$(bin2o)
|
||||
|
||||
-include $(DEPENDS)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
endif
|
||||
#---------------------------------------------------------------------------------
|
||||
48
re-bba-test/cmake/gc-toolchain.cmake
Normal file
48
re-bba-test/cmake/gc-toolchain.cmake
Normal file
@@ -0,0 +1,48 @@
|
||||
set(CMAKE_SYSTEM_NAME Generic) # Must be "Generic" - otherwise CMake expects it in its distribution.
|
||||
set(CMAKE_SYSTEM_PROCESSOR powerpc)
|
||||
set(CMAKE_SYSTEM_VERSION 1.0)
|
||||
set(CMAKE_SYSTEM ${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_VERSION})
|
||||
|
||||
set(DevKitPro_Platform "GameCube")
|
||||
|
||||
set(DevKitPro_ABI "eabi")
|
||||
set(DevKitPro_Target "${CMAKE_SYSTEM_PROCESSOR}-${DevKitPro_ABI}")
|
||||
|
||||
if(NOT DEFINED ENV{DEVKITPRO})
|
||||
message(FATAL_ERROR "The DEVKITPRO environment variable must be defined in order to use this toolchain!")
|
||||
endif()
|
||||
|
||||
set(DevKitPro "$ENV{DEVKITPRO}")
|
||||
|
||||
set(DevKitProPPC "${DevKitPro}/devkitPPC")
|
||||
set(DevKitPro_Bin "${DevKitProPPC}/bin")
|
||||
set(DevKitPro_Tools "${DevKitProPPC}/${DevKitPro_Target}")
|
||||
|
||||
if(WIN32)
|
||||
set(BINARY_EXT ".exe")
|
||||
else()
|
||||
set(BINARY_EXT "")
|
||||
endif()
|
||||
|
||||
set(CMAKE_C_COMPILER "${DevKitPro_Bin}/${DevKitPro_Target}-gcc${BINARY_EXT}")
|
||||
set(CMAKE_CXX_COMPILER "${DevKitPro_Bin}/${DevKitPro_Target}-g++${BINARY_EXT}")
|
||||
|
||||
|
||||
foreach(LANG C CXX)
|
||||
set(CMAKE_${LANG}_FLAGS_INIT "-DGEKKO -mcpu=750 -meabi -mhard-float -mogc")
|
||||
set(CMAKE_${LANG}_STANDARD_INCLUDE_DIRECTORIES
|
||||
"${DevKitProPPC}/lib/gcc/${DevKitPro_Target}/8.3.0/include"
|
||||
"${DevKitPro_Tools}/include/c++/8.3.0"
|
||||
"${DevKitPro_Tools}/include"
|
||||
"${DevKitPro}/libogc/include"
|
||||
)
|
||||
set(CMAKE_${LANG}_STANDARD_LIBRARIES "-logc -lm")
|
||||
set(CMAKE_EXECUTABLE_SUFFIX_${LANG} ".elf")
|
||||
endforeach()
|
||||
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
|
||||
|
||||
set(CMAKE_EXE_LINKER_FLAGS "-L${DevKitPro_Tools}/lib -L${DevKitPro}/libogc/lib/cube")
|
||||
7
re-bba-test/compile_commands.json
Normal file
7
re-bba-test/compile_commands.json
Normal file
@@ -0,0 +1,7 @@
|
||||
[
|
||||
{
|
||||
"directory": "F:/projects/re-bba-rb/re-bba-test",
|
||||
"command": "F:/devkitpro/devkitPPC/bin/powerpc-eabi-gcc.exe -isystem F:/devkitpro/devkitPPC/lib/gcc/powerpc-eabi/8.3.0/include -isystem F:/devkitpro/devkitPPC/powerpc-eabi/include/c++/8.3.0 -isystem F:/devkitpro/devkitPPC/powerpc-eabi/include -isystem F:/devkitpro/libogc/include -DGEKKO -mcpu=750 -meabi -mhard-float -mogc -o CMakeFiles/re-bba-test.dir/src/main.c.obj -c F:/projects/re-bba-rb/re-bba-test/src/main.c",
|
||||
"file": "F:/projects/re-bba-rb/re-bba-test/src/main.c"
|
||||
}
|
||||
]
|
||||
99
re-bba-test/src/main.c
Normal file
99
re-bba-test/src/main.c
Normal file
@@ -0,0 +1,99 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <malloc.h>
|
||||
#include <ogcsys.h>
|
||||
#include <gccore.h>
|
||||
|
||||
static void *xfb = NULL;
|
||||
static GXRModeObj *rmode = NULL;
|
||||
|
||||
void* initialise();
|
||||
int test_bba_get_id();
|
||||
|
||||
#define EXI_BBA_ID 0x04020200
|
||||
|
||||
#define OK 0
|
||||
#define NOK -1
|
||||
|
||||
typedef int(*test_f)(void);
|
||||
|
||||
typedef enum {
|
||||
Ok = OK,
|
||||
ExiGetIdFailed,
|
||||
Nok = NOK,
|
||||
} error_code_t;
|
||||
|
||||
typedef struct {
|
||||
test_f test;
|
||||
char test_name[32];
|
||||
} test_entry_t;
|
||||
|
||||
#define TEST_ENTRY(name) { (name), #name }
|
||||
|
||||
test_entry_t tests[1] = {
|
||||
TEST_ENTRY(test_bba_get_id)
|
||||
};
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
xfb = initialise();
|
||||
|
||||
printf("\nHello World!\n");
|
||||
|
||||
int current_test = 0;
|
||||
int nr_tests = sizeof(tests) / sizeof(tests[0]);
|
||||
|
||||
while(1) {
|
||||
|
||||
VIDEO_WaitVSync();
|
||||
PAD_ScanPads();
|
||||
|
||||
int buttonsDown = PAD_ButtonsDown(0);
|
||||
|
||||
if( buttonsDown & PAD_BUTTON_A ) {
|
||||
printf("Button A pressed.\n");
|
||||
}
|
||||
|
||||
if (buttonsDown & PAD_BUTTON_START) {
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if(current_test < nr_tests) {
|
||||
test_entry_t t = tests[current_test++];
|
||||
int result = t.test();
|
||||
printf("Test: %s Result %s", t.test_name, result == OK ? "OK" : "NOK");
|
||||
current_test++;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void * initialise() {
|
||||
void *framebuffer;
|
||||
|
||||
VIDEO_Init();
|
||||
PAD_Init();
|
||||
|
||||
rmode = VIDEO_GetPreferredMode(NULL);
|
||||
|
||||
framebuffer = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode));
|
||||
console_init(framebuffer,20,20,rmode->fbWidth,rmode->xfbHeight,rmode->fbWidth*VI_DISPLAY_PIX_SZ);
|
||||
|
||||
VIDEO_Configure(rmode);
|
||||
VIDEO_SetNextFramebuffer(framebuffer);
|
||||
VIDEO_SetBlack(FALSE);
|
||||
VIDEO_Flush();
|
||||
VIDEO_WaitVSync();
|
||||
if(rmode->viTVMode&VI_NON_INTERLACE) VIDEO_WaitVSync();
|
||||
|
||||
return framebuffer;
|
||||
}
|
||||
|
||||
error_code_t test_bba_get_id() {
|
||||
|
||||
u32 exi_id = 0;
|
||||
EXI_GetID(EXI_CHANNEL_0, EXI_DEVICE_2, &exi_id);
|
||||
return exi_id == EXI_BBA_ID ? Ok : ExiGetIdFailed;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user