Skip to content

Commit

Permalink
make translate & patchrom can inject the english game with translations
Browse files Browse the repository at this point in the history
  • Loading branch information
andwn committed Sep 8, 2020
1 parent fe54804 commit b4d4345
Show file tree
Hide file tree
Showing 18 changed files with 1,867 additions and 71 deletions.
6 changes: 3 additions & 3 deletions .github/CONTRIBUTING.md
Expand Up @@ -8,8 +8,8 @@ Here are some things I've been asked how to contribute and a brief explanation o
The sound driver used is XGM from SGDK. The only real restrictions for this are:

- The file must be a VGM, created in Deflemask or similar
- The channel FM6 must always be set to DAC mode (or you'll kill sound effects)
- The file should be a reasonable size (depends on how many WAV samples are needed)
- The channel FM6 must always be set to DAC mode (effect 1701)
- The file should be a reasonable size (keep samples to a minimum)

Also, please provide the source tracker file if possible.

Expand All @@ -30,7 +30,7 @@ Getting it into the game gets more complicated based on
- The glyphs that need to be rendered in the game
- European/Latin languages should be pretty much covered
- For Chinese and Korean I can redo the same thing I did with Japanese (just with different encodings)
- A font for Russian/Ukranian/Bulgarian is in progress
- There's like half a font for Russian/Ukrainian/Bulgarian at the moment
- I have no idea what to do for RTL languages
- My level of burnout

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -9,6 +9,7 @@ out.lst
*.tsb
*.pcm
*.xgc
*.patch
*.o
inc/ai_gen.h
res/resources.h
Expand Down
66 changes: 46 additions & 20 deletions Makefile
Expand Up @@ -2,6 +2,8 @@ MARSDEV ?= ${HOME}/mars
MARSBIN = $(MARSDEV)/m68k-elf/bin
TOOLSBIN = $(MARSDEV)/bin

TARGET = doukutsu

CC = $(MARSBIN)/m68k-elf-gcc
AS = $(MARSBIN)/m68k-elf-as
LD = $(MARSBIN)/m68k-elf-ld
Expand All @@ -21,6 +23,7 @@ SLZ = $(TOOLSBIN)/slz
UFTC = $(TOOLSBIN)/uftc
# Cave Story Tools
TSCOMP = bin/tscomp
PATCHROM = bin/patchrom

# Some files needed are in a versioned directory
GCC_VER := $(shell $(CC) -dumpversion)
Expand Down Expand Up @@ -48,6 +51,11 @@ TSCS = $(wildcard res/tsc/en/*.txt)
TSCS += $(wildcard res/tsc/en/Stage/*.txt)
TSBS = $(TSCS:.txt=.tsb)

# TSBs for translations
TL_TSCS = $(wildcard res/tsc/*/*.txt)
TL_TSCS += $(wildcard res/tsc/*/Stage/*.txt)
TL_TSBS = $(TL_TSCS:.txt=.tsb)

# mdtiler scripts to generate tile patterns & mappings
MDTS = $(wildcard res/*.mdt)
MDTS += $(wildcard res/*/*.mdt)
Expand All @@ -63,14 +71,12 @@ WAVS = $(wildcard res/sfx/*.wav)
PCMS = $(WAVS:.wav=.pcm)

RESS = res/resources.res
#Z80S = $(wildcard src/xgm/*.s80)
CS = $(wildcard src/*.c)
CS += $(wildcard src/ai/*.c)
CS += $(wildcard src/db/*.c)
SS = $(wildcard src/*.s)
SS += $(wildcard src/xgm/*.s)
OBJS = $(RESS:.res=.o)
#OBJS += $(Z80S:.s80=.o)
OBJS += $(CS:.c=.o)
OBJS += $(SS:.s=.o)

Expand All @@ -82,9 +88,9 @@ ASMO = $(RESS:.res=.o)
ASMO += $(Z80S:.s80=.o)
ASMO += $(CS:%.c=asmout/%.s)

.SECONDARY: doukutsu.elf
.SECONDARY: $(TARGET)-en.elf

.PHONY: all pal sega release asm debug prereq main-build
.PHONY: all pal sega release asm debug translate prereq main-build

all: release
pal: release
Expand All @@ -104,19 +110,23 @@ asm: prereq head-gen asm-dir $(PATS) $(ASMO)
debug: OPTIONS = -g -Og -DDEBUG -DKDEBUG
debug: main-build symbol.txt

main-build: prereq head-gen doukutsu.bin
translate: $(PATCHROM) $(TL_TSBS)
translate: $(TARGET)-es.bin $(TARGET)-fr.bin $(TARGET)-de.bin $(TARGET)-it.bin
translate: $(TARGET)-pt.bin $(TARGET)-br.bin $(TARGET)-ja.bin

main-build: prereq head-gen $(TARGET)-en.bin

prereq: $(BINTOS) $(RESCOMP) $(XGMTOOL) $(WAVTORAW) $(TSCOMP)
prereq: $(CPXMS) $(XGCS) $(PCMS) $(ZOBJ) $(TSBS)

# Cross reference symbol.txt with the addresses displayed in the crash handler
symbol.txt: doukutsu.bin
$(NM) --plugin=$(PLUGIN)/$(LTO_SO) -n doukutsu.elf > symbol.txt
symbol.txt: $(TARGET)-en.bin
$(NM) --plugin=$(PLUGIN)/$(LTO_SO) -n $(TARGET)-en.elf > symbol.txt

boot.o:
$(AS) $(ASFLAGS) boot.s -o $@

%.bin: %.elf
$(TARGET)-en.bin: $(TARGET)-en.elf
@echo "Stripping ELF header, pad to 512K"
@$(OBJC) -O binary $< temp.bin
@dd if=temp.bin of=$@ bs=524288 conv=sync
Expand All @@ -139,9 +149,6 @@ boot.o:
%.o80: %.s80
$(ASMZ80) $(Z80FLAGS) $< $@ out.lst

#%.s: %.o80
# $(BINTOS) $<

# Old SGDK tools
bin:
mkdir -p bin
Expand All @@ -162,6 +169,9 @@ $(WAVTORAW): bin
$(TSCOMP): bin
cc tools/tscomp/tscomp.c -o $@

$(PATCHROM): bin
cc tools/patchrom/patchrom.c -o $@

# For asm target
asm-dir:
mkdir -p asmout/src/{ai,db,xgm}
Expand All @@ -187,28 +197,43 @@ asmout/%.s: %.c
# Convert TSC
res/tsc/en/%.tsb: res/tsc/en/%.txt
$(TSCOMP) -l=en "$<"

res/tsc/ja/%.tsb: res/tsc/ja/%.txt
$(TSCOMP) -l=ja "$<"

res/tsc/es/%.tsb: res/tsc/es/%.txt
$(TSCOMP) -l=es "$<"

res/tsc/pt/%.tsb: res/tsc/pt/%.txt
$(TSCOMP) -l=pt "$<"

res/tsc/fr/%.tsb: res/tsc/fr/%.txt
$(TSCOMP) -l=fr "$<"

res/tsc/it/%.tsb: res/tsc/it/%.txt
$(TSCOMP) -l=it "$<"

res/tsc/de/%.tsb: res/tsc/de/%.txt
$(TSCOMP) -l=de "$<"

res/tsc/br/%.tsb: res/tsc/br/%.txt
$(TSCOMP) -l=br "$<"

# Generate patches
res/patches/$(TARGET)-%.patch: res/patches/$(TARGET)-%.s
$(AS) $(ASFLAGS) "$<" -o "temp.o"
$(LD) $(LDFLAGS) "temp.o" -o "temp.elf"
$(OBJC) -O binary "temp.elf" "$@"

# Apply patches
$(TARGET)-ja.bin: res/patches/$(TARGET)-ja.patch
$(PATCHROM) $(TARGET)-en.bin "$<" "$@"
$(TARGET)-es.bin: res/patches/$(TARGET)-es.patch
$(PATCHROM) $(TARGET)-en.bin "$<" "$@"
$(TARGET)-fr.bin: res/patches/$(TARGET)-fr.patch
$(PATCHROM) $(TARGET)-en.bin "$<" "$@"
$(TARGET)-de.bin: res/patches/$(TARGET)-de.patch
$(PATCHROM) $(TARGET)-en.bin "$<" "$@"
$(TARGET)-it.bin: res/patches/$(TARGET)-it.patch
$(PATCHROM) $(TARGET)-en.bin "$<" "$@"
$(TARGET)-pt.bin: res/patches/$(TARGET)-pt.patch
$(PATCHROM) $(TARGET)-en.bin "$<" "$@"
$(TARGET)-br.bin: res/patches/$(TARGET)-br.patch
$(PATCHROM) $(TARGET)-en.bin "$<" "$@"


.PHONY: head-gen clean

Expand All @@ -218,8 +243,9 @@ head-gen:

clean:
rm -f $(CPXMS) $(XGCS) $(PCMS) $(PATS) $(MAPS) $(ZOBJ) $(OBJS)
rm -f $(TSBS)
rm -f doukutsu.bin doukutsu.elf symbol.txt boot.o
rm -f $(TSBS) $(TL_TSBS)
rm -f $(TARGET)-*.bin $(TARGET)-en.elf symbol.txt boot.o temp.elf temp.o
rm -f res/patches/*.patch
rm -f src/xgm/z80_xgm.s src/xgm/z80_xgm.o80 src/xgm/z80_xgm.h out.lst
rm -f res/resources.h res/resources.s inc/ai_gen.h
rm -rf asmout
46 changes: 23 additions & 23 deletions doc/COMPATIBILITY.md
Expand Up @@ -6,33 +6,33 @@ All Mega Drive and Genesis consoles manufactured by Sega should work 100%.
Of course this depends on your flash cart, or whatever you burn the ROM to.

### Flash Carts
| Name | Startup | Beatable | Saving | Multilang | Notes |
| ------------------------ | -------- | -------- | -------- | --------- | -------------------------------- |
| Mega Everdrive X3/5/7/Pro| Yes | Yes | Yes | Yes | |
| Everdrive MD | Yes | Yes | Yes | ??? | |
| RetroStage 32MB Cart | Yes | Yes | Yes | Yes\* | Need firmware update |
| UMDKv2 | Yes | Yes | ??? | ??? | Occasional pixel color corruption |
| Oerg's Cart | ??? | ??? | ??? | ??? | Untested, probably works |
| Name | Startup | Beatable | Saving | Notes |
| ------------------------ | -------- | -------- | -------- | -------------------------------- |
| Mega Everdrive X3/5/7/Pro| Yes | Yes | Yes | |
| Everdrive MD | Yes | Yes | Yes | |
| RetroStage 32MB Cart | Yes | Yes | Yes | Need firmware update |
| UMDKv2 | Yes | Yes | ??? | Occasional pixel color corruption |
| Oerg's Cart | ??? | ??? | ??? | Untested, probably works |

### Emulator/FPGA in a Box
| Name | Startup | Beatable | Saving | Multilang | Notes |
| ------------------------ | -------- | -------- | -------- | --------- | -------------------------------- |
| Sega Mega Drive Mini | Yes | Yes | Yes | ??? | With Project Lunar |
| Atgames Consoles | ??? | ??? | ??? | ??? | Untested, probably sounds bad |
| Name | Startup | Beatable | Saving | Notes |
| ------------------------ | -------- | -------- | -------- | -------------------------------- |
| Sega Mega Drive Mini | Yes | Yes | Yes | With Project Lunar |
| Atgames Consoles | ??? | ??? | ??? | Untested, probably sounds bad |

### Emulators
| Name | Startup | Beatable | Saving | Multilang | Notes |
| ------------------------ | -------- | -------- | -------- | --------- | -------------------------------- |
| BlastEm | Yes | Yes | Yes | Yes | Most tested and supported |
| Kega Fusion | Yes | Yes | Yes | ??? | |
| Genesis Plus GX | Yes\* | Yes | Yes | ??? | Outdated versions will crash |
| PicoDrive | Yes\* | Yes | Yes | ??? | Outdated versions will crash |
| Gens GS | Yes | Yes | Yes | ??? | A couple instruments sound funky |
| Regen | Yes | Yes | No | ??? | |
| Higan core | ??? | ??? | ??? | ??? | Untested, probably works |
| Exodus | ??? | ??? | ??? | ??? | Untested |
| Dgen | ??? | ??? | ??? | ??? | Untested |
| sega(1) | ??? | ??? | ??? | ??? | Untested |
| Name | Startup | Beatable | Saving | Notes |
| ------------------------ | -------- | -------- | -------- | -------------------------------- |
| BlastEm | Yes | Yes | Yes | Most tested |
| Kega Fusion | Yes | Yes | Yes | |
| Genesis Plus GX | Yes\* | Yes | Yes | Outdated downstream emulators may crash |
| PicoDrive | Yes\* | Yes | Yes | Outdated downstream emulators may crash |
| Gens GS | Yes | Yes | Yes | A couple instruments sound funky |
| Regen | Yes | Yes | No | |
| Higan core | ??? | ??? | ??? | Untested, probably works |
| Exodus | ??? | ??? | ??? | Untested |
| Dgen | ??? | ??? | ??? | Untested |
| sega(1) | ??? | ??? | ??? | Untested |

### Note About SRAM
CSMD writes 8KB of SRAM mapped at 0x200000 using odd bytes.
Expand Down
23 changes: 10 additions & 13 deletions doc/FAQ.md
Expand Up @@ -7,28 +7,27 @@ Take a look at one of [these walkthroughs](https://www.cavestory.org/guides-and-

### The game feels slow
The Nicalis ports run faster, you're probably used to those.
Enable the "CS+ Speed (NTSC Only)" setting in the config menu for something similar.
Enable the "CS+ Speed" setting in the config menu for something similar.

### The save disks are missing. What's going on?
Your cart or emulator does not support the type of SRAM used by the game.
SRAM is malfunctioning, or not emulated properly.
Check [COMPATIBILITY.md](COMPATIBILITY.md) for a list of tested carts and emulators.

### I found something inaccurate
Because this is a "port", the moment someone finds out about it they hyper-focus on
finding discrepancies with the original game.
In the past, I would entertain issues that people opened about these, but things
really got out of hand. I ended up with a 3 digit issue tab full of minor differences
and often duplicate posts. It burned me out big time resulting in a pretty long hiatus.
I'm no longer interested in issues like this.
If your main concern is accuracy, don't play CSMD. Check out CSE2, or even the original.

These days I'm not interested in issues like these. Please do not open them.
If you are concerned about accuracy, look at CSE2, or just play the original.
In the past I did accept and fix issues that people opened about discrepancies with the
original Cave Story, but this resulted in a 3 digit issue tab full of minor differences
and often duplicate posts. It burned me out big time resulting in a pretty long hiatus.

### I found a bug in an old version
If you can't reproduce in the latest release, please don't report it.
If you can't reproduce in the latest release, don't report it.
The save data for version 0.5.0 onwards are all compatible with each other.

### Can you add new languages and game modes?

I may add your language if you have a translated PC version available,
but no more feature requests. I want to release 1.0 and be done.


## General Questions
Expand All @@ -52,8 +51,6 @@ No.
Feel free to make carts for yourself or friends, but don't sell them.

### Is this moddable?
Yes, but

![you're gonna have a bad time.](badtime.png)

### Can I use your code in my commercial game?
Expand Down

0 comments on commit b4d4345

Please sign in to comment.