Page 1 of 1

x16lib - Library for BASIC and Assembly

Posted: Sat Feb 24, 2024 9:07 am
by unartic
In order to make developing for x16 as easy and convenient as possible, I've started working on a library that goes far beyond what the kernal currently offers. It sits in a rambank of choice and offers the programmer easy to use functions for common tasks.

For BASIC it taps directly into the BASIC variable space to ensure maximum performance.

x16lib is fully documented and with ready to use examples.

The current version offers only a few functions. I would like the community to suggest functions that needs to be in this library. So if you have idea's please post them below.

Please download here:
x16lib.zip
(171.24 KiB) Downloaded 155 times
userguide.pdf
(192.25 KiB) Downloaded 260 times


The current version of x16lib has the following functions:

Printcenter
Print a string in the center of the screen on a specific line

Swapveralayers
Swap the z-order of layer0 and layer1 of vera

Highmem functions
Quickly and easily save and read strings in/from any highram rambank.

Fading
Fades out the screen to all black and fade the screen back to normal operatingmode

String functions
Several well know string functions: trim, ltrim, rtrim, tally, instr and split

Custom keyboard handler
Custom keyboard handler which enables to get the state of individual keys and therefor can work with simultanious keypresses.


NOTE: As the ROM-version of BASLOAD remaps all variable names, BASIC programs loaded via the ROM-version of BASLOAD will not be compatible with x16lib at this moment.

Re: x16lib - Library for BASIC and Assembly

Posted: Thu Feb 29, 2024 8:12 am
by funkheld
Hi good afternoon.

the demos here from asm are wonderful.

Which assembler are they written for?
acme is not.

Thanks.
greeting

Re: x16lib - Library for BASIC and Assembly

Posted: Thu Feb 29, 2024 8:45 am
by unartic
They are written for ca65.

Re: x16lib - Library for BASIC and Assembly

Posted: Sat Mar 16, 2024 11:21 am
by MADRAFi
Can you share source code for the lib? If someone wants to use these procedures in higher level languages, it would be better to wrap them in native procedures executing assembly, instead loading a binary and call the function.
I would like to add them to the Pascal unit.

Re: x16lib - Library for BASIC and Assembly

Posted: Fri May 31, 2024 4:07 pm
by Jakebullet70
Really like this. Would like to see it work with BASLOAD as that is how I am writing all my code now.

As a new feature would like to see:
Save and restore parts of a screen. That way you could save part of screen, show a messagebox and then just restore the part that was overwriten.

Really nice work.

Re: x16lib - Library for BASIC and Assembly

Posted: Fri May 31, 2024 4:57 pm
by unartic
Jakebullet70 wrote: Fri May 31, 2024 4:07 pm Really like this. Would like to see it work with BASLOAD as that is how I am writing all my code now.

As a new feature would like to see:
Save and restore parts of a screen. That way you could save part of screen, show a messagebox and then just restore the part that was overwriten.

Really nice work.
I already have a solution for basload, however implementing is a bit complex and timeconsuming. It is on my list of of todo's, but that list is not very short at the moment ;-) As soon as I've made the changes, I'll post it here, so if you subscribe to this topic, you'll know asap.

You suggestion is also noted ;-)

Re: x16lib - Library for BASIC and Assembly

Posted: Sat Jun 01, 2024 1:44 am
by Jakebullet70
Good deal. I have subscribed. Looking forward to seeing new features. :D

Re: x16lib - Library for BASIC and Assembly

Posted: Sat Jun 01, 2024 5:22 am
by Jakebullet70
How about a way to run (chain / load) to a new PRG while being able to still see the STRINGS in HIGHRAM memory.

I have been looking at the HANGMAN PRG on the SDCARD and the author wrote out VAR's to an INI file before he ran another program.

---> My brain is in overdrive as I am writing code. :)

Re: x16lib - Library for BASIC and Assembly

Posted: Sat Jun 01, 2024 5:43 pm
by unartic
If you use the highram routines from x16lib, they will persist when chaining basic programs.