sm64pc / sm64ex

Fork of https://github.com/sm64-port/sm64-port with additional features.
1.58k stars 487 forks source link

e2k: assembling `00_sound_player.s` fails with `unsupported relocation size: 1` #473

Open DJs3000 opened 3 years ago

DJs3000 commented 3 years ago

Is it possible not to use assembler? There is some assembly code in the project, can it be transferred to C/C++?

fgsfdsfgs commented 3 years ago

Any actual assembler code (such as in the boot directory) is leftovers from the N64 decomp and is unused. GNU Assembler is also used to make blobs of data, such as sequence banks. This does not affect portability.

DJs3000 commented 3 years ago

The problem is that I want to run a project on an exotic e2k architecture and assembly commands are not available to me.

krux02 commented 3 years ago

If you have trouble porting, can you please be precise about the what sections you are struggling with? Inline assemble is AFIK still the way to go for blobs of data in C, for the lack of a better language feature.

fgsfdsfgs commented 3 years ago

There's no actual assembly instructions used, only .byte and the like. If e2k has GNU as available (or something that supports the same macro syntax), it should not be a problem. The game has been ported to various ARM platforms and that caused no problem there either. If you actually have no assembler program available at all, then you'll have to either build the game for an architecture with the same endianness and copy over 00_sound_player.m64, or write a script that parses these files and produces a binary blob.

DJs3000 commented 2 years ago

I can give ssh access to build sm64ex. Write to me at djs500@mail.ru or give your contact.

DJs3000 commented 2 years ago

error in file sound/sequences/00_sound_player.s

fgsfdsfgs commented 2 years ago

Please post the full error message.

DJs3000 commented 2 years ago

image

DJs3000 commented 2 years ago

sound/sequences/00_sound_player.s:7968: Error: unsupported relocation size 1 sound/sequences/00_sound_player.s:7968: Error: unsupported relocation size 1 make: *** [Makefile:1043: build/us_pc/sound/sequences/00_sound_player.o] Error 1 rm build/us_pc/bin/ccm_skybox.c build/us_pc/bin/bitfs_skybox.c build/us_pc/bin/bbh_skybox.c build/us_pc/bin/wdw_skybox.c build/us_pc/bin/water_skybox.c build/us_pc/bin/bits_skybox.c build/us_pc/bin/clouds_skybox.c build/us_pc/bin/ssl_skybox.c build/us_pc/bin/cloud_floor_skybox.c build/us_pc/bin/bidw_skybox.c

fgsfdsfgs commented 2 years ago

Huh. I guess it says that for every .byte directive. Not sure why it would do that and I'm not sure how to fix it. It's possible to rig a build to use a precompiled 00_sound_player.m64, provided one was compiled on a platform with the same endianness, but that's not really a proper solution. Can you run as --version and post what it says? Also try to find the first error in the log.

DJs3000 commented 2 years ago

e2k - Little Endian

lscpu

Architecture: e2k Byte Order: Little Endian CPU(s): 8 On-line CPU(s) list: 0-7 Thread(s) per core: 1 Core(s) per socket: 8 Socket(s): 1 Vendor ID: MBE8C-PC v.2 CPU family: 4 Model: 2 Model name: E8C CPU MHz: 1300 BogoMIPS: 2600.00 L1d cache: 64K L1i cache: 128K L2 cache: 512K L3 cache: 16384K

I didn't understand what to run with --version? The e2k assembler is closed and very different from x86.

DJs3000 commented 2 years ago

gcc -v lcc:1.25.19:Aug-25-2021:e2k-v4-linux Thread model: posix gcc version 7.3.0 compatible. # The compiler skillfully disguises itself as gcc.

fgsfdsfgs commented 2 years ago

I didn't understand what to run with --version?

I meant the e2k assembler, I assumed it was just a fork of GNU as. Is it at least supposed to be "compatible" with the GNU assembler, like syntax and preprocessor-wise? If it isn't then it might very well be that it doesn't properly understand the .byte directive or the macros or something.

DJs3000 commented 2 years ago

Good. Can you explain step by step how I can build sm64ex on e2k using an x86 build?

fgsfdsfgs commented 2 years ago

Try copying build/us_pc/sound/sequences/00_sound_player.m64 from your x86 build to the same path in your e2k build folder. For a more "automatic" approach you can also try modifying the Makefile by replacing the if-else block at line 382 with something like this

ifeq ($(VERSION),sh)
SOUND_BANK_FILES := $(wildcard sound/sound_banks/*.json)
SOUND_SEQUENCE_FILES := $(wildcard sound/sequences/jp/*.m64) \
    $(wildcard sound/sequences/*.m64) \
    sound/sequences/00_sound_player.m64
else
SOUND_BANK_FILES := $(wildcard sound/sound_banks/*.json)
SOUND_SEQUENCE_FILES := $(wildcard sound/sequences/$(VERSION)/*.m64) \
    $(wildcard sound/sequences/*.m64) \
    sound/sequences/00_sound_player.m64
endif

and then copy that file to sound/sequences/ instead of build/us_pc/sound/sequences/ folder.

DJs3000 commented 2 years ago

i fix Makefile 439 line image

from x86 build i copy "00_sound_player.m64" to sm64ex/build/us_pc/sound/sequences and /sm64ex/sound/sequences Next run "make BETTERCAMERA=1 EXTERNAL_DATA=1" in root project: image and text: python3 tools/assemble_sound.py --sequences build/us_pc/sound/sequences.bin build/us_pc/sound/bank_sets sound/sound_banks/ sound/sequences.json sound/sequences/us/17_cutscene_collect_key.m64 sound/sequences/us/1F_cutscene_victory.m64 sound/sequences/us/0C_level_underground.m64 sound/sequences/us/0F_event_metal_cap.m64 sound/sequences/us/22_cutscene_lakitu.m64 sound/sequences/us/01_cutscene_collect_star.m64 sound/sequences/us/0E_event_powerup.m64 sound/sequences/us/21_menu_file_select.m64 sound/sequences/us/0A_level_spooky.m64 sound/sequences/us/1C_event_toad_message.m64 sound/sequences/us/0B_event_piranha_plant.m64 sound/sequences/us/1E_cutscene_intro.m64 sound/sequences/us/07_level_boss_koopa.m64 sound/sequences/us/10_event_koopa_message.m64 sound/sequences/us/06_level_hot.m64 sound/sequences/us/20_cutscene_ending.m64 sound/sequences/us/04_level_inside_castle.m64 sound/sequences/us/19_level_boss_koopa_final.m64 sound/sequences/us/08_level_snow.m64 sound/sequences/us/15_cutscene_star_spawn.m64 sound/sequences/us/13_event_merry_go_round.m64 sound/sequences/us/18_event_endless_stairs.m64 sound/sequences/us/09_level_slide.m64 sound/sequences/us/16_event_boss.m64 sound/sequences/us/12_event_high_score.m64 sound/sequences/us/05_level_water.m64 sound/sequences/us/1B_event_solve_puzzle.m64 sound/sequences/us/14_event_race.m64 sound/sequences/us/11_level_koopa_road.m64 sound/sequences/us/02_menu_title_screen.m64 sound/sequences/us/03_level_grass.m64 sound/sequences/us/0D_menu_star_select.m64 sound/sequences/us/1A_cutscene_credits.m64 sound/sequences/us/1D_event_peach_message.m64 sound/sequences/00_sound_player.m64 sound/sequences/00_sound_player.m64 -DVERSION_US -DNON_MATCHING -DAVOID_UB $(cat build/us_pc/endian-and-bitwidth) Files sound/sequences/00_sound_player.m64 and sound/sequences/00_sound_player.m64 conflict. Remove one of them. make: *** [Makefile:921: build/us_pc/sound/sequences.bin] Error 1

fgsfdsfgs commented 2 years ago

Oh, right. You don't actually need to explicitly add 00_sound_player to that list since there's a wildcard just before it. Try this:

ifeq ($(VERSION),sh)
SOUND_BANK_FILES := $(wildcard sound/sound_banks/*.json)
SOUND_SEQUENCE_FILES := $(wildcard sound/sequences/jp/*.m64) \
    $(wildcard sound/sequences/*.m64)
else
SOUND_BANK_FILES := $(wildcard sound/sound_banks/*.json)
SOUND_SEQUENCE_FILES := $(wildcard sound/sequences/$(VERSION)/*.m64) \
    $(wildcard sound/sequences/*.m64)
endif
DJs3000 commented 2 years ago

IMG_20211130_162135 Yep!)

fgsfdsfgs commented 2 years ago

Still need to figure out a proper fix for this eventually.

DJs3000 commented 2 years ago

I agree! Thank you for helping)

fgsfdsfgs commented 2 years ago

I'm going to reopen this in case someone familiar with the e2k assembler sees this and happens to know the solution.