I need to make this

The place for codemasters or beginners to talk about programming any language for the Spectrum.
Eugene C.
Drutt
Posts: 28
Joined: Wed Jul 17, 2019 2:47 pm

I need to make this

Post by Eugene C. »

Anyone can help me? I need to write text from bottom to top with can can music.
For example:
Spoiler
User avatar
PeterJ
Site Admin
Posts: 6854
Joined: Thu Nov 09, 2017 7:19 pm
Location: Surrey, UK

Re: I need to make this

Post by PeterJ »

What experience have you of Spectrum programming?

https://zxart.ee/eng/authors/d/davos/can-can/
Eugene C.
Drutt
Posts: 28
Joined: Wed Jul 17, 2019 2:47 pm

Re: I need to make this

Post by Eugene C. »

This is "my" version of Can Can:
https://gofile.io/?c=XdiZmK
I don't have any experience of programming. :(
Ralf
Rick Dangerous
Posts: 2279
Joined: Mon Nov 13, 2017 11:59 am
Location: Poland

Re: I need to make this

Post by Ralf »

Do you want to use for sound AY or beeper?

Does the text have to scroll or may it just appear line by line?

The simplest way for anybody not skilled in programming would be probably a very simple program in Basic made of long list of PRINT and BEEP/SOUND instructions. Would it be enough for you?
Eugene C.
Drutt
Posts: 28
Joined: Wed Jul 17, 2019 2:47 pm

Re: I need to make this

Post by Eugene C. »

Beeper. Line by line.
Like this:
Spoiler
With basic the program stop.
User avatar
ZXDunny
Manic Miner
Posts: 498
Joined: Tue Nov 14, 2017 3:45 pm

Re: I need to make this

Post by ZXDunny »

As I explained via Email, you can't do this from BASIC. You need an interrupt-driven sound program which runs while the BASIC runs. The text part is easy enough, the speccy will even scroll the screen for you. But you can't use BEEP.
AndyC
Dynamite Dan
Posts: 1388
Joined: Mon Nov 13, 2017 5:12 am

Re: I need to make this

Post by AndyC »

Well you could BEEP one note, print some text, then BEEP the next. Will probably sound even more staccato and be jerkier than the manic Miner title music though.
User avatar
ZXDunny
Manic Miner
Posts: 498
Joined: Tue Nov 14, 2017 3:45 pm

Re: I need to make this

Post by ZXDunny »

Yes. You're better off using something like Beepola though, IMO. At least one of the music players can do interrupt-generated music iirc.
Ralf
Rick Dangerous
Posts: 2279
Joined: Mon Nov 13, 2017 11:59 am
Location: Poland

Re: I need to make this

Post by Ralf »

Yes, when Basic is playing BEEP, nothing else may be done at the same time.

So you need to do BEEP PRINT BEEP PRINT BEEP PRINT and so on :)

Or if you want to make it much shorter and prettier but also a little bit advanced you may use a loop.

Store note values and texts in DATA instruction
Use READ to get the values.

See here:
http://www.worldofspectrum.org/ZXBasicM ... chap6.html
AndyC
Dynamite Dan
Posts: 1388
Joined: Mon Nov 13, 2017 5:12 am

Re: I need to make this

Post by AndyC »

ZXDunny wrote: Thu Jul 18, 2019 10:12 am Yes. You're better off using something like Beepola though, IMO. At least one of the music players can do interrupt-generated music iirc.
Better off by a country mile. It's hard to argue you are not "better off" by avoiding Sinclair BASIC entirely though. :lol:
User avatar
ZXDunny
Manic Miner
Posts: 498
Joined: Tue Nov 14, 2017 3:45 pm

Re: I need to make this

Post by ZXDunny »

AndyC wrote: Thu Jul 18, 2019 12:11 pm
ZXDunny wrote: Thu Jul 18, 2019 10:12 am Yes. You're better off using something like Beepola though, IMO. At least one of the music players can do interrupt-generated music iirc.
Better off by a country mile. It's hard to argue you are not "better off" by avoiding Sinclair BASIC entirely though. :lol:
Given that the text output part can be done in about four or five lines of BASIC, and the music being the most complex part of the problem... Yeah, you're right :)
Ralf
Rick Dangerous
Posts: 2279
Joined: Mon Nov 13, 2017 11:59 am
Location: Poland

Re: I need to make this

Post by Ralf »

I believe Basic is the best solution for the original poster as he doesn't have much experience with programming.

I could never understand why in beginner's threads like this one people are suggesting advanced solutions which involve assembler etc.
You don't help the poster this way, just make him confused.
AndyC
Dynamite Dan
Posts: 1388
Joined: Mon Nov 13, 2017 5:12 am

Re: I need to make this

Post by AndyC »

Ralf wrote: Thu Jul 18, 2019 2:36 pm I believe Basic is the best solution for the original poster as he doesn't have much experience with programming.

I could never understand why in beginner's threads like this one people are suggesting advanced solutions which involve assembler etc.
You don't help the poster this way, just make him confused.
I thought it was obvious I was half joking, however there is a point to it. Sinclair BASIC is very limited in it's capabilities, particularly for things like sounds, and even a skilled developer will quickly run into significant stumbling blocks trying to do something like this. There is a point at which you simply have no choice but to at least partly adopt machine code routines or limit your ambitions significantly.

It's probably easier to learn and code the solution to this in assembly than to engineer a purely BASIC solution to it.
User avatar
ZXDunny
Manic Miner
Posts: 498
Joined: Tue Nov 14, 2017 3:45 pm

Re: I need to make this

Post by ZXDunny »

I've already told him how to do the text. I've already told him the only way to get acceptable music. The text can be done in BASIC, the music cannot.

What do you suggest in order to achieve his goals in pure BASIC? I'd be interested to know what about Sinclair BASIC that I've missed.
User avatar
1bvl109
Dizzy
Posts: 98
Joined: Tue Jun 04, 2019 9:00 pm

Re: I need to make this

Post by 1bvl109 »

Ralf wrote: Thu Jul 18, 2019 2:36 pm I could never understand why in beginner's threads like this one people are suggesting advanced solutions which involve assembler etc.
You don't help the poster this way, just make him confused.
I think this is purely cultural.
BASIC is a descendent of FORTRAN, a language aimed at mathematicians doing numerical mathematics.
PLOT is aimed at people having a grasp of Cartesian coordinates.
BASIC is for the kids, who are good in math. Especially they had to have math already.
I can explain this

Code: Select all

ld hl,%0100000000000000
ld (hl),%10101010
to a kid who can somewhat read.
I can demonstrate what it does on graph paper and on the Spectrum.
I can explain this

Code: Select all

21,%0100000000000000
36,%10101010
to a kid who can distinguish 0 to 9 and A to F.
I can explain this

Code: Select all

00100001,%0100000000000000
00110110,%10101010
to a kid who can distinguish 0 and 1 and do some basic logical thinking. What about the 00100001? Oh well dear. This is just a kind of word the computer understands. It is like us assigning words to things we do, like "eat", to talk about them.

Now write a BASIC program to plot four points as above and see what concepts you need to introduce to explain them.

There is no IDE for assembler for kids, because we already "know" that this would be to complicated for them.

Next thing we will do is teaching R in kindergarten.

Weizenbaum was right. We're all batshitcrazy. We don't see the obvious.
"Truth would quickly cease to be stranger than fiction, once we got used to it." - H.L. Mencken
User avatar
PeterJ
Site Admin
Posts: 6854
Joined: Thu Nov 09, 2017 7:19 pm
Location: Surrey, UK

Re: I need to make this

Post by PeterJ »

Ii think it would have taken me much longer to get a grasp of Spectrum specific assembler, if I had not learnt BASIC first.

I agree with [mention]Ralf[/mention]
User avatar
1bvl109
Dizzy
Posts: 98
Joined: Tue Jun 04, 2019 9:00 pm

Re: I need to make this

Post by 1bvl109 »

PeterJ wrote: Thu Jul 18, 2019 8:28 pm Ii think it would have taken me much longer to get a grasp of Spectrum specific assembler, if I had not learnt BASIC first.
https://www.youtube.com/watch?v=WeiufBduVE8
But isn't this just a case of knowing any computer language helps to learn any other one?
"Truth would quickly cease to be stranger than fiction, once we got used to it." - H.L. Mencken
User avatar
ZXDunny
Manic Miner
Posts: 498
Joined: Tue Nov 14, 2017 3:45 pm

Re: I need to make this

Post by ZXDunny »

I'm not sure tbh.

You could explain that a value in binary equates to a value in decimal. You could explain hex. You could explain how a byte is represented on the screen, as 8 dots. You could then spend a while explaining to the child how the screen layout works - the thirds, how each line is 8 pixels below the last (until you cross a third boundary). You could explain that the screen is just a region of memory, that it sits at $4000 but you can't actually POKE $4000, you have to convert to decimal. You would then explain that in order to plot a single point you need to get the correct bit pattern and use logical ops to remove other bits or set the one you want. And then finally explain that they need to go back to the thirds/8 pixel gap and what they need to do to convert a Y coordinate to a row and then figure out which bit to set to add to the byte that contains their desired x coordinate.

Or you could explain that PLOT x,y will do the same job.

Disclaimer: I'm teaching my seven year old son to code; there's no way he'll grasp asm when he is just now figuring out how binary works. BASIC first, then the hard stuff (machine code) much later.
AndyC
Dynamite Dan
Posts: 1388
Joined: Mon Nov 13, 2017 5:12 am

Re: I need to make this

Post by AndyC »

You can learn BASIC faster than assembly, that is literally the point of it. But Sinclair BASIC is a crap implementation, it's mind bogglingly slow and extremely feature lacking (really only the C64's half-implementation is worse).

You can do a handful of things easily, but once you cross certain lines it works against you and you will have to either resort to some machine code or engineer a massively more complex solution to retain a pure BASIC program. Playing audio alongside display updates is very definitely in that category.
User avatar
PeterJ
Site Admin
Posts: 6854
Joined: Thu Nov 09, 2017 7:19 pm
Location: Surrey, UK

Re: I need to make this

Post by PeterJ »

I agree about the speed issue [mention]AndyC[/mention], but I was always impressed with the screen$ and attr functions in Spectrum BASIC, especially for beginner game developers.

I know the likes of MSX had sprites, but with the chip they used you could only tell there had been a collision, but not with what.

I had a C64 for a while and trying to follow those control codes in badly printed magazine listings. Ohh my word!
Ralf
Rick Dangerous
Posts: 2279
Joined: Mon Nov 13, 2017 11:59 am
Location: Poland

Re: I need to make this

Post by Ralf »

I always believed and still believe Spectrum Basic is quite good.

You can easily mix text and graphics. You can easily use colour. You can declare your variables anywhere with any names.
You can use UGD. Believe me it's not granted and many Basic dialects miss this or that functionality.
User avatar
ZXDunny
Manic Miner
Posts: 498
Joined: Tue Nov 14, 2017 3:45 pm

Re: I need to make this

Post by ZXDunny »

I have to agree to disagree with AndyC - Sinclair BASIC served me very well for years and I loved it. Yes, it was slow but being able to produce programs with similar graphics to the games (with character movement and general slowness etc) was amazing.

I loved it so much, I remade the BASIC for PCs. I still love it.
User avatar
1bvl109
Dizzy
Posts: 98
Joined: Tue Jun 04, 2019 9:00 pm

Re: I need to make this

Post by 1bvl109 »

ZXDunny wrote: Thu Jul 18, 2019 10:55 pm You could explain that a value in binary equates to a value in decimal.
No need. There are simply bits and they go into an array of the computer we can see. In two steps.

And the Great Programmer said, Let there be 1: and there was 1. And the Great Programmer saw the 1, that it was good: and the Great Programmer divided the 1 from the 0*. And the Great Programmer called the 1 white, and the 0 he called Black. And the evening and the morning were the first day of your class schedule.
ZXDunny wrote: Thu Jul 18, 2019 10:55 pmYou could explain that the screen is just a region of memory, that it sits at $4000 but you can't actually POKE $4000, you have to convert to decimal.
I'm not using POKE, it's a false God invented by the Decimalist sect. May the Great Programm have mercy on them, though them Perverts surely don't deserve any mercy, for they are wicked in their hearts. But this just shows how incredible merciful he is.
ZXDunny wrote: Thu Jul 18, 2019 10:55 pm And then finally explain that they need to go back to the thirds/8 pixel gap ...
It is a common misconception that us true members of the Great Assembly of the Great Assembly refuse to use code we have not written. We are not even recursive at all times, because we are only recursive in times in which we are recursive.

Maybe you are not asked to explain, some sinister PLOT - where do you even get the idea, that toddlers know of such things? Gunpowder and treason be on you! -, but how things move on the screen. There is thing called INC (or use the opcode, if you don't want to bother the kid with the somewhat strange concept of letters) this INC gives us the position right of the former one. We already know how to make patterns appear. Now the pattern has doubled. So we use our power of making black and white in His name, to white the left one out. .

And what actually is INC. Well it is simply an add ... aaaah ... you are not getting me that easily.

INC simply is replacing the 0 that is in the rightmost position with 1.
There most be a 0, 'cus otherwise there'd be a 1. And there cant' be a 1 because ... oh sh*t**.
Ok, this can actually happen. Than we change the 1 to a 0, and see, if we can a execute our cunning plan on the 0 on the left hand side. WHAT? Yeah ... yeah ... that actually could be 1, but look, just how probable ... ok ... ok we set it to 0 and we set the 0 left to this one to ... Oh come on now! You are just doing this on purpose. I don't have to respond to these obscene demands. Oh every gracious Great Programmer help me, as I'm tortured by evil spirited BASICERS. Yeah, that's a pleonasm. So what? ... Back to the the facts now please, for we of the Great Assembly feel only abhorrence towards pompous talk. Well, you just do as described with the 0 left to that and - ha! I foresaw this chicanery - if there should be a 1 you go one like this What? Still question? What if all the bits are 1s? Your' done. And that's that.

Simply https://www.youtube.com/watch?v=dFtLONl4cNc believe me that solves an awful lot of problems, at least you will instantly feel better.
ZXDunny wrote: Thu Jul 18, 2019 10:55 pm Or you could explain that PLOT x,y will do the same job.
To give the job description the child already has to understand Cartesian coordinates.
They are not even the target audience.

And honestly, how often did you see a child ask you how to draw a line between points on the screen instead of - say - asking how a video game works. And if the question is about lines, will you hear decimal numbers or will they point to the screen?
ZXDunny wrote: Thu Jul 18, 2019 10:55 pm Disclaimer: I'm teaching my seven year old son to code; there's no way he'll grasp asm when he is just now figuring out how binary works. BASIC first, then the hard stuff (machine code) much later.
Because he already accepted decimal as the norm. Shouldn't us freaks know best that BCD is a senseless complicated way to internally represent numbers, only of value in special cases e.g. if you have a character oriented numerical display to serve like here Image. And IIRC this one is actually based on a matrix like the Spectrums keyboard.

Foornotes
* not "by the 0". This is a common misconception by nonbelievers, which causes literally infinite trouble.
** with small kids of course I always talk asterixed.
"Truth would quickly cease to be stranger than fiction, once we got used to it." - H.L. Mencken
User avatar
Spud
Manic Miner
Posts: 372
Joined: Sun Nov 12, 2017 8:50 pm
Contact:

Re: I need to make this

Post by Spud »

Nope, sorry, you lost me totally.
User avatar
1bvl109
Dizzy
Posts: 98
Joined: Tue Jun 04, 2019 9:00 pm

Re: I need to make this

Post by 1bvl109 »

AndyC wrote: Fri Jul 19, 2019 7:01 am You can learn BASIC faster than assembly, that is literally the point of it.
It is faster to learn. Than FORTRAN.

"The new language was heavily patterned on FORTRAN II; statements were one-to-a-line, numbers were used to indicate the target of loops and branches, and many of the commands were similar or identical. However, the syntax was changed wherever it could be improved. For instance, the difficult to remember DO loop was replaced by the much easier to remember FOR I = 1 TO 10 STEP 2, and the line number used in the DO was instead indicated by the NEXT I.[a] Likewise, the cryptic IF statement of Fortran, whose syntax matched a particular instruction of the machine on which it was originally written, became the simpler IF I=5 THEN GOTO 100. These changes made the language much less idiosyncratic while still having an overall structure and feel similar to the original FORTRAN."

https://en.wikipedia.org/wiki/BASIC
AndyC wrote: Fri Jul 19, 2019 7:01 am But Sinclair BASIC is a crap implementation, ...
I'm not sure.

Show of hands please. Why didn't more people learn assembler?
Was it
1. their satisfaction with basic
2. no literature provided with the computer
3. no IDE provided with the computer
4. no possibility of sensible debugging, instead
5. a machine which hangs on the slightest error?

I don't opt for Nr. 1.
"Truth would quickly cease to be stranger than fiction, once we got used to it." - H.L. Mencken
Post Reply