CPCWiki forum

General Category => Programming => Topic started by: Dinoneno on 14:45, 14 March 12

Title: CPC Basic 3
Post by: Dinoneno on 14:45, 14 March 12
We have a new version of CPC Basic. It's CPC Basic 3: cpcbasic.tk (http://www.cpcbasic.tk)
Title: Re: CPC Basic 3
Post by: ervin on 15:17, 14 March 12
Wow! That is a big surprise!

I think ccz80 is absolutely brilliant, so I'm very eager to have a look at this.
(I'm poppichicken on the ccz80 forum).

How long have you been working on this?
Title: Re: CPC Basic 3
Post by: steve on 15:22, 14 March 12
I thought it was a new version of basic for the CPC :D , perhaps you could compile your basic so we can put into megaflash or a cartridge or at least load it from disk or cassette.
Title: Re: CPC Basic 3
Post by: EgoTrip on 17:56, 14 March 12
This looks interesting, thanks
Title: Re: CPC Basic 3
Post by: TFM on 18:01, 14 March 12
Quote from: Dinoneno on 14:45, 14 March 12
We have a new version of CPC Basic. It's CPC Basic 3: cpcbasic.tk (http://www.cpcbasic.tk/)

Well eahm... If I go there I get this:

Interactive Cybersecurity Training (http://phishbait.tulane.edu/)

Any mirror available?
Title: Re: CPC Basic 3
Post by: MiguelSky on 02:16, 15 March 12
Quote from: TFM/FS on 18:01, 14 March 12Any mirror available?
Try this link (http://www.telefonica.net/web2/emilioguerrero/CPCBasic/CPCBasicGe.html).
Title: Re: CPC Basic 3
Post by: TFM on 03:28, 15 March 12
Quote from: MiguelSky on 02:16, 15 March 12
Try this link (http://www.telefonica.net/web2/emilioguerrero/CPCBasic/CPCBasicGe.html).

!!!Muchas gracias!!!
Title: Re: CPC Basic 3
Post by: Dinoneno on 07:48, 15 March 12
Quote from: steve on 15:22, 14 March 12
I thought it was a new version of basic for the CPC :D , perhaps you could compile your basic so we can put into megaflash or a cartridge or at least load it from disk or cassette.


Hello. CPC Basic is an application for Windows, so it's not possible put it in a support for Amstrad CPC as a ROM, cartridge, etc. Only you can put in a DISK, CDT, etc. the result generate by CPC Basic from the program you write with it.
Title: Re: CPC Basic 3
Post by: Dinoneno on 07:59, 15 March 12
Quote from: ervin on 15:17, 14 March 12
Wow! That is a big surprise!

I think ccz80 is absolutely brilliant, so I'm very eager to have a look at this.
(I'm poppichicken on the ccz80 forum).

How long have you been working on this?


The main work is from November 2011, but it's a project in my head from many yeas ago. Maybe from 1985, when my parents buy me my Amstrad CPC  ;D ?
Title: Re: CPC Basic 3
Post by: Optimus on 19:05, 15 March 12
This is interesting for cross developing purposes. So, you code on windows and then transfer the compiled assembly code to an emulator. I am wondering if there is a wysiwyg window showing the result in windows before seeing it on the real CPC. Even if not it's interesting for people who are not familiar with C and prefer Basic and I am curious to see the speed and size of some test programs compared to my C programs. Several years ago when I was not familiar with C and enjoyed developing in basic, this would be even great for me. Now, I love C more so I am not switching, but might give it a try out of curiosity.
Title: Re: CPC Basic 3
Post by: Gryzor on 14:53, 16 March 12
This sounds mighty interesting... any screenshots? Couldn't find any on the site!
Title: Re: CPC Basic 3
Post by: ervin on 02:44, 17 March 12
It's really cool actually!
I'll be putting some screenies up shortly.
Title: Re: CPC Basic 3
Post by: Gryzor on 19:06, 18 March 12
Thanks, that'll be interesting to see :)
Title: Re: CPC Basic 3
Post by: ervin on 00:58, 19 March 12
WARNING! LONG post coming up!

Alrighty! I've been having a good look at CPC Basic 3, and I've gotta say, I'm really liking it!
For more serious stuff, I'll stick with ccz80 (also by the same dev), but for simpler stuff, CPC Basic 3 is FANTASTIC!

It's particularly good for prototyping, and for making magazine/book type-ins run about a bajillion times faster!
Your mileage may vary of course, as it still uses the same firmware routines for PRINT, PLOT, DRAW etc, but the actual program logic will be much, much quicker.

A few things to note:
CPC Basic 3 doesn't handle REAL values the same way that Locomotive Basic does.
This threw me at first, as the vast majority of the language works just like Locomotive.
In fact, I've typed up an old type-in from a book, and at least 95% of the code didn't need to change!

To handle real values, Emilio has developed a number of RSX commands, which allow you to pass in an element from a "table" of real variables. I had no idea how to get this working at first, but once I figured it out, it's actually pretty simple, and rather clever too.

If anyone wants to have a go with CPC Basic 3, and has troubles with REAL variables/values, post here and I'll do my best to help.

The website at cpcbasic.tk (http://www.cpcbasic.tk/) serves as the documentation. It needs to be read and understood, if only to learn about the differences from Locomotive. It's not too hard, and once again I'm happy to help with any questions (though I'm still learning as well!)  8)

For these screenshots, I'll be using this block of code:


10 REM Hello World!
20 RANDOMIZE TIME
30 MODE 1
40 FOR i=1 TO 10
50 LOCATE RND MOD 29+1,RND MOD 25+1
60 color=RND MOD 4
70 PAPER color:PEN (color+(RND MOD 3+1)) MOD 4
80 PRINT "Hello World!";
90 NEXT
100 PAPER 0:PEN 1:LOCATE 1,1


You'll notice a few instances of "RND MOD" in the code.
CPC Basic 3 handles RND a bit differently from Locomotive, but it is explained on the website, and is pretty simple to get working the same way.

NOTE that you can simply edit your program in a text file, and compile it using the command line (and therefore avoid the IDE entirely), and for many people that will be the preferred option. But for the more adventurous/nostalgic among us, the IDE is a lot of fun.

Okay, some screenies:

This is what you see when you run cpcbasic.exe.

(http://i69.photobucket.com/albums/i57/poppichicken/cpcbasic1.png)

Along the top of the IDE are some options:

This allows you to set the model of CPC you are targetting.

(http://i69.photobucket.com/albums/i57/poppichicken/cpcbasic2.png)

This allows you to select the output type.

(http://i69.photobucket.com/albums/i57/poppichicken/cpcbasic3.png)

And this allows you to tell the compiler how big the table of REAL values need to be.
There are also handy shortcuts to the Programs and Output folders.

(http://i69.photobucket.com/albums/i57/poppichicken/cpcbasic4.png)

Now for some cool things in the IDE.

You can type CLS to clear the screen.
It's not really a "screen", but a non-editable text window, syntax highlighted with CPC colours.
All typing is done in the white bit under the blue area.

You can click in the blue area, and use the arrow keys to move up/down through the window, to effectively see a history of what you've done.
Very handy for examining your program without having to use the LIST commands as on a real CPC.
Note that the blue section slows down if it gets too long, but can be cleared and sped up again by typing CLS.
You can also use PageUp/PageDown to move more quickly.

You can change the mode!
For example, here is the listing in mode 2 text.

(http://i69.photobucket.com/albums/i57/poppichicken/cpcbasic5.png)

The MODE commands are the same as on a real CPC.

Typing CAT lists the files in your Programs folder.

(http://i69.photobucket.com/albums/i57/poppichicken/cpcbasic6.png)

Typing LOAD"HELLO.BAS" will load that program, and it can be viewed by typing LIST.

Editing and deleting lines is done just like on a real CPC.
For example:
EDIT 80
The line will be made available to edit in the white editing area at the bottom.

(http://i69.photobucket.com/albums/i57/poppichicken/cpcbasic8.png)

Don't forget to SAVE your program periodically.
The saved file will be put into your Programs folder.

Typing RUN will compile the program according to the options you have selected at the top of the IDE.
In this example, it compiles the program, and automatically sends it to the included CPCE emulator.

(http://i69.photobucket.com/albums/i57/poppichicken/cpcbasic9.png)

Hopefully that'll be enough to get people started.
I'm really enjoying CPC Basic 3 so far, and I'm thinking of "updating" some old type-ins that I enjoyed back in the day.

Title: Re: CPC Basic 3
Post by: Gryzor on 14:36, 19 March 12
Darn, it looks so cool it makes me want to start doing stuff again :)
Title: Re: CPC Basic 3
Post by: MugUK on 15:38, 19 March 12
Now that looks like fun ;-)

Sent from my Galaxy S2 using Tapatalk.
Title: Re: CPC Basic 3
Post by: TFM on 16:46, 19 March 12
It's nice that file have date and time, but one could read it betten when data and time would be separated by a blank.
Title: Re: CPC Basic 3
Post by: Dinoneno on 19:23, 19 March 12
Quote from: TFM/FS on 16:46, 19 March 12
It's nice that file have date and time, but one could read it betten when data and time would be separated by a blank.
This problem is fixed in version 3.0.4. Dank der Beobachtung :D .
Title: Re: CPC Basic 3
Post by: MugUK on 19:20, 23 March 12
I installed this last night and tried a small listing from 'The Amazing Amstrad Omnibus' that I had bought.  OK, it didn't work due to too many INT(RND ...) statements but it was fun to type in a listing with actual line numbers.

Times have changed - for the better with my eyesight - as it was done on my 40" LCD TV via a wireless keyboard.  Looking forward to having a proper play with this once I get my 6128 :)
Title: Re: CPC Basic 3
Post by: Gryzor on 22:08, 23 March 12
BASIC programming to the next level...


Indeed, trying some listings so many years after the proper era, be it in Locomotive BASIC or GFA or what have you, is unique... :)
Title: Re: CPC Basic 3
Post by: MiguelSky on 00:11, 24 March 12
I tried Mongui from Amstrad User listings but it hangs. Probably it is due the program creates and uses some RSX.
Title: Re: CPC Basic 3
Post by: ervin on 11:15, 24 March 12
Quote from: MugUK on 19:20, 23 March 12
I installed this last night and tried a small listing from 'The Amazing Amstrad Omnibus' that I had bought.  OK, it didn't work due to too many INT(RND ...) statements but it was fun to type in a listing with actual line numbers.

Times have changed - for the better with my eyesight - as it was done on my 40" LCD TV via a wireless keyboard.  Looking forward to having a proper play with this once I get my 6128 :)

Which program did you try?
I'd like to have an attempt.
Title: Re: CPC Basic 3
Post by: ervin on 11:18, 24 March 12
Quote from: MiguelSky on 00:11, 24 March 12
I tried Mongui from Amstrad User listings but it hangs. Probably it is due the program creates and uses some RSX.

Which issue of the magazine is Mongui in?
Title: Re: CPC Basic 3
Post by: MugUK on 13:55, 24 March 12
Quote from: ervin on 11:15, 24 March 12
Which program did you try?
I'd like to have an attempt.

The Phantom Composer on pages 386 & 387.  The error message generated was:

"Unsupported function in line 100 position 5
Unsupported function in line 120 position 5
Unsupported function in line 130 position 5
Unsupported function in line 140 position 5
Unsupported function in line 160 position 21
Unsupported function in line 220 position 5
Unsupported function in line 240 position 5
Unsupported function in line 290 position 5"

Any occurrence of 'INT(RND ..) was coming up with an error.
Title: Re: CPC Basic 3
Post by: MiguelSky on 22:57, 24 March 12
Quote from: MugUK on 13:55, 24 March 12
The Phantom Composer on pages 386 & 387. Any occurrence of 'INT(RND ..) was coming up with an error.
You must to edit the lines with the INT and delete the INT as the compiles assumes they are INT by default. The RND needs fixing too. From the cpcbasic page:
QuoteThe RND function returns a value from 0 to 65535. To obtain a value in the
range  n to m must use the expression RND MOD (m - n + 1) + n. For example, to
obtain a  random value between 7 and 10 would RND MOD 4+7; for a random value
between 1  and 5 would RND MOD 5+1, for a random value between 0 and 20 would
RND MOD 21.

QuoteWhich issue of the magazine is Mongui in?
I don't know :D I used the one at ftp://ftp.nvg.unit.no/pub/cpc/games/typeins/mongui.zip (ftp://ftp.nvg.unit.no/pub/cpc/games/typeins/mongui.zip)
Title: Re: CPC Basic 3
Post by: ervin on 07:30, 26 March 12
Hmmm... Mongui looks interesting.
Seems to do some pretty cool stuff for a type-in.

Looking at the listing, I can see a few things that won't work as a direct conversion.
For example, use of RND and VAL.

If I get time, I'll try to do a conversion, and take notes of what I had to change.
(I don't know if it'll work though, especially the RSX commands in the listing!)
Title: Re: CPC Basic 3
Post by: MiguelSky on 10:52, 26 March 12
Yes, I tried changing the RND*n to RND MOD n+1 as is said at CPCbasic page. Too I tried to relocate the RSX code to &3000 as the program compiles from &4000, but no results at the moment ...   
Title: Re: CPC Basic 3
Post by: SyX on 14:31, 26 March 12
Quote from: ervin on 11:18, 24 March 12
Which issue of the magazine is Mongui in?
Mongui appeared in "Amstrad Sinclair Ocio" issue 6 (http://www.cpcwiki.eu/index.php/Amstrad_Sinclair_Ocio_06), pages 36-40  ;)
Title: Re: CPC Basic 3
Post by: ervin on 23:31, 26 March 12
Quote from: SyX on 14:31, 26 March 12
Mongui appeared in "Amstrad Sinclair Ocio" issue 6 (http://www.cpcwiki.eu/index.php/Amstrad_Sinclair_Ocio_06), pages 36-40  ;)
Thanks SyX. It's always interesting to see listings from their original printings.
Title: Re: CPC Basic 3
Post by: ervin on 23:35, 26 March 12
Quote from: MiguelSky on 10:52, 26 March 12
Yes, I tried changing the RND*n to RND MOD n+1 as is said at CPCbasic page. Too I tried to relocate the RSX code to &3000 as the program compiles from &4000, but no results at the moment ...   
As I've been trying to figure this out, I've come to the realisation that I just don't understand custom RSX commands!
:(

To make this program work, the RSX code (which I presume is in the DATA statements from lines 250 to 650) would need to be made available to the compiler somehow. i.e. the compiler would need to understand what |ON, |OFF and |PUTSPRITE mean. I have no idea how to do that.

Might be time to ask Dinoneno...
Title: Re: CPC Basic 3
Post by: MiguelSky on 23:40, 26 March 12
Perhaps changing the RSX to CALL...
Title: Re: CPC Basic 3
Post by: ervin on 05:12, 27 March 12
Yeah that'd be worth a try.
How do I go about figuring out the address of each RSX routine?
Title: Re: CPC Basic 3
Post by: Axelay on 07:42, 27 March 12
Quote from: ervin on 05:12, 27 March 12
Yeah that'd be worth a try.
How do I go about figuring out the address of each RSX routine?


If you get the BASIC program in an emu with a disassembler, have it poke the data into memory, but rather than call it, disassemble it from the point it calls.  According to the example in 'my book', the RSX firmware setup call is &BCD1 (KL LOG EXT) and BC should be pointing to a command table that starts with 2 bytes pointing to the keyword table, and is followed by a series of JP commands that should give you the direct entries for calling.  Or maybe you can just check the data statements in the BASIC listing and look for a series of the byte &c3 separated by two other bytes and try your luck using the addresses following those &c3 bytes?
Title: Re: CPC Basic 3
Post by: ervin on 07:45, 27 March 12
Excellent - thanks man.
I'll give it a go.
Title: Re: CPC Basic 3
Post by: AMSDOS on 22:37, 22 December 12

Has anyone looked at the STARS.BAS example which is included here?

The funny thing with this one is it's BASIC 1.1, one of the lines has a PLOT in it with the 4th parameter enabled for it to draw in XOR mode which is a BASIC 1.1 thing. Funny cause I had the program in 464 mode running BASIC 1.0 and it had no troubles running the program.  ;D

But the main thing I wanted to mention is the program itself. If you run that BASIC program, you get this one or two pixel moving up the screen, though I compiled it into Assembly format and compiled it (after making the code readable for the Winape Assembler), and I get this whole starfield with different layers so it looks like some stars are passing faster than other stars.  :o  I don't understand it.  :(
Title: Re: CPC Basic 3
Post by: the KING on 21:05, 10 March 15
Sorry for reopening a very old topic......


Does anyone know where to find the download and documentation for CPC Basic 3?
The website seems long gone.


Tom
Title: Re: CPC Basic 3
Post by: TFM on 21:26, 10 March 15
Try this (from link from 1st post):
http://cpcbasic.webcindario.com/download/CPCBasic.zip (http://cpcbasic.webcindario.com/download/CPCBasic.zip)


Would be really neat to have the for FutureOS too.  :)
Title: Re: CPC Basic 3
Post by: the KING on 21:38, 10 March 15
Quote from: TFM on 21:26, 10 March 15
Try this (from link from 1st post):
http://cpcbasic.webcindario.com/download/CPCBasic.zip (http://cpcbasic.webcindario.com/download/CPCBasic.zip)


Thanks!
....from the first post....? did I really miss that?     :o


Tom
Title: Re: CPC Basic 3
Post by: TFM on 21:49, 10 March 15
Haha! Had to search for the link too.  :laugh:
Title: Re: CPC Basic 3
Post by: kilon on 12:30, 11 March 15
wow this is an awesome project . I am shocked how you guys push so much forward such an old hardware . It also makes me sad because it seems that I underestimated CPC . I always saw home computer nothing more than game machines. I was not aware of all the cool software available for them like 3d apps, trackers, midi apps etc

I see now that CPC packs so much more potential.
Title: Re: CPC Basic 3
Post by: AMSDOS on 09:12, 12 March 15
Quote from: TFM on 21:26, 10 March 15
Would be really neat to have the for FutureOS too.  :)


It relies very heavily on the Firmware, but I guess FutureOS can handle a lot of the stuff found in the Firmware, or take a similar approach with how Small-C can be written to FutureOS?
Title: Re: CPC Basic 3
Post by: Devilmarkus on 15:37, 12 March 15
Great project so far!
I'd like to see examples for RSX usage...
Especially about SIN, COS, etc...

Also I don't know, if it's a bug, but am I right that you have to replace multiplications with MOD?

e.g. 1 * 2 becomes 1 MOD 2... ?!?
Title: Re: CPC Basic 3
Post by: Sykobee (Briggsy) on 22:18, 12 March 15
Very neat - I'll be interested to see the speed up on my current BASIC program, once I find a Windows machine to try it on.


Anyone else done some speed up benchmarks, especially for non-firmware stuff?
Title: Re: CPC Basic 3
Post by: ervin on 23:56, 12 March 15
The speed-ups achievable with CPC Basic 3 are HUGE.
However, that performance increase comes at a cost.

You can't translate locomotive BASIC programs to CPC BASIC 3 on a line-by-line basis.
Decimal numbers are tricky to work with, and you may have to take care with negative numbers as well.

Once you figure that out though, it is absolutely awesome.
Title: Re: CPC Basic 3
Post by: AMSDOS on 08:49, 13 March 15
The Stars Example that comes with CPC BASIC 3 does something totally different when you run it through Locomotive BASIC, and I couldn't even get a Star Travel program to work using this compiler and got a better result when I translated it to Pascal.  :laugh:
Title: Re: CPC Basic 3
Post by: AMSDOS on 23:08, 14 March 15
Quote from: ervin on 23:56, 12 March 15
The speed-ups achievable with CPC Basic 3 are HUGE.
However, that performance increase comes at a cost.

You can't translate locomotive BASIC programs to CPC BASIC 3 on a line-by-line basis.
Decimal numbers are tricky to work with, and you may have to take care with negative numbers as well.

Once you figure that out though, it is absolutely awesome.


I think the trap with regard to negative numbers is not being able to assign a variable a negative number, so something like "dir%=-1" is illegal under CPC BASIC 3, which would prevent you from doing something like x%=x%+dir% if dir% was negative. Fortunately there is more than one way to do something in BASIC and I guess that would be another example where it can be substituted with something like "x%=x%-1".
Title: Re: CPC Basic 3
Post by: TFM on 23:00, 15 March 15
Quote from: AMSDOS on 09:12, 12 March 15

It relies very heavily on the Firmware, but I guess FutureOS can handle a lot of the stuff found in the Firmware, or take a similar approach with how Small-C can be written to FutureOS?


In case of SmallC it was only needed to change some libraries. Here I don't know, have to get a closer look. But FutureOS can not do everything firmware. However it probably could work around and maybe do things a bit more quick.  :)
Title: Re: CPC Basic 3
Post by: AMSDOS on 09:04, 17 March 15
Quote from: TFM on 23:00, 15 March 15

In case of SmallC it was only needed to change some libraries. Here I don't know, have to get a closer look. But FutureOS can not do everything firmware. However it probably could work around and maybe do things a bit more quick.  :)


Well in the case of CPC BASIC 3, Assembly code generated includes a long list of Firmware "EQU" Addresses, the complete list by the looks of it (or maybe just the Firmware Instructions used by BASIC), would have been nice if it only included the ones used by the program, but I guess you can't have everything.  :D
Title: Re: CPC Basic 3
Post by: Trebmint on 10:38, 17 March 15
Not spotted CPCBasic 3 before. Looks pretty amazing. The Assembly output looks very good too, actually as good as any C compiler I've looked at. Hmmm seems I have to up my game with the Unify compiler
Title: Re: CPC Basic 3
Post by: TFM on 20:01, 17 March 15
Quote from: AMSDOS on 09:04, 17 March 15

Well in the case of CPC BASIC 3, Assembly code generated includes a long list of Firmware "EQU" Addresses... :D


That's a general huge problem of BASIC compilers. They still use all the firmware and so the gain of speed is not so much. The real gain of speed could be IMHO archieved by replacing some of the slowest firmware calls by own routines (f.e. print char etc.).


Could you please post such an assembly listing here as an example? Maybe one of your space and stars program. I'm really curious how it would look like in the assembler output.  :)
Title: Re: CPC Basic 3
Post by: Trebmint on 21:26, 17 March 15
Quote from: AMSDOS on 23:08, 14 March 15

I think the trap with regard to negative numbers is not being able to assign a variable a negative number, so something like "dir%=-1" is illegal under CPC BASIC 3, which would prevent you from doing something like x%=x%+dir% if dir% was negative. Fortunately there is more than one way to do something in BASIC and I guess that would be another example where it can be substituted with something like "x%=x%-1".


I think the main issue with negative values (looking at the output) isnt negative values, but when a negative & positive are compared. The assembly show all the logical comparisions are done with SBC HL,BC, which will require the sign to be the same for correct results



Title: Re: CPC Basic 3
Post by: AMSDOS on 07:38, 18 March 15



Quote from: Trebmint on 21:26, 17 March 15

I think the main issue with negative values (looking at the output) isnt negative values, but when a negative & positive are compared. The assembly show all the logical comparisions are done with SBC HL,BC, which will require the sign to be the same for correct results


Unfortunately I'm unsure which program I was trying to interpret for CPC BASIC 3, and now I'm unsure where I encountered trouble with negative numbers.  :(

Quote from: TFM on 20:01, 17 March 15

That's a general huge problem of BASIC compilers. They still use all the firmware and so the gain of speed is not so much. The real gain of speed could be IMHO archieved by replacing some of the slowest firmware calls by own routines (f.e. print char etc.).


Could you please post such an assembly listing here as an example? Maybe one of your space and stars program. I'm really curious how it would look like in the assembler output.  :)


I've attached a Disk Image with 3 Versions of the text version of Starscrl:


STARSCRL.BIN - CPC BASIC 3 version
STARASM.BAS - Assembly version
STARPAS.BIN - Hisoft Pascal version


The Assembly & compiled Pascal versions I made earlier seem to be operating on par with each other, but in those versions I'm using SCR HW ROLL to roll the Screen which might be why I'm getting a different result with CPC BASIC 3 version.


I've gone back to the original 10-Liner program (October 1990 ACU) and compiled that to produce the CPC BASIC 3 Version. The only change I had to make was the PLOT statement in Line 60 where:


PLOT RND*638,398,INT(RND*3)+1


becomes:


PLOT RND MOD 638,398,RND MOD 3+1


the program appears to be running a little bit faster than my Assembly/Pascal program and I tried variations with the PRINT CHR$(11)CHR$(11)  that is used to Scroll the screen. In the case of the original program it's rolling the screen twice, but when I changed that to roll the screen once, the output was still different, program still appeared faster than my Assembly/Pascal counterpart, all versions of the program show a flickery Spaceship, but in the CPC BASIC 3 version, the colour of the ship seems to be pulsating in colour (which I found annoying). Unsure if this is due to the use of LOCATE 1,1:PRINT CHR$(11)CHR$(11) though things appear to be done in a more timely in the other 2 versions, maybe because I'm using SCR HW ROLL which doesn't rely on me to Position the cursor at the top and perform a Cursor Up, though perhaps SCR HW ROLL is producing a more timely result?
Title: Re: CPC Basic 3
Post by: Trebmint on 10:00, 18 March 15
Well looking at the output all I can say is CPC Basic 3 is very well done. Quicker or equal too any C compiler on the z80. It would appear the negative values were dropped purely as the neg/pos check made it too slow in the authors eyes especially as most games would use positive values. There's no easy way to define INTs and Signed or Not in Locomotive Basic. ROM calls are always going to make output look like fast Basic programs, shame there's no sprite/graphic stuff in there too as that would make it the obvious dev choice for many coders on the cpc


It does seem to get confused with longer expressions with a few parenthesis... so better stick to short non complex type. Great program though
Title: Re: CPC Basic 3
Post by: AMSDOS on 11:01, 18 March 15
I found CPC BASIC 3 to be flexible to incorporate RSXes into compiled Binary, from that all I need to do is load the Sprite Driver, Activate that, Load the Sprite. This file (http://www.cpcwiki.eu/forum/programming/moving-graphical-images-down-the-screen/?action=dlattach;attach=10517) demonstrates the use of Sean McManus' Easi-Sprite Driver from a Compiled CPC BASIC 3 program. The result is staggering.
Title: Re: CPC Basic 3
Post by: Morri on 08:52, 19 March 15
Quote from: AMSDOS on 11:01, 18 March 15
I found CPC BASIC 3 to be flexible to incorporate RSXes into compiled Binary, from that all I need to do is load the Sprite Driver, Activate that, Load the Sprite. This file (http://www.cpcwiki.eu/forum/programming/moving-graphical-images-down-the-screen/?action=dlattach;attach=10517) demonstrates the use of Sean McManus' Easi-Sprite Driver from a Compiled CPC BASIC 3 program. The result is staggering.
Got your Easi-Sprite example and I must say this is interesting. I am going to look hard at CPC BASIC 3 and might see if I come come up with something that incorporates both together. Hmmm, what to do...
Title: Re: CPC Basic 3
Post by: AMSDOS on 10:32, 19 March 15
Quote from: Morri on 08:52, 19 March 15
Got your Easi-Sprite example and I must say this is interesting. I am going to look hard at CPC BASIC 3 and might see if I come come up with something that incorporates both together. Hmmm, what to do...


So I think to get that example compiled, I used the previous attachment from that thread (http://www.cpcwiki.eu/forum/programming/moving-graphical-images-down-the-screen/msg68876/#msg68876) which uses ESD with the Locomotive BASIC. Most of that program compiles with CPC BASIC 3, apart from having the first lines to Load ESD or the Sprite. I'm not compiling the program to Run it in the Emulator cause obviously that wouldn't work without ESD or the Sprite present, so it gets compiled as a BIN file - or to Disk, I then copied ESD & the Sprite to that Disc & made a BASIC file to load it all together. In this case the CPC BASIC BIN resides at &4000 so can be loaded first, followed by the Sprite & ESD that sit higher in memory.


I'm unsure how the introduction of ESD would impact with the other RSXs CPC BASIC 3 uses, I have a feeling it would make the other RSXs available to CPC BASIC 3 inoperable and crash the system if they depend on KL LOG EXT too. Loading ESD & Activating that would see to that if that's the case.


If that's going to be an issue, it might be worth taking a look at ESD Advanced from the BASIC Idea which uses a series of Calls depending on what you need to do (there's routines for Force, Overlay, XOR Sprite and a fine Grab Routine), CPC BASIC 3 doesn't need to rely on RSXs, simply CALLing a routine like one would from Locomotive BASIC can also be applied here. It might even be interesting to see what CPC BASIC 3 does to ESD Advanced since it comes with a little presentation.
Title: Re: CPC Basic 3
Post by: AMSDOS on 10:01, 25 March 15
Quote from: AMSDOS on 07:38, 18 March 15Unsure if this is due to the use of LOCATE 1,1:PRINT CHR$(11)CHR$(11) though things appear to be done in a more timely in the other 2 versions, maybe because I'm using SCR HW ROLL which doesn't rely on me to Position the cursor at the top and perform a Cursor Up, though perhaps SCR HW ROLL is producing a more timely result?


I haven't been able to conclude why this CPC Basic 3 code is faster than my Assembly when it's clearly using more memory than my Assembly source, unfortunately I don't have the latest Assembly Source with me.


Initially I thought that SCR HW ROLL might of had something to do with it, but even after modifying the code to use one SCR HW ROLL, the output appears to be unaffected, along with that annoying little Pulsating Spaceship.  ???


The only other clue I can see in my earlier Assembly example is I'm using 2 Frames instead of 1 (which the CPC Basic 3 has), which might be what's happening.
Title: Re: CPC Basic 3
Post by: TFM on 17:27, 25 March 15
It may be connected to the FRAME command. In detail: If it waits until the V-Sync gets reset or not. In your code IIRC you have a FRAME, then you print two chars, then FRAME again. You know what I mean?
Title: Re: CPC Basic 3
Post by: AMSDOS on 10:30, 05 April 15
Quote from: TFM on 17:27, 25 March 15
It may be connected to the FRAME command. In detail: If it waits until the V-Sync gets reset or not. In your code IIRC you have a FRAME, then you print two chars, then FRAME again. You know what I mean?


Yes it is, so once I remove the second FRAME from my Assembly version the program responds very similar to the CPC BASIC 3 version, so with a second FRAME put in after the PRINTing everything looks more timely.


So the output is very good, I had a look at the program from the code generated from Hisoft Pascal 4T and naturally found was not running quite as fast as the ASM/CPC BASIC 3 versions with one FRAME, though it's safe to say optimizations has some a long way since 1984.


It would be interesting to test out ESD Advanced under this compiler cause I recall the program having a little bit of flicking in it, unsure how Sean would feel about it, he was happy for me to use ESD in my compiled programs, though this is his demonstration program.
Title: Re: CPC Basic 3
Post by: Morri on 03:20, 06 April 15
Quote from: AMSDOS on 10:30, 05 April 15
It would be interesting to test out ESD Advanced under this compiler cause I recall the program having a little bit of flicking in it, unsure how Sean would feel about it, he was happy for me to use ESD in my compiled programs, though this is his demonstration program.
I managed to get Sean's frog demo program working with CPCBasic in only a few minutes (Hope Sean doesn't mind  ;D ). I had to delete a few lines and alter the rnd commands but it was pretty straight forward and the sprites appeared on screen nicely.
There was an increase in speed to the point where the falling frog was so flickery that you couldn't see him half the time. I added a couple of frame commands (call &bd19) and that helped but still flickery.
I've attached the dsk below but you'll see I butchered the code (deleted the scrolling message etc) but it was only to see if CPCBasic would work with ESD2's call commands (and it was a good chance to play around with CPCBasic). That side of things looks fine.
Title: Re: CPC Basic 3
Post by: AMSDOS on 10:14, 06 April 15
Quote from: Morri on 03:20, 06 April 15
I managed to get Sean's frog demo program working with CPCBasic in only a few minutes (Hope Sean doesn't mind  ;D ). I had to delete a few lines and alter the rnd commands but it was pretty straight forward and the sprites appeared on screen nicely.
There was an increase in speed to the point where the falling frog was so flickery that you couldn't see him half the time. I added a couple of frame commands (call &bd19) and that helped but still flickery.


I've just dug out the other Frame Flyback I was familiar with:



.ff
ld b,&f5

.ffl
in a,(c)
rra
jr nc,ffl



it's supposed to be faster than the old MC Frame Flyback (&BD19) routine, so it might help with the Flicker.


I started making another Bouncing Ball w/ Backdrop with ESD2, but had problems when CPC BASIC 3 was producing a program which crashed, though as I found out "FOR y%=199 TO 0 STEP -8" causes lots of problems when it gets converted into assembly and the author also states this. It wasn't critical to start from the top and work down, so changed it the other way "FOR y%=8 TO 200 STEP 8" to get a satisfactory result. Initially I thought the negative number in a variable might of been causing problems and wasn't sure how else to do it, so made a moving ball that you move with the Cursor Keys:


10 MODE 0:INK 3,15:INK 7,25:INK 8,1:INK 9,19:INK 11,4
20 FOR y%=8 TO 200 STEP 8
30 FOR x%=0 TO 152 STEP 8
40 CALL &9C40,&4500,x%,y%
50 NEXT x%:NEXT y%
60 x%=100:y%=100:oldx%=x%:oldy%=y%
70 GOSUB 170:GOSUB 200
80 WHILE INKEY(18)=-1:oldx%=x%:oldy%=y%
90 IF (INKEY(0)<>-1) AND (Y%<>198) THEN oldy%=y%:Y%=Y%+1:p%=1
100 IF (INKEY(1)<>-1) AND (X%<>144) THEN oldx%=x%:X%=X%+1:p%=1
110 IF (INKEY(2)<>-1) AND (Y%<>16) THEN oldy%=y%:Y%=Y%-1:p%=1
120 IF (INKEY(8)<>-1) AND (X%<>1) THEN oldx%=x%:X%=X%-1:p%=1
130 IF p%=1 THEN GOSUB 250:GOSUB 170:GOSUB 200
140 p%=0
150 WEND:END
160 ' Save Screen
170 CALL &9CE4,&7000,x%,y%,8,16
180 RETURN
190 ' Print Ball
200 CALL &BD19
210 CALL &9C75,&4522,x%,y%
220 CALL &BD19
230 RETURN
240 ' Restore Screen
250 CALL &BD19
260 CALL &9C40,&7000,oldx%,oldy%
270 CALL &BD19
280 RETURN



Of course when I got the routine close to correct, I had no Frame Flybacks and the ball was Flickering in some places, so I added more and got more Flicking. So if I have some time tomorrow, I might get that other Frame Flyback routine onto it.


But I think there's always going to be that to deal with when writing directly to the active screen. Most people will say it's better to write to the second screen (or have 128k) to quickly switch screens.


Quote from: MorriI've attached the dsk below but you'll see I butchered the code (deleted the scrolling message etc) but it was only to see if CPCBasic would work with ESD2's call commands (and it was a good chance to play around with CPCBasic). That side of things looks fine.


Yes I found CPC BASIC will pass parameters quite well when dealing with CALL commands working out how many parameters there are, obviously this cannot be Run in an Emulator due to using external routines to get the program to perform and I was having some problems when saving it out as a BIN file, unsure why this was happening but when I loaded the file into an Emulator, there was nothing there. So it's just easier to save as a Disk Image. And once the OUTPUT.BIN file is with the sprite data & Sprite Driver a Loader program can be used to load it all it with the OUTPUT.BIN file last.


The only other headache I had was with the Sprite Definer, I was getting some sort of Overflow error and I was following the Instructions. I made a Background (Sprite 0) called it BCKGND, but insisted it should be called BLANK which was 8x8 in size, Sprite 1 that I called BALL A was 16x16, twice I nearly lost both Sprites and was playing funny buggers when I wanted to Save the Sprite Bank, eventually I managed to get them saved. But to use ESD2 Advanced the Sprite Definer is the most direct way of making Sprites for it cause it saves the information regarding the size of the Sprite which is at the Address the routine points at.
Otherwise it's off to ESD and using the GRAB tool to capture the Sprite that's been Drawn to Screen.
Title: Re: CPC Basic 3
Post by: AMSDOS on 03:06, 07 April 15
Quote from: AMSDOS on 10:14, 06 April 15

I've just dug out the other Frame Flyback I was familiar with:



.ff
ld b,&f5

.ffl
in a,(c)
rra
jr nc,ffl



it's supposed to be faster than the old MC Frame Flyback (&BD19) routine, so it might help with the Flicker.


I modified my routine to use this Frame Flyback routine and the result I got was a Ball that moved smoothly the first few top lines and then it disappears the further down the screen I go. I've only called the routine once (Line 200) in my Print Ball. When I let go of the key though the Ball Displays itself. I remember one of Kevin's routines did that, though I think you got more of the screen with his, mine seems to be the first few lines at the top of the screen and then it disappears if you hold the key down.


Anyone know what I'm doing wrong?


Should I put a loop around that Frame Flyback routine?


Or should I just have more Frame Flyback Calls where those &BD19 were?


I can probably test this and see what I come up with.
Title: Re: CPC Basic 3
Post by: arnoldemu on 08:53, 07 April 15
The monitor beam is catching up with your deleting and then drawing code.


So as you move down, the monitor displayed the erased version before you had time to draw it.

There are ways to avoid it but the drawing becomes more complicated. delete and draw a line at a time.
Title: Re: CPC Basic 3
Post by: AMSDOS on 10:30, 07 April 15
Quote from: arnoldemu on 08:53, 07 April 15
The monitor beam is catching up with your deleting and then drawing code.

Hmmm.

QuoteSo as you move down, the monitor displayed the erased version before you had time to draw it.


Yes.

QuoteThere are ways to avoid it but the drawing becomes more complicated. delete and draw a line at a time.


I've put 2 Frame Flybacks routines (line 200) in my Print Ball routine, which gave me something that looks similar to 2 x &BD19s.


A FOR loop in line 130 before GOSUB 200 had little effect, partly because I was limited (1 to 255) and M/C Loops are so much faster than a BASIC one.


What I need is more Key Control, I tried this with SPEED KEY, but INKEY() doesn't appear to be governed by this, so I might have to go back to INKEY$() to control the Input more.
Title: Re: CPC Basic 3
Post by: Trebmint on 11:32, 07 April 15
You really need a flipped screen display. Always one of the main issues with sprites was they could just disappear or at best flicker as its hard to determine which side of the raster they are.
Using two screens you can work on the back screen and then wait until the Flyback and flip the finished screen into view. This has the advantage of basically not having to worry about ordering of screen redraw to minimize flicker, and therefore is the fastest and best looking. The obvious disadvantage is that it requires two screens.
Title: Re: CPC Basic 3
Post by: AMSDOS on 10:03, 08 April 15
Quote from: Trebmint on 11:32, 07 April 15
You really need a flipped screen display. Always one of the main issues with sprites was they could just disappear or at best flicker as its hard to determine which side of the raster they are.
Using two screens you can work on the back screen and then wait until the Flyback and flip the finished screen into view. This has the advantage of basically not having to worry about ordering of screen redraw to minimize flicker, and therefore is the fastest and best looking. The obvious disadvantage is that it requires two screens.


I'll have a look into this, though I imagine the Sprite Routine will need adjusting to accommodate writing to both screens.


At the moment I've got a fairly good result by using INKEY$ and am controlling the Speed of the Key with Speed Key, which draws a nice Smooth image of my Ball in 3/4 of the screen. But maybe it's just a fluke!  :laugh:
Title: CPC Basic 3 - Bresenham's line algorithm problem
Post by: AMSDOS on 10:37, 25 May 15

I found this BASIC routine on Rosetta Code (compatible with Locomotive BASIC) to calculate using the Bresenham algorithm which works nicely and was able to use the Fast Plot  (http://www.cpcwiki.eu/index.php/Programming:Fast_plot) for Mode 1 as well, but when I ran it though Locomotive BASIC it didn't seem any faster (probably due to the calculations involved probably), but when I tried to get this going in CPC BASIC 3, no good. I changed ABS function into it's RSX equivalent and also dropped the INT in Line 1550 since Integers are the default, but still no luck, probably the negative numbers causing problems, so I changed those to 65535 as suggested in the Manual, but still had no Luck.  I'm guessing it maybe -DY or -DX, usually in Locomotive BASIC one can use NOT instead of "-", not am not sure. Any ideas?



1500 REM === Draw a line. Ported from C version
1510 REM Inputs are X1, Y1, X2, Y2: Destroys value of X1, Y1
1520 DX = ABS(X2 - X1):SX = -1:IF X1 < X2 THEN SX = 1
1530 DY = ABS(Y2 - Y1):SY = -1:IF Y1 < Y2 THEN SY = 1
1540 ER = -DY:IF DX > DY THEN ER = DX
1550 ER = INT(ER / 2)
1560 PLOT X1,Y1:REM This command may differ depending on BASIC dialect
1570 IF X1 = X2 AND Y1 = Y2 THEN RETURN
1580 E2 = ER
1590 IF E2 > -DX THEN ER = ER - DY:X1 = X1 + SX
1600 IF E2 < DY THEN ER = ER + DX:Y1 = Y1 + SY
1610 GOTO 1560
Title: Re: CPC Basic 3 - Bresenham's line algorithm problem
Post by: arnoldemu on 11:16, 25 May 15
DX,DY etc are not integers, add % to make them integers and it'll go faster.
Title: Re: CPC Basic 3 - Bresenham's line algorithm problem
Post by: AMSDOS on 11:41, 26 May 15
Quote from: arnoldemu on 11:16, 25 May 15
DX,DY etc are not integers, add % to make them integers and it'll go faster.


Sorry I should of explained that I used DEFINT a-z and just followed the Inputs for the routine with GOSUB 1520, to draw some lines, but I was comparing the use of that PLOT with @Executioner (http://www.cpcwiki.eu/forum/index.php?action=profile;u=17) (s) Fast Plot for Mode 1, could see some improvement, but not quicker than GRA LINE ABSOLUTE, but must be the Algorithm causing the delay. I wanted to see how CPC BASIC 3 would transform it, though am having trouble translating for it. Negative variables or digits I think.
Title: Re: CPC Basic 3
Post by: ervin on 13:29, 27 May 15
Prepare to be shocked by the speed improvement!
8)

Almost a year ago, I managed to get a general bresenham routine working in ccz80.
I've converted that ccz80 code to CPC Basic 3, and I present to you the results.

I don't know if it's the same as your algorithm, but I thought you might find it interesting regardless.
Bresenham's starts at line 1000.

10 mode 1
20 border 2

30 fx1=1:fy1=199
40 fx2=0:fy2=0

50 for i=1 to 20
60 gosub 1000
70 fy1=fy1-10
80 fx2=fx2+16
90 next i

100 fx1=0:fy1=0
110 fx2=319:fy2=0

120 for i=1 to 20
130 gosub 1000
140 fx1=fx1+16
150 fy2=fy2+10
160 next i

170 fx1=319:fy1=0
180 fx2=319:fy2=199

190 for i=1 to 20
200 gosub 1000
210 fy1=fy1+10
220 fx2=fx2-16
230 next i

240 fx1=319:fy1=199
250 fx2=0:fy2=199

260 for i=1 to 20
270 gosub 1000
280 fx1=fx1-16
290 fy2=fy2-10
300 next i

310 end

1000 x=fx1
1010 y=fy1

1020 if fx2>fx1 then dx=fx2-fx1 else dx=fx1-fx2
1030 if fy2>fy1 then dy=fy2-fy1 else dy=fy1-fy2

1040 if fx1>fx2 then s1=-1 else if fx2>fx1 then s1=1 else s1=0
1050 if fy1>fy2 then s2=-1 else if fy2>fy1 then s2=1 else s2=0

1060 if dy>dx then gosub 2000 else swp=0
1070 e=dy+dy-dx

1100 for j=1 to dx
1110 plot x,y

1120 while e<32768:rem while e>=0
1130 if swp=1 then x=x+s1 else y=y+s2
1140 e=e-(dx+dx)
1150 wend

1160 if swp=1 then y=y+s2 else x=x+s1
1170 e=e+(dy+dy)

1180 next

1190 return

2000 t=dx:dx=dy:dy=t:swp=1
2010 return


For anyone interested, here is the ccz80 version.

include "cpc6128.ccz80";

byte swap;

word fx1,fy1;
word fx2,fy2;
word x,y;
word dx,dy;
word s1,s2;
word t;
word e;

mode(1);
border(2,2);

fx1=0;fy1=199;
fx2=0;fy2=0;

repeat(20)
{
    gosub BRES_LINE;
    fy1-=10;
    fx2+=16;
}

fx1=0;fy1=0;
fx2=319;fy2=0;

repeat(20)
{
    gosub BRES_LINE;
    fx1+=16;
    fy2+=10;
}

fx1=319;fy1=0;
fx2=319;fy2=199;

repeat(20)
{
    gosub BRES_LINE;
    fy1+=10;
    fx2-=16;
}

fx1=319;fy1=199;
fx2=0;fy2=199;

repeat(20)
{
    gosub BRES_LINE;
    fx1-=16;
    fy2-=10;
}

return;

BRES_LINE:

x=fx1;
y=fy1;

if (fx2>fx1)
    dx=fx2-fx1;
else
    dx=fx1-fx2;

if (fy2>fy1)
    dy=fy2-fy1;
else
    dy=fy1-fy2;

if (fx1>fx2)
    s1=-1;
else if (fx2>fx1)
    s1=1;
else
    s1=0;

if (fy1>fy2)
    s2=-1;
else if (fy2>fy1)
    s2=1;
else
    s2=0;

if (dy>dx)
{
    t=dx;
    dx=dy;
    dy=t;
    swap=1;
}
else
    swap=0;

e=dy+dy-dx;

repeat(dx)
{
    plot(x,y);

    // while e>=0
    while (e<32768)
    {
        if (swap==1)
            x+=s1;
        else
            y+=s2;

        e-=dx+dx;
    }

    if (swap==1)
        y+=s2;
    else
        x+=s1;

    e+=dy+dy;
}

return;
Title: Re: CPC Basic 3 - Bresenham's line algorithm problem
Post by: Prodatron on 15:12, 27 May 15
Can you try this?



1500 REM === Draw a line. Ported from C version
1510 REM Inputs are X1, Y1, X2, Y2: Destroys value of X1, Y1

1511 X1=X1+32768:X2=X2+32768:Y1=Y1+32768:Y2=Y2+32768

1520 DX = ABS(X2 - X1):SX = -1:IF X1 < X2 THEN SX = 1
1530 DY = ABS(Y2 - Y1):SY = -1:IF Y1 < Y2 THEN SY = 1
1540 ER = -DY:IF DX+32768 > DY+32768 THEN ER = DX
1550 ER = INT(ER / 2)
1560 PLOT X1-32768,Y1-32768:REM This command may differ depending on BASIC dialect
1570 IF X1 = X2 AND Y1 = Y2 THEN RETURN
1580 E2 = ER
1590 IF E2+32768 > -DX+32768 THEN ER = ER - DY:X1 = X1 + SX
1600 IF E2+32768 < DY+32768 THEN ER = ER + DX:Y1 = Y1 + SY
1610 GOTO 1560


Didn't test it, but it could solve the problem when comparing negative with positive integers?
Title: Re: CPC Basic 3 - Bresenham's line algorithm problem
Post by: AMSDOS on 11:51, 29 May 15
Quote from: Prodatron on 15:12, 27 May 15
Can you try this?



1500 REM === Draw a line. Ported from C version
1510 REM Inputs are X1, Y1, X2, Y2: Destroys value of X1, Y1

1511 X1=X1+32768:X2=X2+32768:Y1=Y1+32768:Y2=Y2+32768

1520 DX = ABS(X2 - X1):SX = -1:IF X1 < X2 THEN SX = 1
1530 DY = ABS(Y2 - Y1):SY = -1:IF Y1 < Y2 THEN SY = 1
1540 ER = -DY:IF DX+32768 > DY+32768 THEN ER = DX
1550 ER = INT(ER / 2)
1560 PLOT X1-32768,Y1-32768:REM This command may differ depending on BASIC dialect
1570 IF X1 = X2 AND Y1 = Y2 THEN RETURN
1580 E2 = ER
1590 IF E2+32768 > -DX+32768 THEN ER = ER - DY:X1 = X1 + SX
1600 IF E2+32768 < DY+32768 THEN ER = ER + DX:Y1 = Y1 + SY
1610 GOTO 1560


Didn't test it, but it could solve the problem when comparing negative with positive integers?


Unfortunately that gave me something which started drawing a Line one way & then back onto itself (what what it appeared). I altered the -1 that SX & SY have in Lines 1520 & 1530 which almost gave me the result I was after, but froze. I tried this in Locomotive BASIC prior to that which gave me an overflow error, this appeared to be the same.




1500 REM === Draw a line. Ported from C version
1510 REM Inputs are X1, Y1, X2, Y2: Destroys value of X1, Y1

1511 X1=X1+32768:X2=X2+32768:Y1=Y1+32768:Y2=Y2+32768

1520 DX = ABS(X2 - X1):SX = 32768:IF X1 < X2 THEN SX = 1
1530 DY = ABS(Y2 - Y1):SY = 32768:IF Y1 < Y2 THEN SY = 1
1540 ER = -DY:IF DX+32768 > DY+32768 THEN ER = DX
1550 ER = ER / 2
1560 PLOT X1-32768,Y1-32768:REM This command may differ depending on BASIC dialect
1570 IF X1 = X2 AND Y1 = Y2 THEN RETURN
1580 E2 = ER
1590 IF E2+32768 > -DX+32768 THEN ER = ER - DY:X1 = X1 + SX
1600 IF E2+32768 < DY+32768 THEN ER = ER + DX:Y1 = Y1 + SY
1610 GOTO 1560




But thanks trying anyway.


@ervin (http://www.cpcwiki.eu/forum/index.php?action=profile;u=82) I'll eventually get around to looking at your routine, if it's speedy with an ordinary PLOT, the fast plot will probably send it off it's head.
Title: Re: CPC Basic 3
Post by: rk last on 19:23, 26 July 16
Im a newbie to CPCBASIC and have experienced a problem whilst trying to run circle.bas.

After typing run, the CPCE emulator opens with call &4000 displayed.  Pressing RETURN runs the program and ends with a syntax error????
Title: Re: CPC Basic 3
Post by: AMSDOS on 01:22, 27 July 16
So is the program returning to basic or just producing some weird syntax error loop?

If it's looping then perhaps it needs an end command at the exit point of the program to tell cpcbasic to return to basic?
Title: Re: CPC Basic 3
Post by: ervin on 02:06, 27 July 16
Quote from: rk last on 19:23, 26 July 16
Im a newbie to CPCBASIC and have experienced a problem whilst trying to run circle.bas.

After typing run, the CPCE emulator opens with call &4000 displayed.  Pressing RETURN runs the program and ends with a syntax error? ???


My apologies if this is a silly question, but are you compiling the program before RUNning it?

Title: Re: CPC Basic 3
Post by: Morri on 05:45, 27 July 16
The circle routine uses REAL numbers so before you "RUN" the program to the emulator, make sure that you change the "real numbers" box to 4.
This will ensure the program runs correctly. I have checked and got it to work using this method.
Title: Re: CPC Basic 3
Post by: rk last on 11:38, 27 July 16
Quote from: AMSDOS on 01:22, 27 July 16
So is the program returning to basic or just producing some weird syntax error loop?

If it's looping then perhaps it needs an end command at the exit point of the program to tell cpcbasic to return to basic?

The program switches to mode 2 and then presents the error message.
Title: Re: CPC Basic 3
Post by: rk last on 11:40, 27 July 16
Quote from: ervin on 02:06, 27 July 16

My apologies if this is a silly question, but are you compiling the program before RUNning it?

Ive loaded the program, then type RUN, the emulator opens with the CALL command displayed.  Pressing RETURN runs the code in mode 2 and then error message appears. 
Title: Re: CPC Basic 3
Post by: rk last on 11:49, 27 July 16
CPC TYPE: 6128
OUTPUT: Run in Emulator
REAL NUMBERS: 4
PROGRAM: Circle

I type in RUN and the emulator appears with the CALL command.  After pressing RETURN nothing happens now?
Title: Re: CPC Basic 3
Post by: ervin on 13:37, 27 July 16
Hmmm, that's really strange that you're not able to run it.

Technically, Real Numbers should be set to 6, as there are 6 real values in the program, with indexes from 1 to 5.
I'm not having any troubles running the program.

Are you able to upload a screenshot of your CPC BASIC 3 editor window, with the code to circle.bas listed?
Title: Re: CPC Basic 3
Post by: rk last on 17:47, 27 July 16
First of all, may I thank you guys  for the help and support.  Secondly, things got worse after trying your suggestions where I could no longer list the code.  Also, the browser window that lists the basic programs remains fixed over the CPCBASIC window after selecting my choice.

So I deleted the BASIC folder and unzipped it again.  Same issues returned so in the end I restored my pc to an earlier date and have just unzipped the folder again.  I`m using Windows 10.  Upon clicking on the CPCBASIC icon, Windows warns me about an unknown program.  I clicked ignore and open.  Now when I pick the circle program Windows asks me what to open it with.  I am correct in browsing for the CPCBASIC icon?  I ask because Ive gone no further than this and wont until Ive passed this by you guys.

Thanks again.
Title: Re: CPC Basic 3
Post by: rk last on 19:33, 27 July 16
[attachimg=1]
[attachimg=2]
[attachimg=3]
[attachimg=4]

Title: Re: CPC Basic 3
Post by: Morri on 20:35, 27 July 16
Here are the steps I used.
My guess is you're forgetting step 2 as opening by clicking on the circle.bas from explorer won't work, it must be from in CPC BASIC 3.
Just remember that the bottom white box is where all the editing is done. The part that looks like an original CPC screen is only for reviewing. The cool part is once a program is listed you can click in that area and scroll right up through the listing. However if you want to edit anything, you have to go back to the white box at the bottom and type edit 100 etc... It's a bit different to start with and get your head around but once you get used to it i find it excellent to use.
Title: Re: CPC Basic 3
Post by: rk last on 20:46, 27 July 16
You were correct.  I was missing out step 2  :doh:

Thank you Morri and apologies for taking up your time.
Title: Re: CPC Basic 3
Post by: Morri on 21:03, 27 July 16
No worries, here to help. Just as a side, have a look at a game I made using CPC BASIC 3 to see it's capabilities.
Let's GO! (http://www.cpc-power.com/index.php?page=detail&num=12550)
It was made using a combination of CPC BASIC 3 and an old sprite driver made by Sean McManus called Easy Sprite driver.
The speed difference is amazing once the program is compiled so CPC BASIC 3 is worth learning if you are not assembly savvy (like myself).
Title: Re: CPC Basic 3
Post by: rk last on 21:22, 27 July 16
Thats a cool demonstration of what basic 3 can achieve.  I also liked the robocod theme - reminded me of my amiga days :)  Im defintely going to have a stab at producing a game using the new basic.

Back in the day I managed two loco basic games.  A mode 1 submarine game with detailed redefined text graphics - bubbles, shells, fish, ships etc. And a mode 0 platformer that i coded after playing the cassette 50 game - fantasy land.

Hey!  You ended up getting a review @ CPC Game reviews by the mysterious Missas :)  Whenever I tried to review a new game there, Nicholas would always tell me that I had been beaten to the review...grrrr.  I reviewed games there under the name: Pug.
Title: Re: CPC Basic 3
Post by: ervin on 01:46, 28 July 16
@rk last (http://www.cpcwiki.eu/forum/index.php?action=profile;u=1820) Excellent! That's great that you got it working.

One thing to remember about CPC BASIC 3 (and also ccz80 which CPC BASIC 3 code gets converted into during compilation), is that it can't handle signed numbers. i.e. handling negative numbers can be a tricky business.

The RSX commands implemented by Dinoneno (like |REAL etc.) may handle negative numbers, but normal CPC BASIC 3 variables can't.
Please check out my forum post from a few years ago; it contains some tips on getting started with CPC BASIC 3.
CPC Basic 3 (http://www.cpcwiki.eu/forum/programming/cpc-basic-3/msg39631/#msg39631)

@Morri (http://www.cpcwiki.eu/forum/index.php?action=profile;u=95) - am I correct?
Did you have to have workarounds for negative numbers in your game?
Or am I totally wrong?
Title: Re: CPC Basic 3
Post by: Morri on 02:59, 28 July 16
Quote from: ervin on 01:46, 28 July 16
@Morri (http://www.cpcwiki.eu/forum/index.php?action=profile;u=95) - am I correct?
Did you have to have workarounds for negative numbers in your game?
Or am I totally wrong?
No, from memory, I just didn't use negative numbers. I think "x=x-1" etc was OK and I might have even had STEP -1 (would have to check my source) but as long as the result wasn't a negative CPC BASIC was OK.
I managed to avoid using those RSX extensions in CPC BASIC and only used integers as well.
Title: Re: CPC Basic 3
Post by: genesis8 on 23:40, 25 December 16
Just  sure, Dinoneo is simply Emlio Guerrero ?
Title: Re: CPC Basic 3
Post by: cpcuser on 10:35, 26 December 16
Circleplot with ccz80++ and Integer-Table.




include Indirections6128.ccz80++
include Text.ccz80++
include Keyboard.ccz80++
include Graphics.ccz80++

class Test
{
 
  static int tg_curx, tg_cury, sign, theta,grad;
   static int wert,deltax,deltay,length,x,y,xp,yp;
   
  static short winkel[] = {
         0   ,  2  ,   4  ,   7  ,   9,
         11  ,  13  ,  16  ,  18  ,  20,
         22  ,  24  ,  27  ,  29  ,  31,
         33  ,  35  ,  37  ,  40  ,  42,
         44  ,  46  , 48   , 50   , 52,
         54  ,  56   , 58  ,  60   , 62,
         64  ,  66  ,  68  ,  70   , 72,
         73  ,  75  ,  77  ,  79  ,  81,
         82  ,  84  ,  86  ,  87  ,  89,
         91  ,  92  ,  94  ,  95  ,  97,
         98  ,  99  ,  101 ,  102 ,  104,
         105  , 106 ,  107  , 109  , 110,
         111  , 112 ,  113  , 114  , 115,
         116 ,  117 ,  118  , 119  , 119,
         120  , 121 ,  122  , 122  , 123,
         124  , 124 ,  125  , 125  , 126,
         126 ,  126 ,  127  , 127 ,  127,
         128 ,  128 ,  128  , 128 ,  128,
         128 };
         
  static void main()   
  {   
      short a;
     
      Graphics.GraphicsMode(1);
      Graphics.Clg();
     
     while(1)
      {
         a=Keyboard.Inkey();     
         
         if(a=='d')
         { 
           Text.Locate(15,12);
          Text.PrintString("ein Kreis...");   
           
           for (grad = 0; grad <= 360; ++grad)
          {
               x=320;
               y=200;
               length=190;     
               wink_plot();                 
          }   
       }     
    }   
  }


  static void tg_isin()
  {
     sign=1;
      theta=grad;
     
     if(theta>180)
     {
       theta=360-theta;
       sign=-1;
     }
     
      if(theta>90)
      {
         theta=180-theta;
      }
      wert=sign*winkel[theta];
   }
   
   static void tg_icos()
  {
     sign=1;
      theta=grad;
     
      if(theta>180)
      {
        theta=360-theta;
      } 
     
      if(theta>90)
      {
         theta=180-theta;
         sign=-1;
      }
      wert=sign*winkel[90-theta];
   }
   
   static void wink_plot()
   {     
      tg_curx=x << 7;
      tg_cury=y << 7;
     
      tg_isin();
      deltay=length*wert;
      tg_icos();
      deltax=length*wert;
   
      tg_curx=tg_curx+deltax;
      tg_cury=tg_cury-deltay;
   
      xp=tg_curx >> 7;
      yp=tg_cury >> 7;
     
      Graphics.Plot(xp,yp);
   }
}



Greeting
Title: Re: CPC Basic 3
Post by: AMSDOS on 07:37, 27 December 16
Quote from: cpcuser on 10:35, 26 December 16
Circleplot with ccz80++ and Integer-Table.



10 ccz80=0:cpcbasic3=1
20 while ccz80<>cpcbasic3
30   print"Try Again?"
40 wend
Powered by SMFPacks Menu Editor Mod