Stephane-D / SGDK

SGDK - A free and open development kit for the Sega Mega Drive
https://www.patreon.com/SGDK
MIT License
1.75k stars 187 forks source link

Problem zero size #260

Closed VitalyDyachkov closed 2 years ago

VitalyDyachkov commented 2 years ago

Good day, friends! Thanks for the detailed description of the tool and the SGDK tool itself. I'm having a problem compiling a file using the command line. Output ->

C:\SegaProject>C:\SGDK\bin\make -f C:\SGDK\makefile.gen C:/SGDK/bin/mkdir.exe -p src/boot C:/SGDK/bin/mkdir.exe -p out C:/SGDK/bin/cp.exe C:/SGDK/src/boot/sega.s src/boot/sega.s C:/SGDK/bin/cp.exe C:/SGDK/src/boot/rom_head.c src/boot/rom_head.c C:/SGDK/bin/gcc.exe -DSGDK_GCC -m68000 -Wall -Wextra -Wno-shift-negative-value -Wno-main -Wno-unused-parameter -fno-builtin -fms-extensions -Iinc -Isrc -Ires -IC:/SGDK/inc -IC:/SGDK/res -BC:/SGDK/bin -O3 -fuse-linker-plugin -fno-web -fno-gcse -fno-unit-at-a-time -fomit-frame-pointer -flto -c src/boot/rom_head.c -o out/rom_head.o C:/SGDK/bin/objcopy.exe -O binary out/rom_head.o out/rom_head.bin C:/SGDK/bin/gcc.exe -x assembler-with-cpp -Wa,--register-prefix-optional,--bitwise-or -DSGDK_GCC -m68000 -Wall -Wextra -Wno-shift-negative-value -Wno-main -Wno-unused-parameter -fno-builtin -fms-extensions -Iinc -Isrc -Ires -IC:/SGDK/inc -IC:/SGDK/res -BC:/SGDK/bin -O3 -fuse-linker-plugin -fno-web -fno-gcse -fno-unit-at-a-time -fomit-frame-pointer -flto -c src/boot/sega.s -o out/sega.o src/boot/sega.s: Assembler messages: src/boot/sega.s:52: Error: skip (0) or count (256) invalid for file size (0) make: *** [out/sega.o] Error 1

main.c==================================

include

u8 data = 0;

int main(bool hard) { VDP_drawText("Hello Genny World!", 10, 13);

while(TRUE)
{
    // read input
    // move sprite
    // update score
    // draw current screen (logo, start screen, settings, game, gameover, credits...)

    // wait for screen refresh and do all SGDK VBlank tasks
    SYS_doVBlankProcess();
    for(int i = 0; i < 100;i++)
    {
        data++;
    }
    if(data == 100){
    data = 0;
    }
}

return 0;}

Can you please tell me what could be wrong?

D0NM commented 2 years ago

Well the problem is: rom_head.bin is not generated. IT is basically 0 bytes.

The ugly fix (lol)

segas.s line 52

it uses directive .incbin "file"[,skip[,count]] so... replace the zero-length file with anything. And it'd work.

Also it is strange, but SGDK has 2 couples of sega.s + rom_head.c one is licated in sdgk\src\boot the other is in the template

VitalyDyachkov commented 2 years ago

Thanks for the answer! But I just didn't understand why the .bin file wasn't generated.

D0NM commented 2 years ago

The make file has been changed. There is a bug.

VitalyDyachkov commented 2 years ago

That is, you need to roll back to an earlier version?

VitalyDyachkov commented 2 years ago

SGDK 1.70 (February 2022)

VitalyDyachkov commented 2 years ago

Thank you very much, D0NM friend! Downloaded SDK version 1.34 (December 2017), managed to build a starter project!

D0NM commented 2 years ago

My future investigation shows that road_head.c is being compiled. But the object file is ~ 4K instead of 899 bytes. Also it has some garbage inside, You cannot see the real text strings in this .o file.

On using objcopy.exe it produces the zero length .bin file

Stephane-D commented 2 years ago

Fixed ! (looks like -O1 flag break rom_head.c compilation, reverted to DEFAULT_FLAGS)