FAQ  •  Register  •  Login

Add more library functions

<<

britlion

Posts: 720

Joined: Mon Apr 27, 2009 7:26 pm

Location: Slough, Berkshire, UK

Post Tue Nov 23, 2010 11:59 pm

Add more library functions

Cool stuff.

I've added it as a code patch to the wiki library section. Are there any others in there, like LCD's proportional print routine or the nascent maths library section that you think are worth calling part of the include pack?
<<

boriel

Site Admin

Posts: 1238

Joined: Wed Nov 01, 2006 6:18 pm

Location: Santa Cruz de Tenerife, Spain

Post Wed Nov 24, 2010 12:21 am

Re: Function call with string params bug (*solved*)

Yes, but like in this topic, we *must* intensively check them before including them into the library.
I've been quite busy these last months hence the delay, but I'm started to manage automatic testing, so things should go much faster from now onwards.

By the way, I think print64 is well tested enough, so I will include them in the library.
Also would like to include many other libraries (Mojon's codes in a /mj/ directory, and your fourspriter version among others) :wink:

BTW, there's a function called setattr(x, y, value) in ATTR.BAS library.
Programming an attrAddr function is also straighforward as this function is already defined in library-asm/attr.asm
I thing the routine in there is much faster an shorter (need more testing).
<<

britlion

Posts: 720

Joined: Mon Apr 27, 2009 7:26 pm

Location: Slough, Berkshire, UK

Post Wed Nov 24, 2010 12:32 am

Re: Function call with string params bug (*solved*)

Thanks, Boriel.

Part of the duplication issue is lack of documentation - not knowing what's out there as a callable function.

Think that should be in library routines? I suppose knowing what's available in what include is going to help a lot
<<

boriel

Site Admin

Posts: 1238

Joined: Wed Nov 01, 2006 6:18 pm

Location: Santa Cruz de Tenerife, Spain

Post Wed Nov 24, 2010 9:18 am

Re: Function call with string params bug (*solved*)

britlion wrote:Thanks, Boriel.

Part of the duplication issue is lack of documentation - not knowing what's out there as a callable function.

Think that should be in library routines? I suppose knowing what's available in what include is going to help a lot

E.g. the print42 library is buggy. It contains the following code:
  Code:
newline:
        LD DE,(63536)
        CALL nxtline       ; move to next line
        LD (63536),DE     ; and go on to next character
        JR nextChar

This is a bug for sure: you're writing at a fixed position (65356) which is the memory heap for temporary work, so you're corrupting it. Besides, I don't understand very well what these lines do? :?:
<<

britlion

Posts: 720

Joined: Mon Apr 27, 2009 7:26 pm

Location: Slough, Berkshire, UK

Post Wed Nov 24, 2010 9:29 am

Re: Add more library functions

I completely agree I need other people to test these. I didn't write the original code, just reworked it from well known sources into shape; which means there are likely to be bugs.

I'll look into this one after work today.
<<

boriel

Site Admin

Posts: 1238

Joined: Wed Nov 01, 2006 6:18 pm

Location: Santa Cruz de Tenerife, Spain

Post Wed Nov 24, 2010 9:34 am

Re: Add more library functions

britlion wrote:I completely agree I need other people to test these. I didn't write the original code, just reworked it from well known sources into shape; which means there are likely to be bugs.

I'll look into this one after work today.

Ok, I will later. :wink:
Ah, I forgot: please, put the URL or whatever of the original code (based upon: bla bla bla). Not only gives them credit, but also we can blame on them in case of a bug, like this! :mrgreen:
<<

boriel

Site Admin

Posts: 1238

Joined: Wed Nov 01, 2006 6:18 pm

Location: Santa Cruz de Tenerife, Spain

Post Wed Nov 24, 2010 8:11 pm

Re: Add more library functions

britlion wrote:I completely agree I need other people to test these. I didn't write the original code, just reworked it from well known sources into shape; which means there are likely to be bugs.

I'll look into this one after work today.

I've made some changes to your routine. Please download and compare.

Some corrections:
  • Removed the LD DE,(XXXX) block. It's useless and might corrupt the HEAP
  • Check if HL==0 (NULL) at the beginning of the asm code, and return if so (this can happen if not enough memory)
  • Remove the FASTCALL and, instead of returning immediately, jump to the end of subroutine whenever required. The string ByVal parameters must be freed upon return, or there will be a memory leak (yes, the same that happened with print64 :P)
  • Make as much labels as possible LOCAL, so it won't pollute namespace and won't collide with other routines. E.g. nextchar label could be used in many other routines (e.g. print64).
Have a look at this file, please and tell me (it works ok to me). Also, if you notice something to fix up, please do so and post it back.
Attachments
print42.bas
Fixed version of print42.bas
(15.68 KiB) Downloaded 68 times

Return to Wishlist

Who is online

Users browsing this forum: No registered users and 1 guest

cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by Vjacheslav Trushkin for Free Forums/DivisionCore.

phpBB SEO