Beginner Question: KallistiOS GL Example Won't Run

If you have any questions on programming, this is the place to ask them, whether you're a newbie or an experienced programmer. Discussion on programming in general is also welcome. We will help you with programming homework, but we will not do your work for you! Any porting requests must be made in Developmental Ideas.
Post Reply
User avatar
rpk
DC Developer
DC Developer
Posts: 16
https://www.artistsworkshop.eu/meble-kuchenne-na-wymiar-warszawa-gdzie-zamowic/
Joined: Thu Dec 29, 2016 1:02 pm
Has thanked: 10 times
Been thanked: 12 times

Beginner Question: KallistiOS GL Example Won't Run

Post by rpk »

I'm a newbie to DC homebrew, and I'm having some difficulty getting the KallistiOS basic GL example to run.

I've been trying https://github.com/ljsebald/KallistiOS/ ... l/basic/gl with no success, regardless of whether it's running in an emulator or on hardware.

My dev environment is Debian Linux (see https://github.com/Drylm/dc-dev), which seems to compile the example just fine:

Code: Select all

root@a1741946a172:/src/kos-docker-test/examples/dreamcast/kgl/basic/gl# make
rm -f gltest.elf romdisk.*
kos-cc  -c gltest.c -o gltest.o
gltest.c: In function 'main':
gltest.c:245:12: warning: format '%d' expects argument of type 'int', but argument 2 has type 'uint32' [-Wformat]
gltest.c:245:12: warning: format '%f' expects argument of type 'double', but argument 3 has type 'int' [-Wformat]
gltest.c:245:12: warning: format '%f' expects argument of type 'double', but argument 4 has type 'float' [-Wformat]
gltest.c:126:13: warning: variable 'texture' set but not used [-Wunused-but-set-variable]
kos-cc  -c pvr-texture.c -o pvr-texture.o
/src/dc/kos/utils/genromfs/genromfs -f romdisk.img -d romdisk -v
0    rom 58661264         [0xffffffff, 0xffffffff] 37777777777, sz     0, at 0x0
1    .                    [0x34      , 0xff6de   ] 0040755, sz     0, at 0x20
1    ..                   [0x34      , 0xff6da   ] 0040755, sz     0, at 0x40     [link to 0x20    ]
1    glass.pvr            [0x34      , 0xff6df   ] 0100755, sz 32800, at 0x60
/src/dc/kos/utils/bin2o/bin2o romdisk.img romdisk romdisk.o
/opt/toolchains/dc/sh-elf/bin/sh-elf-gcc -O2 -fomit-frame-pointer -ml -m4-single-only -ffunction-sections -fdata-sections -I/src/dc/kos/../kos-ports/include -I/src/dc/kos/include -I/src/dc/kos/kernel/arch/dreamcast/include -I/src/dc/kos/addons/include -I/src/dc/kos/../kos-ports/include -D_arch_dreamcast -D_arch_sub_pristine -Wall -g -fno-builtin -fno-strict-aliasing  -ml -m4-single-only -Wl,-Ttext=0x8c010000 -Wl,--gc-sections -T/src/dc/kos/utils/ldscripts/shlelf.xc -nodefaultlibs -L/src/dc/kos/lib/dreamcast -L/src/dc/kos/addons/lib/dreamcast -L/src/dc/kos/../kos-ports/lib -ml -m4-single-only -Wl,-Ttext=0x8c010000 -Wl,--gc-sections -T/src/dc/kos/utils/ldscripts/shlelf.xc -nodefaultlibs -L/src/dc/kos/lib/dreamcast -L/src/dc/kos/addons/lib/dreamcast -L/src/dc/kos/../kos-ports/lib -o gltest.elf  \
        gltest.o pvr-texture.o romdisk.o  -lGL -lpcx -lkosutils -Wl,--start-group -lkallisti -lc -lgcc -Wl,--end-group

This produces gltest.elf, which I convert to a .bin and then scramble:

Code: Select all


sh-elf-objcopy -O binary gltest.elf gltest.bin
/src/dc/kos/utils/scramble/scramble gltest.bin 1ST_READ.BIN

To test on hardware, I use DreamShell 4.0.0 RC 4 with an SD card reader. I copy the .elf, the .bin and the scrambled .bin to the SD card. From the DreamShell file explorer, I try executing each of these. The .elf just makes the Dreamcast reset, and the other two result in a blank screen followed by a lost signal after a few seconds.

To test using emulators, I use BootDreams to generate a .CDI and then depending on the emulator either load the CDI directly or use DaemonTools to mount it as a virtual disk drive. Here are the results:

- DreamEMU loads the scrambled .bin and just renders a black screen (similar to the real hardware, but no way to see logs).
- Demul shows the SEGA license screen then freezes (no way to see logs).
- Chankast shows the SEGA license screen then freezes (no way to see logs).
- reicast does not show the SEGA license screen, and just shows the error: "in cpu_iNimp -> ..\core\hw\sh4\interpr\sh4_opcodes.cpp : 66"
- nulldc shows the SEGA license screen then freezes with the following error:

Code: Select all

    KallistiOS ##version##: Mon Oct 31 23:34:55 UTC 2016
    root@f246d9df54da:/src/dc/kos
    Except in block BE5ECEB | E4765B8
    Except in block BE5ECEB | E4765B8
    Except in block BE5FF11 | E4773F8
    Except in block BE8D0EA | E4948C8
    VREG = 03 ARMRST 01
    Except in block BE8D552 | E495108
    not implemented opcode : 740 : unknown opcode @ 449
    Press Any key to continue
Does anybody have a suggestion of what I could try next?

Edit:

I should add, I've tried a handful of other examples with similar results but am focusing on the GL example because I want to use it to experiment.

Attached are all the generated .elf, .bin and .cdi files.
Attachments
gltest.zip
.elf, .bin and .cdi files that were generated.
(1.62 MiB) Downloaded 67 times
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5664
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has thanked: 9 times
Been thanked: 69 times
Contact:

Re: Beginner Question: KallistiOS GL Example Won't Run

Post by BlueCrab »

Try out the 2ndmix example and see if it runs. If it doesn't, then your toolchain is likely the culprit here (and producing bad code).

The unknown opcode in the nulldc logs kinda suggests to me that your toolchain is broken, and if 2ndmix is broken, that would be able to confirm that for me...
User avatar
bogglez
Moderator
Moderator
Posts: 578
Joined: Sun Apr 20, 2014 9:45 am
Has thanked: 0
Been thanked: 0

Re: Beginner Question: KallistiOS GL Example Won't Run

Post by bogglez »

I also think something is wrong with your toolchain.

Can you try this install script instead? It works for everyone including me on Debian

http://dcemulation.org/?title=Compiling_KOS_on_Linux
Wiki & tutorials: http://dcemulation.org/?title=Development
Wiki feedback: viewtopic.php?f=29&t=103940
My libgl playground (not for production): https://bitbucket.org/bogglez/libgl15
My lxdream fork (with small fixes): https://bitbucket.org/bogglez/lxdream
User avatar
rpk
DC Developer
DC Developer
Posts: 16
Joined: Thu Dec 29, 2016 1:02 pm
Has thanked: 10 times
Been thanked: 12 times

Re: Beginner Question: KallistiOS GL Example Won't Run

Post by rpk »

I just tried the 2ndmix example and it works on nulldc and on hardware.

2ndmix doesn't link with GL or any other libraries, so maybe the toolchain's libraries (kos-ports) weren't set up properly.

I'll try re-building the toolchain using the install script and report back.

Thanks for the help :)

Edit:

Yep, after re-building the toolchain everything seems to work. Thanks again!
Post Reply