Using and improving Exbasic

Basic and Machine Language

Moderator: Moderators

wimoos
Vic 20 Afficionado
Posts: 345
Joined: Tue Apr 14, 2009 8:15 am
Website: http://wimbasic.webs.com
Location: Netherlands
Occupation: farmer

Building Wimbasic

Post by wimoos »

I have now built Wimbasic (based on the disassembled Exbasic).

I have gained approx. 60 bytes now, mainly by trimming the announcement screen, but also by:
- removing superfluous NOPs
- removing other code and data that is never touched
- rewriting pieces of code

Alongside I have fixed the following bugs:
- DUMP and MATRIX now print a sign as well
- DUMP no longer prints FN-hooks
- SPACE no longer bails out with SYNTAX error but with ILLEGAL QUANTITY error
- CEEK(x,C) works properly now
- changed ODF into OFF
- LETTER ON/OFF works properly now with different memory configurations
- Colorcodes for BORDER, GROUND, CURSOR and COKE are now accepted from 1 to 16 instead of 1 to 8

I will make this version available shortly, together with the source.

I will look into improving RENUM, but I am also thinking about kicking out commands that are probably never used, such as HARDCOPY.

Suggestions are appreciated.

Regards,

Wim.
Diddl
Vic 20 Afficionado
Posts: 425
Joined: Wed Jun 10, 2009 3:18 am

Re: Building Wimbasic

Post by Diddl »

wimoos wrote:Suggestions are appreciated.
You could expand WIM BASIC with all goods available in other extensions.

On a FE3 you don't have problems with space. You have 8KB in BLK-5 and if this isn't enough you switch to another 8K into BLK-5. A intelligent bank switcher should make it possible like in a C64 Final Cartridge, where 128KB are used.

So you could make a WIM BASIC MINI for normal Eprom Cards and a Super WIM BASIC for FE3 User. :D
carlsson
Class of '6502
Posts: 5516
Joined: Wed Mar 10, 2004 1:41 am

Post by carlsson »

Does this Basic extention accept constants in foreign bases, e.g. can you write A=$900F or B=BAND%10001000 ? Oh while you at it, an operator to do binary shifting and rotation might be nice. I know for 8-bit integers you could do this in machine code.
Anders Carlsson

Image Image Image Image Image
wimoos
Vic 20 Afficionado
Posts: 345
Joined: Tue Apr 14, 2009 8:15 am
Website: http://wimbasic.webs.com
Location: Netherlands
Occupation: farmer

Post by wimoos »

You can write A=DEC("900F"). The HEX$ function is also available.
Binary notation is not in there (yet), but could easily be added to DEC()
I myself was also thinking about XOR and MOD.
Shifting and rotation...hm...good thought.

If its the VIC chip you want to address, this can be done through VOLUME, PLAY and SOUND for audio and COLOR, GROUND, BORDER, etc. for screen.

How about sprites ?
Diddl
Vic 20 Afficionado
Posts: 425
Joined: Wed Jun 10, 2009 3:18 am

Post by Diddl »

The FE3 Wedge can evaluate HEX values preceeded by a $:

Code: Select all

 A=$1B00:B=$22+$1A+345
It looks nicer than DEC("1B00") for me
carlsson
Class of '6502
Posts: 5516
Joined: Wed Mar 10, 2004 1:41 am

Post by carlsson »

Since the VIC chip doesn't have hardware sprites, I think it would be quite a lot of code to add software sprites to the Basic extention? Indeed you have Robert Hurst's SSS library which probably could be extended with a Basic frontend, but I don't know how large that one would be.
Anders Carlsson

Image Image Image Image Image
Diddl
Vic 20 Afficionado
Posts: 425
Joined: Wed Jun 10, 2009 3:18 am

Post by Diddl »

carlsson wrote:Since the VIC chip doesn't have hardware sprites, I think it would be quite a lot of code to add software sprites to the Basic extention? Indeed you have Robert Hurst's SSS library which probably could be extended with a Basic frontend, but I don't know how large that one would be.
A lot of code wouldn't be the problem. It is a speed problem ...
User avatar
Mike
Herr VC
Posts: 4816
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Post by Mike »

Diddl wrote:
carlsson wrote:Indeed you have Robert Hurst's SSS library which probably could be extended with a Basic frontend, but I don't know how large that one would be.
A lot of code wouldn't be the problem. It is a speed problem ...
Robert's stack for itself is quite fast, witness Quikman, and Omega Fury. The later one easily sports more than a dozen sprites on screen, flicker-free.

But the surrounding program needs to be structured, and written with SSS in mind. The BASIC extension would require IRQ wedges, which take care of the movement of sprites (say, from A to B), so the BASIC program itself is relieved from that task - similar to SPRMOV in BASIC 7.0. The wedge would also manage page flips. Also, collision detection must be added. All in all quite demanding - and still rather a specialist application for a BASIC extension, IMO.

I had a few PM's exchanged with Robert regarding this very topic, but thus far we hadn't even settled at least on a stable BASIC API for SSS.

Michael
Diddl
Vic 20 Afficionado
Posts: 425
Joined: Wed Jun 10, 2009 3:18 am

Post by Diddl »

would be nice: WIM BAsic with Grafic extension + Sprite support :D
carlsson
Class of '6502
Posts: 5516
Joined: Wed Mar 10, 2004 1:41 am

Post by carlsson »

I think a Basic API to SSS would be a great way to get more users.. imagine all the games e.g. Jeff could design with smooth moving sprites. However I'm not sure it belongs in a programming-helper oriented Basic extension.
Anders Carlsson

Image Image Image Image Image
wimoos
Vic 20 Afficionado
Posts: 345
Joined: Tue Apr 14, 2009 8:15 am
Website: http://wimbasic.webs.com
Location: Netherlands
Occupation: farmer

Wimbasic available

Post by wimoos »

Wimbasic (not for FE3 yet) may be downloaded here: http://home.kpn.nl/oost4231/wimbasic.zip
Diddl
Vic 20 Afficionado
Posts: 425
Joined: Wed Jun 10, 2009 3:18 am

Post by Diddl »

many thanks for WimBasic, it's great!

Works fine in FE3 from SD and flash also.



Why old Exbasic had NOP inside?

How did Dripke and Krause made this?

With VICMON? :shock:
Leeeeee
soldering master
Posts: 396
Joined: Fri Apr 23, 2004 8:14 am

Post by Leeeeee »

The FE3 Wedge can evaluate HEX values preceeded by a $:

Code: Select all

 A=$1B00:B=$22+$1A+345
It looks nicer than DEC("1B00") for me
That should be do-able along with the % prefix for binary values. It's juat a case of some new code and changing the address for the get value from BASIC line vector.

It would also be a lot faster than performing DEC("1B00").

Lee.
User avatar
Mike
Herr VC
Posts: 4816
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Post by Mike »

Hi, Wim,
wimoos wrote:[...]I myself was also thinking about XOR and MOD.[...]
Some time ago, in another thread there had been a discussion about how to implement DIV(), and MOD() as functions of two arguments. This ultimately ended up with some source, but - unfortunately - no implementation thus far. ;)

XOR also would read in two arguments, convert them to int, perform EOR on two bytes, and convert the result to float again.

One other candidate for improvement is SQR(), which easily can be sped up 4 times by applying Heron's algorithm.

Here's the source. I've added a rounding step at the beginning to counteract a subtle bug that might happen with some arguments:

Code: Select all

.Sqrt
 JSR $DC1B             ; round FAC#1
 JSR $DC2B             ; check sign of FAC#1
 BEQ Sqrt_03           ; =0? Then end immediately! (SQR(0)=0)
 BPL Sqrt_00           ; continue, if positive, else
 JMP $D248             ; flag ?ILLEGAL QUANTITY ERROR
.Sqrt_00
 LDA $61
 STA $FB               ; remember exponent byte of argument
 AND #$01
 ORA #$80
 STA $61               ; reduce argument X to range [0.5,2.0[
 LDA #$04
 STA $FC
 LDX #Sqrt_04 MOD 256
 LDY #Sqrt_04 DIV 256
 JSR $DBD4             ; store FAC#1 (X: reduced argument) to Sqrt_04
 LDA #$BC
 LDY #$D9
 BNE Sqrt_02           ; start with Y=1 as first approximation,
.Sqrt_01               ; and loop 4 times, calculating Y=(Y+X/Y)/2.0 each turn
 LDX #Sqrt_05 MOD 256
 LDY #Sqrt_05 DIV 256
 JSR $DBD4             ; store FAC#1 (Y: intermediate result) to Sqrt_05
 LDA #Sqrt_04 MOD 256
 LDY #Sqrt_04 DIV 256
 JSR $DB0F             ; FAC#1 = X/Y
 LDA #Sqrt_05 MOD 256
 LDY #Sqrt_05 DIV 256
.Sqrt_02
 JSR $D867             ; FAC#1 = Y+X/Y (=1+X on first entry)
 DEC $61               ; divide FAC#1 by 2.0
 DEC $FC
 BNE Sqrt_01
 LDA $FB               ; calculate exponent of result
 LSR A
 ADC #$40
 STA $61
.Sqrt_03
 RTS
.Sqrt_04
 EQUB 0:EQUB 0:EQUB 0:EQUB 0:EQUB 0
.Sqrt_05
 EQUB 0:EQUB 0:EQUB 0:EQUB 0:EQUB 0
Maybe that code is useful for you extending WimBASIC.

Greetings,

Michael
Last edited by Mike on Sat Jan 30, 2010 7:40 am, edited 1 time in total.
wimoos
Vic 20 Afficionado
Posts: 345
Joined: Tue Apr 14, 2009 8:15 am
Website: http://wimbasic.webs.com
Location: Netherlands
Occupation: farmer

Post by wimoos »

Hello Michael,

I think I see possibilities for this. The code is 75 bytes, can maybe brought down to 70 bytes. Your code also contains an improvement that can be used in ODD(). This will save me another 13 bytes.

Maybe I find some time this weekend...

Regards.
Post Reply