VTUI library

All aspects of programming on the Commander X16.
User avatar
Cyber
Posts: 482
Joined: Mon Apr 27, 2020 7:36 am

VTUI library

Post by Cyber »


Yeah, looks appealing to me as well!

User avatar
JimmyDansbo
Posts: 476
Joined: Sun Apr 26, 2020 8:10 pm
Location: Denmark
Contact:

VTUI library

Post by JimmyDansbo »


Please let me know when you find typos, errors and bugs. It seems I quickly "go blind" when looking at my own text and source.

Visit my Github repo
or my personal site with CX16/C64/6502 related information.
Feel free to contact me regarding any of my projects or even about meeting up somewhere near Denmark
User avatar
desertfish
Posts: 1096
Joined: Tue Aug 25, 2020 8:27 pm
Location: Netherlands

VTUI library

Post by desertfish »


 I was reading the rather excellent documentation and found this:

"Addresses used are $22 - $2D this is to avoid using the ABI registers used by the new Commander X16 functions. "

Why did you choose this? There are sixteen Cx16 ABI registers, more than enough I would think to (re)use them yourself?

If they're only used for arguments or return values for the VTUI's functions there shouldn't be any issue to just use a couple of the r0..r15 registers for that? The code has to set them anyway to call a routine in rom or library either way, I think

I'm zooming in on this one in particular because as it is currently, I won't be able to use the library in Prog8.  Prog8 assumes a certain fixed free block of zero page to store its own variables, and it is only aware of the ZP space taken up by the cx16's abi virtual registers and the reserved block from $80 upwards...

 

User avatar
kliepatsch
Posts: 247
Joined: Thu Oct 08, 2020 9:54 pm

VTUI library

Post by kliepatsch »


+1 Good point. I think even the initialization routine would be perfectly fine running from within the r0 to r15 registers. No need to use up additional ZP space, as far as I can tell, anyway.

User avatar
JimmyDansbo
Posts: 476
Joined: Sun Apr 26, 2020 8:10 pm
Location: Denmark
Contact:

VTUI library

Post by JimmyDansbo »



5 hours ago, desertfish said:




Why did you choose this? There are sixteen Cx16 ABI registers, more than enough I would think



I have not looked into using the new ABI in the kernal and therefor I decided to just leve those registers alone to ensure that I did not interfere with something that would use those registers. The ABI registers are plenty of space for the VTUI library and I have no issue moving it to use r0, r1, r2 and so on.

Visit my Github repo
or my personal site with CX16/C64/6502 related information.
Feel free to contact me regarding any of my projects or even about meeting up somewhere near Denmark
User avatar
desertfish
Posts: 1096
Joined: Tue Aug 25, 2020 8:27 pm
Location: Netherlands

VTUI library

Post by desertfish »


Should be good as long as you're not storing global variables in them, I suppose, only temporary function arguments/returnvalues

Thanks for considering the modification

User avatar
JimmyDansbo
Posts: 476
Joined: Sun Apr 26, 2020 8:10 pm
Location: Denmark
Contact:

VTUI library

Post by JimmyDansbo »


VTUI updated to version 0.3

Now it uses zeropage registers r0 to r5


 

Visit my Github repo
or my personal site with CX16/C64/6502 related information.
Feel free to contact me regarding any of my projects or even about meeting up somewhere near Denmark
User avatar
desertfish
Posts: 1096
Joined: Tue Aug 25, 2020 8:27 pm
Location: Netherlands

VTUI library

Post by desertfish »


Fantastic work @JimmyDansbo ; also on the documentation: even now for this early version  it's already super clear and detailed.

It allowed me to easily interface to the library from Prog8 and I've been playing with it for a bit! Got it to work quite smoothly (mostly):

image.png.4a3208450dc9cd8ac58584b6095a0cdd.png

Without a doubt you'll notice a few of the letters are weird. This is because I was attempting to use vtui with upper+lowercase charset. The petscii translation routines seem overly restrictive with the characters that they accept... I was attempting to print "Hello, world! VTUI from Prog8!".

Here's my list of findings so far:


  1. question: any particular reason fill_box() require the character to be in R0H ?  This complicates things a little bit for me because Prog8 treats the R-registers strictly as words. Suggestion: Can't this parameter be in A, like the mode for border()?


  2. question: any particular reason fill_box(), border(), save_rect() and rest_rect() require the dimensions to be in a single R1 register rather than splitting the width and height across say R1L and R2L? (same reason for me as #1 above)


  3. suggestion: add a few more box types that look nice with the Upper+Lowercase characters charset. Currently only border mode 0 and 1 are ok in this case. Perhaps also provide a way to specify the exact box character?


  4. suggestion: let the initialize function also immediately set the 'sane' / most used default settings for vera stride and increment, without requiring screen_set() ?


  5. suggestion: the petscii-to-screencode translation and vice versa, is now quite restrictive. My "Hello, world! VTUI from Prog8!" is printed as "Vello world! VVVV from Vrog8!"  as you can see in the screenshot. Can we perhaps improve this to map more characters


  6. bug: calling initialize twice makes other calls crash


  7. bug in doc: rest_rest() documentation is incorrect in the register table, 'Purpose' column seems copied from save_rect()


  8. bug: a set_decr() with C=1 (decrement) seems to misalign character+color output for instance when using print_str() afterwards in an attempt to print in reverse. This is visible in the second text line in the screenshot.


 

I'm willing to help improve the library for things like this and add PR's on github if you want?

 

User avatar
JimmyDansbo
Posts: 476
Joined: Sun Apr 26, 2020 8:10 pm
Location: Denmark
Contact:

VTUI library

Post by JimmyDansbo »


@desertfish thank you for your kind words. The documentation part is the hardest ? It is great to see that you have been able to interface with library.

Let me address your points.


  1. Not really any particular reason other than at the time of writing the function, it seemed easier to pass the variable that way. - On my TODO.


  2. Again, no particular reason other than keeping parameters tight. I see no issue changing it to just use the low part of the 16bit registers - On my TODO.


  3. At the moment, the library only supports the default character set, but the addition of a custom character for border is a good idea.


  4. The initialize function only exist in the generic library, not the include files and only has to do with initializing the jump table. I would like to keep the functionality of the different flavors the same. If the initialize function were to change settings in VERA as well, someone coming from the generic library to one of the include files might run into issues.


  5. The conversion functions pet2scr and scr2pet (also used in print_str) are very limited, that is again because the library only support default character set at the moment.


  6. I will look into this - On my TODO


  7. Good catch, will fix - On my TODO


  8. None of the library functions are designed to function with the decrement bit set and all expect the increment to be set to 1 


As you know, I am aiming at a library size below 1K in order to have it reside in Golden RAM. This restriction means that error detection/correction has been omitted it also means that it might be hard to add much more functionality.

I thank you for your kind offer to help. For now I would like to try and figure this out my self as this is still a learning experience for me. If you find that I am too slow or going in the wrong direction, feel free to let me know.

Visit my Github repo
or my personal site with CX16/C64/6502 related information.
Feel free to contact me regarding any of my projects or even about meeting up somewhere near Denmark
Ender
Posts: 220
Joined: Sat May 09, 2020 9:32 pm

VTUI library

Post by Ender »


Looking good!  A couple of minor things I see:


  1. Line 27 in acme-ex01.asm is "lda 0", you probably want "lda #0".


  2. The ".org" line in ca65-ex01.asm is unnecessary, the "CODE" segment already handles putting the code at the correct address.


Can't wait to see more stuff use this, your screenshots look good.

Post Reply