BatLib

A forum where you can announce your awesome project(s).

Moderator: MaxCoderz Staff

Xeda
New Member
Posts: 42
Joined: Sun 06 Feb, 2011 7:08 am

Re: BatLib

Post by Xeda »

I've been gone for the past 9 days without internet, but I have some updates... If you like the sound of SubMatrix, you might like some of the newer commands...:

Code: Select all

70-PlayNote
71-Logic
72-MatrixList
73-Left
74-Right
75-Mid
76-Diag
77-DiagI
78-SubCol
79-SubRow
80-ListToDiag
81-ListToDiagI
82-ListToCol
83-ListToRow
84-ExecVarBASIC
85-GetProgName
86-Timer
87-DrawText
88-DrawDispText
89-ASCIILength
90-DrawTokenStr
Things like ListToCol and SubRow will make it much easier to use matrices for saving/loading save data. Since the last update I have also added a fixed width 4x6 font (I've only finished the first 128 chars) as well as some commands that use it. It draws the chars to the grah screen and wraps the text to the next line automatically. Command 89 (ASCIILength) is also pretty useful because it returns the number of chars in a token or a string of tokens. For example, dim(86,"sin(ln(3)) would return 10 because the sin( token is 4 chars and ln( is 3 chars and the rest are 1 char. This will help give programmers an idea of how much space a string will use when displayed

Also, I have put a lot of work over the past few days into BASIC ReCode (dim(40)) so that is now functioning as an interpreted programming language. It now has 43 functions and has enough stuff to make a game. In fact, I remade my old Block Eater program using ReCode and the result is pretty impressive The code is a few hundred bytes smaller and the speed increase is massive:
Block Eater (ReCode)
Image
Block Eater (BASIC)
Image

Neat, right? The cool part is that a BASIC program can include blocks of ReCode and blocks of ReCode can contain assembly. ReCode uses BASIC tokens but doesn't necessarily do the same thing. For example, Line( draws rectangles (the same as dim(29)) instead of a line and Shade( deals with the contrast.

Here is a link to v4.00.92.43
http://www.omnimaga.org/index.php?actio ... ttach=6555
User avatar
benryves
Maxcoderz Staff
Posts: 3087
Joined: Thu 16 Dec, 2004 10:06 pm
Location: Croydon, England
Contact:

Re: BatLib

Post by benryves »

That's really impressive work, and the screenshot demonstrating the ReCode performance boost speaks volumes! :) Keep it up!
Xeda
New Member
Posts: 42
Joined: Sun 06 Feb, 2011 7:08 am

Re: BatLib

Post by Xeda »

Hehe, I found another way to boost speed, but before I get to that, I added a few more commands that deal with using sprites, BASIC strings, using pictures 0~255 whether they are in RAM or not, 27 more variables (54 total) and the Full command. Full will set the calc at 15MHz if possible, if it is used as is, or if you add a 0 to that (so Full0) it will set it at 6MHz. The download is here:
http://www.omnimaga.org/index.php?actio ... ttach=6589
Block Eater 1.1.gif
Block Eater 1.1.gif (122.22 KiB) Viewed 13565 times
What might be hard to believe is that it might be faster on an actual calc. When I tried it on my calc, I showed it off to some friends (who don't program calcs, but are familiar with programming), they thought my little Block Eater guy was teleporting from corner to corner! Then when they figured out it was actually moving they were absolutely amazed ^-^

My next speed booster will be partial screen updates >_> imagine if you could just update a small portion of the screen instead of the whole thing! Updating an 8x8 portion of the screen would take 1/96th of the time.
User avatar
benryves
Maxcoderz Staff
Posts: 3087
Joined: Thu 16 Dec, 2004 10:06 pm
Location: Croydon, England
Contact:

Re: BatLib

Post by benryves »

As long as the process of computing the dirty rectangles doesn't take longer than it would take to just copy the entire screen, of course. :-)
Xeda
New Member
Posts: 42
Joined: Sun 06 Feb, 2011 7:08 am

Re: BatLib

Post by Xeda »

Okay, so it has been a while since I last updated here, but I also didn't do any programming for a few weeks. Um, I tried the whole partial screen updates and it was at least 6 times faster to do that than to update the whole screen. However, other than that, I have added three commands to BatLib and 7 commands to ReCode.
So for BatLib, I added:
DelElements-This deletes some number of elements of a list at an offset
InsElements-This inserts a number of zeros into a list at a given offset
InsList-This inserts a list (which can be in archive) into another list

And then for ReCode:
sin(
cos(
2
fixed ">"
// is used to make comments
log( which doesn't work anymore x.x Gotta fix that
log(Text( which is used to display a number in a chosen base using the BatLib fixed 4x6 font

And now I have been requested to make an input routine, so I will get to work on that, hopefully :)

The screeny of the 3 new BatLib commands
Image
The download:
http://www.omnimaga.org/index.php?actio ... ttach=7202
Xeda
New Member
Posts: 42
Joined: Sun 06 Feb, 2011 7:08 am

Re: BatLib

Post by Xeda »

I introduced a new update that finally reached another goal I had :D BatLib now officially has over 100 commands! along with over 50 ReCode commands, the total number is over 150! The best part is that BatLib still fits on one app page and in fact still has more than a quarter page of free space (>4700 bytes, actually) ! I added a bunch of updates that were driven by requests and the fact that I wanted some commands for my RPG that I am working on in my spare time :) So here are the added commands, fixes, and updates:

-BatLib commands are (usually) executed at 15MHz, if possible
-ReCode starts in 6MHz mode
-dim(10 is executed at 6MHz
-Pause (in ReCode) is executed at 6MHz
-dim(44 (a sound routine) is executed at 6MHz
-Changed 'Pause While' to 'Pause If ' to prevent problems with nesting inside of a While/If...Then block
-dim(1 now also disables 'Done'

dim(12 and dim(14 now return ".ARCH" if the variable is archived
dim(15 is fixed to read archived bytes
dim(16 is now a tilemap command that can use pictures for sprites data :D

94-InsertBytes- used to insert a string of data into another var at a given offset
95-SplitUpNibbles-Used to Decompress nibble data to bytes
96-NibbleComp-Compresses LSNs of data
97-GetNibble- used to read nibbles in a var
98-WriteNibble- used to write nibble values to vars
100-BatLibRAM- used to reinstall RAM used by BatLib (for when I fix hook chaining)
101-Sub2DData- Similar to SubMatrix except using a 2D matrix of bytes (I used this for tilemap data >:D )

As a note, most commands that deal with reading data can read from archive. I say "most" because I actually didn't realise that I never fixed dim(15 (VarReadByte) to read a byte of archive and for all I know, I may have missed another command :/

Also, I will make a post about my RPG which is only just being started :)

BatLib v4.00.102.51
User avatar
Madskillz
Calc Wizard
Posts: 745
Joined: Fri 17 Dec, 2004 10:22 pm
Location: Wandering around in the Jungle...
Contact:

Re: BatLib

Post by Madskillz »

That's impressive Xeda, I'm sure some other BASIC programmers will find a use for this.
The Revolution is here...
Post Reply