Original Progress Thread

Porting Richard Russell's BBC BASIC (Z80) to the TI-83+ and TI-84+ series calculators.

Moderator: benryves

User avatar
tr1p1ea
Maxcoderz Staff
Posts: 4141
Joined: Thu 16 Dec, 2004 10:06 pm
Location: I cant seem to get out of this cryogenic chamber!
Contact:

Re: Original Progress Thread

Post by tr1p1ea »

Wow, thats really cool Ben! I dont mind at all. I had high hopes for tilemapping in this and they are being fulfilled :).
"My world is Black & White. But if I blink fast enough, I see it in Grayscale."
Image
Image
User avatar
Art_of_camelot
Regular Member
Posts: 124
Joined: Sun 09 Sep, 2007 8:50 pm
Location: The dark side of the moon
Contact:

Re: Original Progress Thread

Post by Art_of_camelot »

Is there a limit to the number of character that a font set can have?
Projects:
Projects:TBA-Soonish. :)
Updated 5/3/12
User avatar
benryves
Maxcoderz Staff
Posts: 3089
Joined: Thu 16 Dec, 2004 10:06 pm
Location: Croydon, England
Contact:

Re: Original Progress Thread

Post by benryves »

Cheers, tr1p1ea. :) Here's the same program running on a BBC Micro.
Art_of_camelot wrote:Is there a limit to the number of character that a font set can have?
It's an eight-bit character set and all but the first 32 values can be changed, resulting in 224 user-definable characters. Of those only characters 128-255 should be changed, as those below 128 are the usual printable characters (eg the alphanumeric characters). This is just one way of doing tilemaps (though it is an easy and fast way, just printing strings!) - there are others (eg drawing sprites, or if worst comes to the worst custom assembly code).
User avatar
Art_of_camelot
Regular Member
Posts: 124
Joined: Sun 09 Sep, 2007 8:50 pm
Location: The dark side of the moon
Contact:

Re: Original Progress Thread

Post by Art_of_camelot »

Ok, another question. If sprites were to be used instead, where would the sprite data be stored? and how do you go about accessing it(assuming you were using BBC's sprite function)?
Projects:
Projects:TBA-Soonish. :)
Updated 5/3/12
User avatar
benryves
Maxcoderz Staff
Posts: 3089
Joined: Thu 16 Dec, 2004 10:06 pm
Location: Croydon, England
Contact:

Re: Original Progress Thread

Post by benryves »

The BBC BASIC DIM command can be used to declare arrays (eg DIM array$(9) declares an array of strings named array$ with bounds from 0 to 9 - ie, 10 elements). It can also be used to allocate memory directly, eg DIM pattern 7 would allocate 8 bytes (0 to 7) and return a pointer to that data in the variable pattern. You could use this to allocate memory for sprite data.

As for how you'd invoke the sprite command; I'm not sure. The current method is an unsightly hack on top of PLOT, but the BBC Micro's own Graphics Extension ROM (or "GXR") supported sprites so I'm probably going to modify my code to use the same methods. However, I don't know how the GXR worked and can't find any documents on it so you'll have to wait for concrete answers.
User avatar
kalan_vod
Calc King
Posts: 2932
Joined: Sat 18 Dec, 2004 6:46 am
Contact:

Re: Original Progress Thread

Post by kalan_vod »

So, how large is BBC Basic on the calc? And will you be adding a user friendly GUI, or keeping it command line?
User avatar
tr1p1ea
Maxcoderz Staff
Posts: 4141
Joined: Thu 16 Dec, 2004 10:06 pm
Location: I cant seem to get out of this cryogenic chamber!
Contact:

Re: Original Progress Thread

Post by tr1p1ea »

Im pretty sure its headed for a 3-page APP, and i doubt there will be a gui since the original features nothing of the sort afaik.
"My world is Black & White. But if I blink fast enough, I see it in Grayscale."
Image
Image
User avatar
benryves
Maxcoderz Staff
Posts: 3089
Joined: Thu 16 Dec, 2004 10:06 pm
Location: Croydon, England
Contact:

Re: Original Progress Thread

Post by benryves »

Yes, it's a 3 page app (48KB), with BBC BASIC and the BBC Micro MOS API routines on page 1; file I/O, console I/O and general TI-OS interop on page 0 and graphics routines on page 2.

I'm not sure what you'd be looking for as far as a GUI goes. If it's for editing programs the file format is documented so it would be possible to write external tools if need be. You can convert text files into BASIC programs by *EXECing them from within BBC BASIC.
User avatar
benryves
Maxcoderz Staff
Posts: 3089
Joined: Thu 16 Dec, 2004 10:06 pm
Location: Croydon, England
Contact:

Re: Original Progress Thread

Post by benryves »

For more information on the Graphics Extension ROM, which supported sprites and patterned fills, you can download a copy of the manual from J.G.Harston's website. I'll try and modify the TI-83+ version to use the same (or at least similar) techniques. This could be a little tricky with sprites...
User avatar
benryves
Maxcoderz Staff
Posts: 3089
Joined: Thu 16 Dec, 2004 10:06 pm
Location: Croydon, England
Contact:

Re: Original Progress Thread

Post by benryves »

I may have sorted out the memory limitation issue.

BBC BASIC's program memory is in the range ≥PAGE and <HIMEM. By default PAGE is set to &A100 and HIMEM is clamped to &C000. By increasing HIMEM you could give more memory to BBC BASIC and by decreasing it you could give more memory to the TI-OS for new program variables.

However, there's a problem; BBC BASIC does not know of the existance of the TI-OS. Currently memory is allocated by the host interface when it loads so that the TI-OS does not run into it, but once HIMEM is changed BBC BASIC is free to overflow this allocated memory and corrupt user variables (if HIMEM is increased) or leaves a gap that the TI-OS can't identify as free memory (if HIMEM is decreased).

To get around this problem I have created a *HIMEM OS command. For example,

Code: Select all

*HIMEM D000
would move HIMEM to &D000. As it goes via the host interface it can perform additional safety checks, relocate the stack and insert more memory to accomodate BASIC's new area. The opposite also rings true; decreasing HIMEM this way frees memory back to the TI-OS.

Decreasing HIMEM the "usual" way (decreasing it via the BASIC HIMEM pseudo-variable) has its advantages; you can use it to set aside an area of memory that isn't cleared when variables are CLEARed (eg by running a new program). For example, if you had a 2KB assembly library you could decrement HIMEM by 2KB, assemble the library to HIMEM then unload the BASIC program from memory. The assembly routine is now outside BBC BASIC's memory space (though still inside the space allocated when BBC BASIC was initialised as that has not been updated by *HIMEM) so can still be accessed.

In addition to this I have modified the EXT# function. Usually this is used to retrieve the size of a an open file handle (eg PRINT EXT#2 would display the size of the open file with a handle of 2). If you pass -1 to EXT# it returns the amount of free memory to the TI-OS (as reported by _MemChk). You could use this, for example, to allocate all of the TI-83+ free memory to BBC BASIC:

Code: Select all

OSCLI "HIMEM "+STR$~(HIMEM+EXT#-1)
User avatar
benryves
Maxcoderz Staff
Posts: 3089
Joined: Thu 16 Dec, 2004 10:06 pm
Location: Croydon, England
Contact:

Re: Original Progress Thread

Post by benryves »

I spent some time recently knocking together a minesweeper clone in BBC BASIC:
Image
(Due to a bug in Wabbitemu an error is displayed when exiting instead of a quit message; this works on later versions of Wabbitemu and hardware, but later versions of Wabbitemu don't take screenshots properly).

The source code can be found here, and will run in the free Windows version of BBC BASIC if you want to try it (Enter to "click" on cells, Delete to flag). I had to uglify the source somewhat (cramming multiple statements onto a single line, removing most comments) to fit it into the 8KB of the shareware version of BBC BASIC without triggering No room errors!
User avatar
kalan_vod
Calc King
Posts: 2932
Joined: Sat 18 Dec, 2004 6:46 am
Contact:

Re: Original Progress Thread

Post by kalan_vod »

That looks awesome! How much is that program on calc?
User avatar
benryves
Maxcoderz Staff
Posts: 3089
Joined: Thu 16 Dec, 2004 10:06 pm
Location: Croydon, England
Contact:

Re: Original Progress Thread

Post by benryves »

The file on-calculator is the same size as it is on the PC (plus a few bytes of overhead for the filename and VAT entry), so a bit under 5KB.
bwang
New Member
Posts: 25
Joined: Tue 11 Nov, 2008 7:36 pm

Re: Original Progress Thread

Post by bwang »

Looks great! When will the app be released?
User avatar
benryves
Maxcoderz Staff
Posts: 3089
Joined: Thu 16 Dec, 2004 10:06 pm
Location: Croydon, England
Contact:

Re: Original Progress Thread

Post by benryves »

Most of BBC BASIC is now usable, albeit with a few known bugs/omissions, so I hope to put together a release that can be checked by the author. Once that has been checked I can then release a series of test versions, as no doubt I've missed a few bugs. If I could at least compile the first test release before the end of this week I'd be happy. :)
Post Reply