Iterative builds or hot-loading with DCLOAD + DC-TOOL 1.0.5

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

Iterative builds or hot-loading with DCLOAD + DC-TOOL 1.0.5

Post by rpk »

I've recently bought a dreamcast broadband adapter (BBA) and set up DCLOAD-IP + DC-TOOL 1.0.5.

I can send my compiled .elf and have it execute on the dreamcast, but after making any changes to the code and rebuilding I need to reboot the dreamcast to dcload in order to upload again. This is of course much better than burning a CD or copying to an SD card each time there's a new build, but I'm looking for a way to speed up the process even more.

Does anyone know of a way to re-upload code to the dreamcast without restarting the console (for example, to have dcload-ip stay in memory ready for a fresh upload)?
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5666
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has thanked: 9 times
Been thanked: 69 times
Contact:

Re: Iterative builds or hot-loading with DCLOAD + DC-TOOL 1.

Post by BlueCrab »

If your program exits cleanly (if you're using KOS and you call exit() or return from main(), this will be true generally), then dcload should be ready to accept a new binary as soon as your program ends. It won't show anything on the screen, but if you start sending it a new one, it should "just work".

Also, many times crashes from programs written with KOS will end up dropping back out to dcload as well.

Of course, if you end up stuck in some kind of infinite loop, this won't be true...
User avatar
bogglez
Moderator
Moderator
Posts: 578
Joined: Sun Apr 20, 2014 9:45 am
Has thanked: 0
Been thanked: 0

Re: Iterative builds or hot-loading with DCLOAD + DC-TOOL 1.

Post by bogglez »

I think you're talking about hot loading, also called compile and edit etc.

For example jak and daxter on ps2 had its own programming language which allowed reloading absolutely any code at runtime (including changed data structures it seems) http://www.codersnotes.com/notes/disassembling-jak

This is an example of doing a slightly less powerful version of that where the game code is in a separate DLL than the engine code. The engine notices when the DLL has changed, unloads and reloads it, then passes all game memory to it. This allows changing AI and such while the game is running, but doesn't allow freely changing data structures. Should be enough for most purposes though and doesn't require writing a compiler.
I've never tried this on DC though
https://www.youtube.com/watch?v=WMSBRk5WG58
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: Iterative builds or hot-loading with DCLOAD + DC-TOOL 1.

Post by rpk »

BlueCrab, you're right - if I exit from my game's main loop, it drops to a black screen. From there, I can upload a new .ELF and run it even though there's no DCLOAD prompt. Thanks for the help, really takes the sting out of waiting.

bogglez, thanks for the links. Live code reloading while the game is running has been on my radar for a while. It puts me in mind of multiplayer systems where the game state is synchronised across machines. With some careful planning it might be possible to have the game resume from a full state snapshot of a previous run, or even rewind/replay game state to help debugging.

My naive approach would be to serialize all the high-level data structures' state into key/value pairs, compress it and dump to a file over the network, which would mean re-loading is just a case of doing the same in reverse.

Will post here if I ever get that far :)
Post Reply