The XL Engine is and will remain free, donations are purely optional but greatly appreciated.

Recent Comments

Archive for December 2013

I have resumed work on the DaggerXL Beta after taking a break for Christmas. I don’t have much new to show yet but I will talk about a few topics.


On the XL Engine forums¬†there has been mod work towards using the WebUI system that will be present in the Beta release. I talked about this system before in a previous blog post but now Lazaroth has been busy working on a UI mod, using existing web technologies to prototype. I dropped the files into the WebUI folder under the XL Engine and modified a bit of code (that will be externalized for the release) and was able to view the new UI in the current version of the XL Engine. There are a few issues to work out but its a great start and will allow me to work out kinks in the WebUI system. It also shows that using HTML5/CSS/Javascript and a browser is a great way of prototyping new UI ideas and the results can be nearly “drop-in” for use in the XL Engine.




If you want more information on the mod or to help out, check out Lazaroth’s thread on the forums.


Anatomy of a For-Loop in Daggerfall

So what does a for-loop look like in Daggerfall? It turns out that recognizing for-loops generated by the compiler is rather simple as you’ll see shortly. I have copied some of the actual assembly code with comments.

mov dword [ebp-0018],00000000
[19A283]				;for (int i=0; i<27; i++) {
cmp dword [ebp-0018],001B               ;//comparison block
jl 0019A293
jmp 0019A2D1
[19A28B]			        ;//for-loop counter block
mov eax,[ebp-0018]
inc dword [ebp-0018]
jmp 0019A283
[19A293]			        ;//code block
jmp 0019A28B
[19A2D1]				;} //for (int i=0; i<27; i++)

The actual assembly code is on the left, with code addresses shown in brackets [ ]. As you can see the local variable, ‘i’ as I named it, is at ebp-0x18. So the first thing that happens is to fill the value with 0, basically the i=0; part of the for-loop. Next it enters the comparison block¬†where the local variable is compared to a value – in this case 0x1B = 27, and if the comparison is successful the execution jumps to the code block, otherwise it jumps to the end of the loop (the last line shown above).

When you see the C/C++ code

for (int i=0; i<27; i++)
    //code inside the loop

The “code inside the loop” is the code block above. Once the code is executed or a continue is hit – then the execution jumps to the for-loop counter block. Here the counter is incremented, decremented or otherwise modified before jumping back to the comparison block. Obviously if a break is encountered in the code block, the jump will lead directly to the end of the loop or to a another address which will have a jump to the end of the loop if the difference in address is too big for a “short” jump (usually). Remember that for-loops look different with modern compilers and sometimes the format is tweaked a bit even in Daggerfall depending on what the optimizer does. But this is essentially what a for-loop looks like, even nested loops have a similar, though recursive, structure.

The Beta

I have recently continued work towards the Beta release and will start posting updates again as additional progress is made.

Unfortunately I have a lot on my plate for this Christmas season, so I will be taking a break from XL Engine work until after Christmas. This has been happening for the last week or so, which is why I haven’t been posting updates. Anyway this is not caused by roadblocks or even stressful issues but rather by obligations I have to meet by the holiday.

Once Christmas is over I should have some extra time for a while, allowing me to make up for lost time a little. :)

Happy Holidays.


The XL Engine is and will remain free, donations are purely optional but greatly appreciated.