Compare commits

...

2 Commits

Author SHA1 Message Date
2ff32c0ac8
Stuff 2019-01-19 22:02:35 +01:00
5fae86a662
Build DaMaGe-Emulator Boot ROM 2019-01-09 19:54:01 +01:00
8 changed files with 249 additions and 27 deletions

BIN
BootROMs/DamageLogo.1bpp Normal file

Binary file not shown.

View File

@ -549,7 +549,8 @@ TrademarkSymbol:
db $3c,$42,$b9,$a5,$b9,$a5,$42,$3c db $3c,$42,$b9,$a5,$b9,$a5,$42,$3c
SameboyLogo: SameboyLogo:
incbin "SameboyLogo.1bpp" ; incbin "SameboyLogo.1bpp"
incbin "DamageLogo.1bpp"
SameboyLogoEnd: SameboyLogoEnd:
AnimationColors: AnimationColors:

View File

@ -91,7 +91,11 @@ Start:
call WaitBFrames call WaitBFrames
; Set registers to match the original DMG boot ; Set registers to match the original DMG boot
IF DEF(MGB)
ld hl, $FFB0
ELSE
ld hl, $01B0 ld hl, $01B0
ENDC
push hl push hl
pop af pop af
ld hl, $014D ld hl, $014D

2
BootROMs/mgb_boot.asm Normal file
View File

@ -0,0 +1,2 @@
MGB EQU 1
include "dmg_boot.asm"

View File

@ -106,9 +106,9 @@ endif
cocoa: $(BIN)/SameBoy.app cocoa: $(BIN)/SameBoy.app
quicklook: $(BIN)/SameBoy.qlgenerator quicklook: $(BIN)/SameBoy.qlgenerator
sdl: $(SDL_TARGET) $(BIN)/SDL/dmg_boot.bin $(BIN)/SDL/cgb_boot.bin $(BIN)/SDL/agb_boot.bin $(BIN)/SDL/sgb_boot.bin $(BIN)/SDL/sgb2_boot.bin $(BIN)/SDL/LICENSE $(BIN)/SDL/registers.sym $(BIN)/SDL/background.bmp $(BIN)/SDL/Shaders sdl: $(SDL_TARGET) $(BIN)/SDL/dmg_boot.bin $(BIN)/SDL/mgb_boot.bin $(BIN)/SDL/cgb_boot.bin $(BIN)/SDL/cgb_boot_fast.bin $(BIN)/SDL/agb_boot.bin $(BIN)/SDL/sgb_boot.bin $(BIN)/SDL/sgb2_boot.bin $(BIN)/SDL/LICENSE $(BIN)/SDL/registers.sym $(BIN)/SDL/background.bmp $(BIN)/SDL/Shaders
bootroms: $(BIN)/BootROMs/agb_boot.bin $(BIN)/BootROMs/cgb_boot.bin $(BIN)/BootROMs/dmg_boot.bin $(BIN)/BootROMs/sgb_boot.bin $(BIN)/BootROMs/sgb2_boot.bin bootroms: $(BIN)/BootROMs/agb_boot.bin $(BIN)/BootROMs/cgb_boot.bin $(BIN)/BootROMs/cgb_boot_fast.bin $(BIN)/BootROMs/dmg_boot.bin $(BIN)/BootROMs/mgb_boot.bin $(BIN)/BootROMs/sgb_boot.bin $(BIN)/BootROMs/sgb2_boot.bin
tester: $(TESTER_TARGET) $(BIN)/tester/dmg_boot.bin $(BIN)/tester/cgb_boot.bin $(BIN)/tester/agb_boot.bin $(BIN)/tester/sgb_boot.bin $(BIN)/tester/sgb2_boot.bin tester: $(TESTER_TARGET) $(BIN)/tester/dmg_boot.bin $(BIN)/tester/mgb_boot.bin $(BIN)/tester/cgb_boot.bin $(BIN)/tester/cgb_boot_fast.bin $(BIN)/tester/agb_boot.bin $(BIN)/tester/sgb_boot.bin $(BIN)/tester/sgb2_boot.bin
all: cocoa sdl tester libretro all: cocoa sdl tester libretro
# Get a list of our source files and their respective object file targets # Get a list of our source files and their respective object file targets
@ -178,7 +178,9 @@ $(BIN)/SameBoy.app: $(BIN)/SameBoy.app/Contents/MacOS/SameBoy \
Cocoa/Info.plist \ Cocoa/Info.plist \
Misc/registers.sym \ Misc/registers.sym \
$(BIN)/SameBoy.app/Contents/Resources/dmg_boot.bin \ $(BIN)/SameBoy.app/Contents/Resources/dmg_boot.bin \
$(BIN)/SameBoy.app/Contents/Resources/mgb_boot.bin \
$(BIN)/SameBoy.app/Contents/Resources/cgb_boot.bin \ $(BIN)/SameBoy.app/Contents/Resources/cgb_boot.bin \
$(BIN)/SameBoy.app/Contents/Resources/cgb_boot_fast.bin \
$(BIN)/SameBoy.app/Contents/Resources/agb_boot.bin \ $(BIN)/SameBoy.app/Contents/Resources/agb_boot.bin \
$(BIN)/SameBoy.app/Contents/Resources/sgb_boot.bin \ $(BIN)/SameBoy.app/Contents/Resources/sgb_boot.bin \
$(BIN)/SameBoy.app/Contents/Resources/sgb2_boot.bin \ $(BIN)/SameBoy.app/Contents/Resources/sgb2_boot.bin \
@ -309,7 +311,7 @@ $(BIN)/BootROMs/%.bin: BootROMs/%.asm
-@$(MKDIR) -p $(dir $@) -@$(MKDIR) -p $(dir $@)
cd BootROMs && rgbasm -o ../$@.tmp ../$< cd BootROMs && rgbasm -o ../$@.tmp ../$<
rgblink -o $@.tmp2 $@.tmp rgblink -o $@.tmp2 $@.tmp
head -c $(if $(findstring dmg,$@)$(findstring sgb,$@), 256, 2304) $@.tmp2 > $@ head -c $(if $(findstring dmg,$@)$(findstring sgb,$@)$(findstring mgb,$@), 256, 2304) $@.tmp2 > $@
@rm $@.tmp $@.tmp2 @rm $@.tmp $@.tmp2
# Libretro Core (uses its own build system) # Libretro Core (uses its own build system)

View File

@ -8,8 +8,11 @@ endif
CFLAGS += -DSAMEBOY_CORE_VERSION=\"$(VERSION)\" CFLAGS += -DSAMEBOY_CORE_VERSION=\"$(VERSION)\"
platform=ctr
ifeq ($(platform),) ifeq ($(platform),)
platform = unix platform = unix
ifeq ($(shell uname -a),) ifeq ($(shell uname -a),)
platform = win platform = win
else ifneq ($(findstring MINGW,$(shell uname -a)),) else ifneq ($(findstring MINGW,$(shell uname -a)),)
@ -94,6 +97,18 @@ else ifeq ($(platform), wiiu)
CFLAGS += -DGEKKO -DHW_RVL -DWIIU -mwup -mcpu=750 -meabi -mhard-float -D__ppc__ -DMSB_FIRST -I$(DEVKITPRO)/libogc/include CFLAGS += -DGEKKO -DHW_RVL -DWIIU -mwup -mcpu=750 -meabi -mhard-float -D__ppc__ -DMSB_FIRST -I$(DEVKITPRO)/libogc/include
CFLAGS += -U__INT32_TYPE__ -U __UINT32_TYPE__ -D__INT32_TYPE__=int CFLAGS += -U__INT32_TYPE__ -U __UINT32_TYPE__ -D__INT32_TYPE__=int
STATIC_LINKING = 1 STATIC_LINKING = 1
# CTR(3DS)
else ifeq ($(platform), ctr)
TARGET := $(TARGET_NAME)_libretro_$(platform).a
CC = $(DEVKITARM)/bin/arm-none-eabi-gcc$(EXE_EXT)
AR = $(DEVKITARM)/bin/arm-none-eabi-ar$(EXE_EXT)
CFLAGS += -DARM11 -D_3DS
CFLAGS += -march=armv6k -mtune=mpcore -mfloat-abi=hard
CFLAGS += -Wall -mword-relocations
CFLAGS += -fomit-frame-pointer -ffast-math
CFLAGS += -I$(CTRULIB)/include
CFLAGS += -std=c99 -DUSE_VFS_3DS
STATIC_LINKING = 1
else ifneq (,$(findstring osx,$(platform))) else ifneq (,$(findstring osx,$(platform)))
TARGET := $(TARGET_NAME)_libretro.dylib TARGET := $(TARGET_NAME)_libretro.dylib
fpic := -fPIC fpic := -fPIC
@ -178,10 +193,13 @@ $(CORE_DIR)/build/bin/BootROMs/%_boot.bin:
$(MAKE) -C $(CORE_DIR) $(patsubst $(CORE_DIR)/%,%,$@) $(MAKE) -C $(CORE_DIR) $(patsubst $(CORE_DIR)/%,%,$@)
$(TARGET): $(OBJECTS) $(TARGET): $(OBJECTS)
@echo "** BUILDING $(TARGET) FOR PLATFORM $(platform) **"
-@$(MKDIR) -p $(dir $@) -@$(MKDIR) -p $(dir $@)
ifeq ($(STATIC_LINKING), 1) ifeq ($(STATIC_LINKING), 1)
echo $(AR) rcs $@ $(OBJECTS)
$(AR) rcs $@ $(OBJECTS) $(AR) rcs $@ $(OBJECTS)
else else
echo $(CC) $(fpic) $(SHARED) $(INCFLAGS) -o $@ $(OBJECTS) $(LDFLAGS)
$(CC) $(fpic) $(SHARED) $(INCFLAGS) -o $@ $(OBJECTS) $(LDFLAGS) $(CC) $(fpic) $(SHARED) $(INCFLAGS) -o $@ $(OBJECTS) $(LDFLAGS)
endif endif

188
test.pl Executable file
View File

@ -0,0 +1,188 @@
#!/usr/bin/perl
# This script parses Git blame's "porcelain" output format and
# ascertains the oldest lines of code seen.
#
# If you want to perform a custom report, just define your own callback
# function and invoke parse_porcelain() with it.
#
# The expected input format is slightly modified from raw `git blame
# -p`. Here is an example script for producing input:
#
# for f in `git ls-tree -r --name-only HEAD`; do \
# echo "BEGIN_RECORD $f"; \
# git blame -l -t -M -C -n -w -p $f; \
# echo "END_RECORD $f"; \
# done
use strict;
use warnings FATAL => "all";
use POSIX qw(strftime);
our @STATES = qw(global header_first header_metadata);
our $RE_BEGIN_RECORD = qr/^BEGIN_RECORD\s(.*)$/msx;
our $RE_END_RECORD = qr/^END_RECORD\s(.*)$/msx;
our $RE_LINE_HEADER = qr/
^
([a-z0-9]{40}) # SHA
\s(\d+) # Original line number
\s(\d+) # Current line number
(?:\s(\d+))? # Number of lines in group (optional)
$/msx;
our $RE_HEADER_METADATA = qr/^([a-z-]+)\s(.*)$/msx;
our $RE_LINE_DATA = qr/^\t(.*)$/msx;
# Parses Git blame's porcelain output.
# Calls the supplied $onBlock callback function when a full block of
# code has been parsed. The function receives a hashref describing the
# block.
sub parse_porcelain {
my ($fh, $onBlock) = @_;
my $state = "global";
my $metadata = {};
my @lines;
my ($commit, $original_line, $current_line);
my $current_file;
my $callOnBlock = sub {
my $data = {};
$data->{'filename'} = $current_file;
$data->{'lines'} = \@lines;
$data->{'metadata'} = $metadata;
$data->{'commit'} = $commit;
&$onBlock($data);
@lines = ();
};
while (my $line = <$fh>) {
chomp $line;
if ($line =~ $RE_BEGIN_RECORD) {
$state eq "global" or die "Parser error. Unexpected BEGIN_RECORD.";
$current_file = $1;
$state = "header_first";
next;
}
elsif ($line =~ $RE_END_RECORD) {
$1 eq $current_file or die "Parser error. END_RECORD mismatch!";
if ($onBlock and scalar(@lines)) {
&$callOnBlock();
}
$state = "global";
next;
}
if ($state eq "header_first") {
$line =~ $RE_LINE_HEADER or die "Invalid initial header line! $line";
my ($new_commit, $new_original_line, $new_current_line, $block_count);
($new_commit, $new_original_line, $new_current_line, $block_count) = ($1, $2, $3, $4);
if ($block_count and $onBlock and scalar(@lines)) {
&$callOnBlock();
}
$commit = $new_commit;
$original_line = $new_original_line;
$current_line = $new_current_line;
$state = "header_metadata";
next;
}
if ($state eq "header_metadata") {
# Lines beginning with a tab denote line content. Subsequent line(s)
# will be metadata for that line.
if ($line =~ $RE_LINE_DATA) {
my $content = $1;
push @lines, [$content, $original_line, $current_line];
$state = "header_first";
next;
}
next if $line eq "boundary";
$line =~ $RE_HEADER_METADATA or die "Could not parse header metadata.";
my ($k, $v) = ($1, $2);
$metadata->{$k} = $v;
next;
}
die "Unknown state!";
}
}
# onBlock callback that collects oldest commit times for blocks.
my $old_lines = {};
sub collect_times {
my ($data) = @_;
# We filter non-relevant lines.
my $have_content = 0;
foreach my $line (@{$data->{'lines'}}) {
my $s = $line->[0];
# Skip empty and whitespace.
next if $s =~ m/^\s*$/;
# Skip things looking like comments.
next if $s =~ m/^\s*(#|\/\/|\/\*|\*\/)/;
if ($s =~ m/[a-z0-9]/) {
$have_content = 1;
last;
}
}
if (!$have_content) {
return;
}
my $time = $data->{'metadata'}->{'committer-time'};
my $metadata = {};
$metadata->{'commit'} = $data->{'commit'};
$metadata->{'author'} = $data->{'metadata'}->{'author'};
$metadata->{'filename'} = $data->{'filename'};
$metadata->{'lines'} = [];
foreach my $line (@{$data->{'lines'}}) {
push @{$metadata->{'lines'}}, $line->[2];
}
push @{$old_lines->{$time}}, $metadata;
}
sub print_oldest_blocks {
my ($times) = @_;
foreach my $time (sort { $a <=> $b } keys %$times) {
my $blocks = $times->{$time};
my $date = strftime("%Y-%m-%d %H:%M:%S", gmtime($time));
print "Time: $time ($date)\n";
foreach my $data (@$blocks) {
print " Commit: " . $data->{'commit'} . "\n";
print " Author: " . $data->{'author'} . "\n";
print " Filename: " . $data->{'filename'} . "\n";
print " Lines: " . join(', ', @{$data->{'lines'}}) . "\n";
}
}
}
parse_porcelain(*STDIN, \&collect_times);
print_oldest_blocks($old_lines);

7
test.sh Executable file
View File

@ -0,0 +1,7 @@
#!/bin/sh
for f in `git ls-tree -r --name-only HEAD`; do \
echo "BEGIN_RECORD $f"; \
git blame -l -t -M -C -n -w -p "$f"; \
echo "END_RECORD $f"; \
done | ./test.pl