News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu
avatar_geebus

Starting to learn BASIC

Started by geebus, 22:54, 22 December 18

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

geebus

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

robcfg

I think it´s pretty cool!


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

ComSoft6128

Hi geebus,

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

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

Cheers,

Peter



skylas

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!
ART WAR!
BATTLE OF LENINGRAD!
AMSTABOO!
RODOLFO SKYLARRIENTE 1 and 2!

skylas

#4

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.
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!
ART WAR!
BATTLE OF LENINGRAD!
AMSTABOO!
RODOLFO SKYLARRIENTE 1 and 2!

geebus

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.

AMSDOS

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.
* 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

skylas

Quote from: geebus on 19:11, 30 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
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!
ART WAR!
BATTLE OF LENINGRAD!
AMSTABOO!
RODOLFO SKYLARRIENTE 1 and 2!

geebus

Quote from: skylas on 02:19, 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?

skylas

#9
Quote from: geebus on 12:21, 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.
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!
ART WAR!
BATTLE OF LENINGRAD!
AMSTABOO!
RODOLFO SKYLARRIENTE 1 and 2!

geebus

What if I have the sound on repeat?

skylas

#11
Quote from: geebus on 13:04, 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
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!
ART WAR!
BATTLE OF LENINGRAD!
AMSTABOO!
RODOLFO SKYLARRIENTE 1 and 2!

mr_lou

Ok I'm jumping in.

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


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:


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

mr_lou


Powered by SMFPacks Menu Editor Mod