Author Topic: Starting to learn BASIC  (Read 2158 times)

0 Members and 1 Guest are viewing this topic.

Offline geebus

  • Amateur Geek
  • Supporter
  • CPC6128
  • *
  • Posts: 188
  • Country: scotland
    • Gee-k.net
    • Awards
Starting to learn BASIC
« on: 23:54, 22 December 18 »
Hi all. I've started to (re)learn BASIC after about a 20 year gap. If i'm honest, I don't remember anything because I was about 10 years old the last time I wrote BASIC and I just copied things out of a book that we had for the family Amstrad.


I thought I'd draw my website logo that I've been working on the past couple of weeks and it took an age.
I drew it line by line...moved then drew more lines. In all I have 76 lines of code which are in fact several commands just separated with : to make better use of my screen space.


If any of you would like to see what I wrote, I made a dsk and cdt file containing the huge amount of "move:draw". Surely there's a quicker way to do it? I will admit, I did enjoy wasting time writing this and it looks so close to my 8-bit logo.
I hope i'm not the only one who is sad enough to enjoy the screen drawing out all the lines line by line.


http://www.gee-k.net/uploads/gee-k.dsk
http://www.gee-k.net/uploads/gee-k.cdt
« Last Edit: 16:16, 12 January 19 by geebus »
like
0
No reactions

Offline robcfg

  • Supporter
  • 6128 Plus
  • *
  • Posts: 2.429
  • Country: se
  • 8-Bit Technomancer
    • index.php?action=treasury
    • Awards
Re: Starting to learn BASIC
« Reply #1 on: 00:11, 23 December 18 »
I think it´s pretty cool!


I would so like to find the tape where I saved a Sigma 7 inspired screen of me...
like
0
No reactions

Offline ComSoft6128

  • ..................................
  • Supporter
  • 6128 Plus
  • *
  • Posts: 2.377
  • Country: scotland
  • CPC THEN CPC NOW
    • index.php?action=treasury
    • Awards
Re: Starting to learn BASIC
« Reply #2 on: 08:26, 23 December 18 »
Hi geebus,

You may find "The Basic Idea" by Sean McManus helpful:

https://www.sean.co.uk/books/amstrad/index.shtm

Cheers,

Peter


like
0
No reactions

Offline skylas

  • CPC6128
  • ****
  • Posts: 226
  • Country: gr
    • AMSTRAD SAKIS
    • Awards
Re: Starting to learn BASIC
« Reply #3 on: 04:06, 30 December 18 »
.
like
0
No reactions
Web: https://amstradsakis.blogspot.com
Twitter: https://twitter.com/AmstradSakis
My programs (only BASIC):
RETRO-LOADSHEET ON AMSTRAD CPC!
PENALTY KICKS!
CAPITAL QUIZ!
CAPITAL QUIZ 2! (Reverse edition)
HEADS OR TAILS (ΚΟΡΩΝΑ/ΓΡΑΜΜΑΤΑ)
HEART CHASER 1,2,3!
BARBOUTI!
STROOPIE!
BUDRUMI!

Offline skylas

  • CPC6128
  • ****
  • Posts: 226
  • Country: gr
    • AMSTRAD SAKIS
    • Awards
Re: Starting to learn BASIC
« Reply #4 on: 04:06, 30 December 18 »

Hello
Didnt see exactly what you did, but i think you can avoid using so many MOVE commands.For example:.
10 MOVE 200,200:DRAW 400,200:DRAW 400,150.
Second DRAW command connects the specific pixel with the previous point. You can also use DRAWR (the difference is that you dont give the exact pixel point, but how many pixel right/left, up/down to go.Eg (same result).
10 MOVE 200,200:DRAW 400,200:DRAWR 0,-50 (in DRAWR you can have negative numbers)
Also, if you are on an 6128 (and not 464, that means locomotive basic 1.1 instead of 1.0), you can draw only the outer and inner lines and then use FILL command in order to fill with the colour you like.Maybe there is a way that this can happen on 464, but i dont know anything more. But in 6128 it is easy, you just PLOT in the space (completely) surrounded by line and then use FILL.
« Last Edit: 14:13, 30 December 18 by skylas »
like
0
No reactions
Web: https://amstradsakis.blogspot.com
Twitter: https://twitter.com/AmstradSakis
My programs (only BASIC):
RETRO-LOADSHEET ON AMSTRAD CPC!
PENALTY KICKS!
CAPITAL QUIZ!
CAPITAL QUIZ 2! (Reverse edition)
HEADS OR TAILS (ΚΟΡΩΝΑ/ΓΡΑΜΜΑΤΑ)
HEART CHASER 1,2,3!
BARBOUTI!
STROOPIE!
BUDRUMI!

Offline geebus

  • Amateur Geek
  • Supporter
  • CPC6128
  • *
  • Posts: 188
  • Country: scotland
    • Gee-k.net
    • Awards
Re: Starting to learn BASIC
« Reply #5 on: 20:11, 30 December 18 »
thanks for the tips!
i'm using a 464 at the moment. I bought a 6128 but i've yet to receive it as it was dropped off with a friend who lives quite a distance away. I'll get it the next time he's visiting family closer to me.
I'd like to be able to code things for the 464 in the knowledge that it'll work on both systems.
I'll need to make a few more programs that do a bit more than draw things in a very long convoluted way.
Next thing i'd like to learn is how to make music play at the same time as graphics are going on screen.
like
0
No reactions

Offline AMSDOS

  • Supporter
  • 6128 Plus
  • *
  • Posts: 3.939
  • Country: au
    • index.php?action=treasury
    • Programs for Turbo Pascal 3
    • Awards
Re: Starting to learn BASIC
« Reply #6 on: 00:39, 31 December 18 »
The easiest thing to do with that Logo, is use a Sprite Driver to grab it as a sprite. Obviously you wouldn't get that same drawing process occurring, if that's part of the experience you want people to have, and it's also already extending onto the existing BASIC with a Resident System Extension (RSX). In terms of how fast it is, size of it would drop and drawing would be like drawing a sprite.

Regarding FILL, obviously people over the years have written something to simulate the command on the 464, I'm unsure which is the best one in terms of speed or accuracy, some are faster than the BASIC 1.1, though Speed may put a compromise on accuracy in terms of FILLing in all the areas and doing checks. The faster FILL routines are normally done in Assembly and come as a MC Loader in a BASIC program. A number of these programs are on CPC-Power, simply type in FILL in the Search box and a few will pop-up. I typed in one called RSX-Fill which was published in Happy Computer, which seems to be reasonable.
like
0
No reactions
* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

Offline skylas

  • CPC6128
  • ****
  • Posts: 226
  • Country: gr
    • AMSTRAD SAKIS
    • Awards
Re: Starting to learn BASIC
« Reply #7 on: 03:19, 31 December 18 »
Next thing i'd like to learn is how to make music play at the same time as graphics are going on screen.
take a look at SOUND command in the cpc manual  for sound
like
0
No reactions
Web: https://amstradsakis.blogspot.com
Twitter: https://twitter.com/AmstradSakis
My programs (only BASIC):
RETRO-LOADSHEET ON AMSTRAD CPC!
PENALTY KICKS!
CAPITAL QUIZ!
CAPITAL QUIZ 2! (Reverse edition)
HEADS OR TAILS (ΚΟΡΩΝΑ/ΓΡΑΜΜΑΤΑ)
HEART CHASER 1,2,3!
BARBOUTI!
STROOPIE!
BUDRUMI!

Offline geebus

  • Amateur Geek
  • Supporter
  • CPC6128
  • *
  • Posts: 188
  • Country: scotland
    • Gee-k.net
    • Awards
Re: Starting to learn BASIC
« Reply #8 on: 13:21, 31 December 18 »
take a look at SOUND command in the cpc manual  for sound


I've had a play around with the sound command, just unsure how to make it play sound at the same time as my logo draws for example. I've not played around with it yet. Would a GOSUB routine pause the drawing whilst the SOUND command worked away at doing it's routine?
like
0
No reactions

Offline skylas

  • CPC6128
  • ****
  • Posts: 226
  • Country: gr
    • AMSTRAD SAKIS
    • Awards
Re: Starting to learn BASIC
« Reply #9 on: 13:31, 31 December 18 »

I've had a play around with the sound command, just unsure how to make it play sound at the same time as my logo draws for example. I've not played around with it yet. Would a GOSUB routine pause the drawing whilst the SOUND command worked away at doing it's routine?
I think that if you have SOUND command first in the list and then draw the logo, it will be done at the same time. The music starts and then you see the drawing. Maybe if the duration of the SOUND commands is large, the start of drawing maybe delayed a bit, but this can be fixed i think.
« Last Edit: 13:33, 31 December 18 by skylas »
like
0
No reactions
Web: https://amstradsakis.blogspot.com
Twitter: https://twitter.com/AmstradSakis
My programs (only BASIC):
RETRO-LOADSHEET ON AMSTRAD CPC!
PENALTY KICKS!
CAPITAL QUIZ!
CAPITAL QUIZ 2! (Reverse edition)
HEADS OR TAILS (ΚΟΡΩΝΑ/ΓΡΑΜΜΑΤΑ)
HEART CHASER 1,2,3!
BARBOUTI!
STROOPIE!
BUDRUMI!

Offline geebus

  • Amateur Geek
  • Supporter
  • CPC6128
  • *
  • Posts: 188
  • Country: scotland
    • Gee-k.net
    • Awards
Re: Starting to learn BASIC
« Reply #10 on: 14:04, 31 December 18 »
What if I have the sound on repeat?
like
0
No reactions

Offline skylas

  • CPC6128
  • ****
  • Posts: 226
  • Country: gr
    • AMSTRAD SAKIS
    • Awards
Re: Starting to learn BASIC
« Reply #11 on: 16:11, 31 December 18 »
What if I have the sound on repeat?
Maybe someone more experienced may offer a better way, but i think that:If you use an AFTER subroutine (after.... gosub) you can call your subroutine after some seconds, the number of the seconds should be the duration of your sound.Not sure if this will cause a small delay in designing, maybe this depends on how long is the list of the sound subroutine.
Corr: maybe EVERY, not AFTER is better
« Last Edit: 15:53, 02 January 19 by skylas »
like
0
No reactions
Web: https://amstradsakis.blogspot.com
Twitter: https://twitter.com/AmstradSakis
My programs (only BASIC):
RETRO-LOADSHEET ON AMSTRAD CPC!
PENALTY KICKS!
CAPITAL QUIZ!
CAPITAL QUIZ 2! (Reverse edition)
HEADS OR TAILS (ΚΟΡΩΝΑ/ΓΡΑΜΜΑΤΑ)
HEART CHASER 1,2,3!
BARBOUTI!
STROOPIE!
BUDRUMI!

Offline mr_lou

  • 6128 Plus
  • ******
  • Posts: 3.206
  • Country: dk
    • index.php?action=treasury
    • 8-bit Memoirs - a Blu-ray diskmag-like eBook about the 8-bit era
    • Awards
Re: Starting to learn BASIC
« Reply #12 on: 18:07, 31 December 18 »
Ok I'm jumping in.

Basically what you want to do is to include this line in your game-loop:

Code: [Select]
ON SQ(1) GOSUB 1000 ' or whatever line your sound-routine starts

The sound-routine contains a few SOUND commands, usually read from DATA lines, before calling RETURN.

This way, the routine will only be called when necessary, and your program will run fine.

Very small example of a sound-routine:

Code: [Select]
1000 ' Simple sound-routine
1010 READ A:IF A = -1 THEN RESTORE:GOTO 1010
1020 SOUND 1,A,100,15
1030 RETURN
1040 DATA 478,239,-1
like
0
No reactions

Offline mr_lou

  • 6128 Plus
  • ******
  • Posts: 3.206
  • Country: dk
    • index.php?action=treasury
    • 8-bit Memoirs - a Blu-ray diskmag-like eBook about the 8-bit era
    • Awards
Re: Starting to learn BASIC
« Reply #13 on: 18:25, 31 December 18 »
Here's a bigger (semi recent) example.

http://www.cpcwiki.eu/forum/demos/a-small-basic-tune/
like
0
No reactions