Extending BASIC

Talk about programming CreatiVision (except games programming). Projects of homebrew hardware are also welcome.
User avatar
@username@
Posts: 320
Joined: Tue Oct 22, 2013 6:59 pm
Location: Scotland

Extending BASIC

Post by @username@ » Mon Dec 23, 2013 2:41 pm

This is about extending BASIC 83B to include new functions with relative ease.

The first problem to me was that the existing BASIC83B CART was located at $7000-$7FFF and $A000-$BFFF. This left a gap of 8K of nothing.

My solution to this was to 'rebase' the lower 4K to $9000. So now the CART is 16k in size, located at $8000-$BFFF. This gives 4K for extensions!

BASIC83B uses a table based look up to find the next reserved word. To make life easy, I also relocated this to $8000. This means there's still 100 or so bytes free at $9EFF, should we fill the extension 4k!

To assemble your own, you will need DASM, or a DASM compatible assembler.

Hopefully, the included sample function "CALL" will be enough to get you started.

CALL extension

You must include a RTS ($60) at the end of your function.

Simplest example

Code: Select all

10 POKE 640,96
20 CALL 640
PRAT Example

Code: Select all

PRAT 10,4,"HELLO WORLD!"

Syntax: PRAT column, row, output
Uses original PRINT function, so if you can print it, you can PRAT it.
Edit: v1.3 - Changed table layout and pointers, no longer need to update offsets at $Bxxx.
Edit: Fixed PEEK indexed record to $9C in offset table. Also added ? print short cut to save space, and some new equates in the .s
Edit: Speed up line load.
Edit: Added PRintAT
Edit: Added VPOKE and sprite stuff
Edit: Added VREG, VSAVE and VLOAD
Edit: Added VPK and function support
You do not have the required permissions to view the files attached to this post.
Last edited by @username@ on Thu Jan 02, 2014 6:21 pm, edited 11 times in total.
User avatar
Scouter3d
Posts: 646
Joined: Mon Jun 28, 2010 7:02 am
Location: Wien
Contact:

Re: Extending BASIC

Post by Scouter3d » Mon Dec 23, 2013 2:49 pm

So cool! Thanks!

Looking forward to all the additions!

Greetings TOM :0)
User avatar
Mobsie
Posts: 708
Joined: Fri Jun 13, 2008 10:38 am
Location: Weinheim, Germany

Re: Extending BASIC

Post by Mobsie » Mon Dec 23, 2013 2:51 pm

As all from you AMAZING!
I test the new Basic and works perfect. The "Call" was really a most missed function. Let more useful stuff come.
I try to be soon finish with my Memory Expansion, my test build work well with an old VIC-20 expansion.
Thank you
User avatar
MADrigal
Site Admin
Posts: 1189
Joined: Sun Sep 15, 2013 1:00 pm
Contact:

Re: Extending BASIC

Post by MADrigal » Mon Dec 23, 2013 6:20 pm

That's a very simple addition, but a very important one!
It's finally possible to execute machine code through the BASIC.
Thanks very much!

Great addition! :)
User avatar
@username@
Posts: 320
Joined: Tue Oct 22, 2013 6:59 pm
Location: Scotland

Re: Extending BASIC

Post by @username@ » Fri Dec 27, 2013 4:17 pm

Updates for 27 Dec 2013

* New PRintAT function.
* Fixed PEEK, LET and STOP table offsets
* Removed address selection each time a line is copied to VRAM. Speed up 41cy per byte transferred.


I'll post a kind of lazy changelog as I do them, but the latest code, asm and binary will be in the first post.
User avatar
Mobsie
Posts: 708
Joined: Fri Jun 13, 2008 10:38 am
Location: Weinheim, Germany

Re: Extending BASIC

Post by Mobsie » Fri Dec 27, 2013 4:27 pm

Another nice function, thank you.
The speed up "Removed address selection" is really impressive!
User avatar
@username@
Posts: 320
Joined: Tue Oct 22, 2013 6:59 pm
Location: Scotland

Re: Extending BASIC

Post by @username@ » Fri Dec 27, 2013 4:42 pm

The speed up sounds far more impressive than it really is!

This was the original subroutine at 9470 (7470 in 83B)

Code: Select all

ROM:9470 sub_9470:                              
ROM:9470                 LDA     #0
ROM:9472                 STA     $D1
ROM:9474
ROM:9474 loc_9474:                              
ROM:9474                                         
ROM:9474                 LDX     $D6
ROM:9476                 LDA     $D5
ROM:9478                 JSR     $FE1F
ROM:947B                 LDX     $D1
ROM:947D                 LDA     $230,X          
ROM:9480                 JSR     $FD82
ROM:9483                 CMP     #$D
ROM:9485                 BEQ     loc_9499
ROM:9487                 LDA     #$20 ; ' '
ROM:9489                 STA     $230,X         
ROM:948C                 INC     $D1
ROM:948E                 INC     $D5
ROM:9490                 BNE     loc_9474
ROM:9492                 INC     $D6
ROM:9494                 JSR     sub_94A6
ROM:9497                 BNE     loc_9474
ROM:9499
ROM:9499 loc_9499:                               
ROM:9499                 LDA     #$20 ; ' '
ROM:949B                 LDX     $D1
ROM:949D                 STA     $230,X
ROM:94A0                 INC     $D5
ROM:94A2                 BNE     locret_94AF
ROM:94A4                 INC     $D6
The "speedup" was simply to change the BNE 9474 at 9490, to a more sensible BNE 947B.

This should not cause any problems, as BIOS routine at FE1F disables interrupts, and the check for rollover is still performed.

This function takes care of storing the entered lines in VRAM for a program. The main speed increase will be seen with CLOAD/CSAVE/CRUN.
User avatar
@username@
Posts: 320
Joined: Tue Oct 22, 2013 6:59 pm
Location: Scotland

Re: Extending BASIC

Post by @username@ » Sun Dec 29, 2013 2:28 am

This update brings sprites to BASIC 83C!

By default, BASIC 83 sets the VDP to have a sprite pattern table at $800 (used for DATA temp work) and a sprite attribute table at $1300 (is erased when screen scrolls up!).

To allow sprites, the VDP initialisation has been changed to give the sprite pattern table at $0000 and the sprite attribute table at $0180. This gives 44 characters to use as sprites.

However, you don't get something for nothing. We lose CHAR 96 to 160(remember the SAT is $80 bytes), but that's a small price in my opinion, as these are non-printing and most likely would not be used.

Conveniently, you can use the CHAR command to define your sprite patterns too.

The VPOKE function is the same as POKE, but for video RAM.

Here's an example, showing how to use some sprites

Code: Select all

10   CHAR 96,0103030301030305
20   CHAR 97,0F030307070E0C06
30   CHAR 98,C0A0E0C080C0F0F8
40   CHAR 99,C0C0F07060300000
50   CHAR100,0103030301030307
60   CHAR101,030303070E0C0800
70   CHAR102,C0A0E0C080C0E0A0
80   CHAR103,C0C0C0C0C0C0C060
90   CHAR104,0103030301030305
100  CHAR105,0503030705030303
110  CHAR106,C0A0E0C080C0C0A0
120  CHAR107,A0C0E0E080800080
200  CHAR108,0003070F07A3F1F0
210  CHAR109,F0E0801C0C020000
220  CHAR110,000080980C412303
230  CHAR111,075F3F1E3E1C0800
240  CHAR112,000001030168FCFC
250  CHAR113,FCF8E00703000000
260  CHAR114,00C0E0E6C2D04800
270  CHAR115,01170F060E840000
280  CHAR116,00000000401A3F3F
290  CHAR117,7EFEF86061000000
300  CHAR118,003078F870341200
310  CHAR119,00050300C2C02000
320  CHAR120,0000006030068F0F
330  CHAR121,1F7FFE7878300000
340  CHAR122,00081C3E1C8DC4C0
350  CHAR123,C181000070300800
360  CHAR124,000000180C412303
370  CHAR125,075F3F1E3E1C0800
380  CHAR126,0000040E06A3F1F0
390  CHAR127,F0E080001C0C0000
400  CHAR128,0000206043D04800
410  CHAR129,01170F070F070200
420  CHAR130,000000020068FCFC
430  CHAR131,FCF8E08086000000
440  CHAR132,0010387970341200
450  CHAR133,0005030103010000
460  CHAR134,00000080C01A3F3F
470  CHAR135,7FFEF8E0E0C08000
480  CHAR136,000C1E3E1C8DC4C0
490  CHAR137,C081000070300800
500  CHAR138,0000006030068F0F
510  CHAR139,1F7FFE78F8702000
520  CHAR140,071F3F7F7FFFFFFF
530  CHAR141,FFFFFF7F7F3F1F07
540  CHAR142,E0F8FCFEFEFFFFFF
550  CHAR143,FFFFFFFEFEFCF8E0
900  N=12
910  VPOKE 388,88
920  VPOKE 389,120
930  VPOKE 390,N
940  VPOKE 391,4
950  VPOKE 392,88
960  VPOKE 393,120
970  VPOKE 394,44
980  VPOKE 395,1
1000 X=0
1010 Y=0
1020 M=0
1030 X=X+4
1040 VPOKE 387,15
1050 IF X < 240 THEN GOTO 1090
1060 X=0
1070 Y=Y+16
1080 IF Y>192 THEN Y=0
1090 VPOKE 384,Y
1100 VPOKE 385,X
1110 VPOKE 386,M
1120 M=M+4
1130 IF M>8 THEN M=0
1140 N=N+4
1150 IF N>40 THEN N=12
1160 VPOKE 390,N
1170 GOTO 1030
You will need to grab the binary from the first post to check it out.
You do not have the required permissions to view the files attached to this post.
User avatar
Scouter3d
Posts: 646
Joined: Mon Jun 28, 2010 7:02 am
Location: Wien
Contact:

Re: Extending BASIC

Post by Scouter3d » Sun Dec 29, 2013 7:16 am

Wow! simply wow!
User avatar
MADrigal
Site Admin
Posts: 1189
Joined: Sun Sep 15, 2013 1:00 pm
Contact:

Re: Extending BASIC

Post by MADrigal » Sun Dec 29, 2013 8:44 am

That's impressive!!!! :shock: :shock: :shock:
Post Reply