ugBASIC
Re: ugBASIC
here is my code:
when compiling for the zx spectrum it doesnt seem to do anything.
It should print the character generator screen
the relevant function called is initcharscreen [] which calls CLS
CLS isnt called as the 'bytes' thing is on the screen
when compiling for the zx spectrum it doesnt seem to do anything.
It should print the character generator screen
the relevant function called is initcharscreen [] which calls CLS
CLS isnt called as the 'bytes' thing is on the screen
-
- Drutt
- Posts: 21
- Joined: Fri Aug 25, 2023 7:24 am
Re: ugBASIC
Hi Wall_Axe, first of all thank you for your example!
Actually, frequent updates to the compiler are coming out these days, as the new version 1.14.2 is about to be released. So I recommend you update the compiler. If you use the IDE just go to Configuration > Compilers, and download the compiler for the ZX Spectrum.
This is the output using directly your source:
It doesn't seem to work properly, but something shows anyway.
Now, however, I'll delve deeper.
Thank you again!
I study your code carefully, to understand what's wrong (in the compiler, of course! )
Actually, frequent updates to the compiler are coming out these days, as the new version 1.14.2 is about to be released. So I recommend you update the compiler. If you use the IDE just go to Configuration > Compilers, and download the compiler for the ZX Spectrum.
This is the output using directly your source:
It doesn't seem to work properly, but something shows anyway.
Now, however, I'll delve deeper.
Thank you again!
-
- Drutt
- Posts: 21
- Joined: Fri Aug 25, 2023 7:24 am
Re: ugBASIC
Hi Wall_Axe, first of all, thank you again for the source!
I have introduced a preliminary optimization in the compiler for ZX Spectrum (which I recommend you download again, via IDE or from the dedicated page) which allows you to reuse the strings several times while always occupying the same space. At the same time, in the same compiler version, I introduced constants instead of simple numbers when accessing arrays.
For example, instead of writing
you should write
This suggests to the compiler that those numbers (0 and 1) are constants, so it can calculate the offset at compile time instead of at runtime. This greatly streamlines the resulting executable. In the future it is possible that these types of optimizations will be automatic, but in the meantime this workaround will help you. However, keep in mind that I am using this example source of yours as a "testbed" for further optimizations, so it is possible that in the next few days the compiler will become even more optimized.
This is the result I get on Speccy.
Thank you again, and have a nice retrocoding!
From a first analysis, I believe that the problem lies, or rather did lie, in the size of the executable. Due to some optimization failures, including duplication of constant strings and access to arrays with positions calculated at runtime rather than at compile time, the source became a bit too large to fit in the available memory.
I have introduced a preliminary optimization in the compiler for ZX Spectrum (which I recommend you download again, via IDE or from the dedicated page) which allows you to reuse the strings several times while always occupying the same space. At the same time, in the same compiler version, I introduced constants instead of simple numbers when accessing arrays.
For example, instead of writing
Code: Select all
r$(0,1)="outside the base entrance"
Code: Select all
r$(#0,#1)="outside the base entrance"
This is the result I get on Speccy.
Thank you again, and have a nice retrocoding!
Re: ugBASIC
thanks,
that was a very quick fix considering the size of the code.
I'll get back to to it then
that was a very quick fix considering the size of the code.
I'll get back to to it then
Re: ugBASIC
this brought it down from 38k to 30k and now it works
Thanks
it still seems like a large executable compared to the size of the code.
Anything further that can be done?
Thanks
it still seems like a large executable compared to the size of the code.
Anything further that can be done?
-
- Drutt
- Posts: 21
- Joined: Fri Aug 25, 2023 7:24 am
Re: ugBASIC
Hi Wall_Axe, first of all thank you again for the feedback.
I took a few days to publish version 1.14.2, which already brings some notable improvements. Further optimizations have been made in the beta version, which is currently being tested. However, from a brief examination of the source, I could suggest a series of improvements to the code, and in particular the best one of all, which is to try to use strings as little as possible, especially when comparing options.
For example, it is better to initialize an array or vector at definition time than to do it at run time, especially if it is composed of numeric values. For example, this saves a few hundred bytes:
Another optimization is to avoid executing "useless" instructions, in the sense that you initialize a value that you already know is the starting one. For example, by omitting these instructions, you gain an entire KB, and more!
The next version will feature numerous optimization improvements, so stay tuned!
I took a few days to publish version 1.14.2, which already brings some notable improvements. Further optimizations have been made in the beta version, which is currently being tested. However, from a brief examination of the source, I could suggest a series of improvements to the code, and in particular the best one of all, which is to try to use strings as little as possible, especially when comparing options.
For example, it is better to initialize an array or vector at definition time than to do it at run time, especially if it is composed of numeric values. For example, this saves a few hundred bytes:
Code: Select all
DIM encounters(3,3) = _
#{ 0, 0, 0, _
0, 0, 0, _
0, 1, 0 }
DIM encountername$(7,10)
DIM encounterstr(7,10) = _
#{ 0, 0, 0, 0, 0, 0, 0, _
0, 4, 0, 0, 0, 0, 0, _
0, 4, 0, 0, 0, 0, 0, _
0, 4, 0, 0, 0, 0, 0, _
0, 3, 0, 0, 0, 0, 0, _
0, 4, 0, 0, 0, 0, 0, _
0, 4, 0, 0, 0, 0, 0, _
0, 0, 0, 0, 0, 0, 0, _
0, 0, 0, 0, 0, 0, 0, _
0, 0, 0, 0, 0, 0, 0 }
DIM partystr(9) = #{ 3, 0, 0, 0, 0, 0, 0, 0, 0 }
DIM partyskill(9) = #{ 3, 0, 0, 0, 0, 0, 0, 0, 0 }
Code: Select all
' lockeddoors$(0,0)=""
lockeddoors$(0,1)="e"
' lockeddoors$(1,2)=""
' lockeddoors$(1,0)=""
' lockeddoors$(1,1)=""
' lockeddoors$(1,2)=""
' lockeddoors$(2,0)=""
' lockeddoors$(2,1)=""
' lockeddoors$(2,2)=""
Re: ugBASIC
hi i tried compiling with the latest normal version available. It goes into an infinite loop and doesnt stop compiling.
(using the same code as pg.3 of this thread)
(using the same code as pg.3 of this thread)
-
- Drutt
- Posts: 21
- Joined: Fri Aug 25, 2023 7:24 am
Re: ugBASIC
Re: ugBASIC
Thanks I'll check it out