Author |
Topic: Features that are never used (Read 542 times) |
|
rtr
Guest
|
 |
Features that are never used
« Thread started on: Mar 22nd, 2014, 11:58am » |
|
This is the first in an occasional series of posts on features of BBC BASIC for Windows which distinguish it from other BASICs, but which are so obscure that nobody ever uses them, unless of course you know different!
1. Outputting bottom-to-top text
BB4W supports outputting right-to-left text (for languages like Hebrew and Arabic) and top-to-bottom text (for Chinese, Japanese and Korean, rarely) but it also supports bottom-to-top text - both when output to the 'mainwin' and to the printer:
Code: *font Lucida Console,24
VDU 23,16,12;0;0;0;13 : REM Bottom-to-top text
PRINT "Hello world!" But there is no national language written this way, as far as I know, so apart from as a gimmick it's unlikely this facility has ever been used in a real program.
Richard.
|
|
Logged
|
|
|
|
JGHarston
Junior Member
member is offline


Gender: 
Posts: 52
|
 |
Re: Features that are never used
« Reply #1 on: Mar 24th, 2014, 01:34am » |
|
I think I once displayed a graph by writing the Y axis that way. But some things that seem redundant are easier to code that way, like CPUs that have MOVE r,r operations, disk controllers that have "write data and don't transfer" operations, plot operations that end up as "don't move, don't plot, and don't update".
|
|
Logged
|
|
|
|
rtr
Guest
|
 |
Re: Features that are never used
« Reply #2 on: Mar 24th, 2014, 09:40am » |
|
on Mar 24th, 2014, 01:34am, JGHarston wrote:But some things that seem redundant are easier to code that way. |
|
If you are implying that bottom-to-top printing 'fell out' as a side effect of top-to-bottom and right-to-left printing, it didn't (not in the BB4W code at least, I can't speak about Acorn's).
Richard.
|
|
Logged
|
|
|
|
lancegary
New Member
member is offline


Posts: 4
|
 |
Re: Features that are never used
« Reply #3 on: Mar 24th, 2014, 2:09pm » |
|
on Mar 24th, 2014, 01:34am, JGHarston wrote:I think I once displayed a graph by writing the Y axis that way. But some things that seem redundant are easier to code that way, like CPUs that have MOVE r,r operations, disk controllers that have "write data and don't transfer" operations, plot operations that end up as "don't move, don't plot, and don't update". |
|
It is true that most graphs are plotted in the opposite direction (bottom up) to the direction in which western text is written to the screen (top down). There was a time when stats programs used text (as opposed to pixels) for plotting graphs. So the bottom up facility would have been most useful for making text graphs. I suppose text art and charts could still be made using BB4W ...
Lance
|
|
Logged
|
|
|
|
rtr
Guest
|
 |
Re: Features that are never used
« Reply #4 on: Mar 24th, 2014, 2:24pm » |
|
on Mar 24th, 2014, 2:09pm, lancegary wrote:It is true that most graphs are plotted in the opposite direction (bottom up) |
|
BBC BASIC is relatively unusual in using Cartesian graphics coordinates (positive Y being upwards). It's what you want for plotting graphs and other scientific purposes, but it often confuses people more used to the graphics origin being in the top-left corner.
It's also why you have to be so careful in BBC BASIC to set your 'window' dimensions (e.g. using MODE) because since the graphics origin is at the bottom left and the text origin is at the top left, correct alignment of text and graphics critically depends on the window height.
Windows itself supports the 'positive Y upwards' convention, but it's not the default setting and I decided (rightly or wrongly) not to change that but to achieve the mapping by translating the coordinates. Ever since I've wondered whether that was the right decision, because it makes it rather more difficult to mix BASIC graphics and API graphics.
Just one of the many things I might do differently if I could turn the clock back, but which now isn't an option because of compatibility considerations with existing programs.
Quote:So the bottom up facility would have been most useful for making text graphs |
|
For that to work you would need to set the text 'X' direction to the normal left-to-right and the text 'Y' direction upwards. You can do that too, but it's not what I was talking about in the initial post.
Richard.
|
« Last Edit: Mar 24th, 2014, 2:28pm by rtr » |
Logged
|
|
|
|
yee
New Member
member is offline


Posts: 4
|
 |
Re: Features that are never used
« Reply #5 on: Mar 25th, 2014, 07:14am » |
|
Since the characters in a line of Chinese text are independent, therfore can be " readily" read in eitheir directions , so in practice, a chinese reader can get used to it being output/ displayed in the top to botom or botom to top directions realtime !
- very sorry that I have not yet find a niche application for this feature
- may be a Chines crossword puzzle or a *true* 3-D cross word pudzle ?
|
|
Logged
|
|
|
|
rtr
Guest
|
 |
Re: Features that are never used
« Reply #6 on: Mar 25th, 2014, 4:31pm » |
|
on Mar 25th, 2014, 07:14am, yee wrote:a chinese reader can get used to it being output/displayed in the top to botom or botom to top directions |
|
You may find this amusing:
http://blogs.msdn.com/b/oldnewthing/archive/2012/07/19/10331400.aspx
That's what you need to do when top-to-bottom text is not supported natively! Windows has nothing comparable with the control over text direction, scrolling, wrapping etc. that BBC BASIC (strictly, the VDU driver/emulator) provides. And it's not even specific to BB4W: as far as I know VDU 23,16 was implemented way back in 1987 on the Acorn Archimedes.
Richard.
|
« Last Edit: Mar 25th, 2014, 4:32pm by rtr » |
Logged
|
|
|
|
JGHarston
Junior Member
member is offline


Gender: 
Posts: 52
|
 |
Re: Features that are never used
« Reply #7 on: Mar 26th, 2014, 03:22am » |
|
on Mar 24th, 2014, 2:24pm, Richard Russell wrote:BBC BASIC is relatively unusual in using Cartesian graphics coordinates (positive Y being upwards). It's what you want for plotting graphs and other scientific purposes, but it often confuses people more used to the graphics origin being in the top-left corner. |
| I don't think I've ever encountered a Basic, or even a programming language at all, that plotted from the top downwards. Plotting is just so intuitively bottom upwards from primary school onwards, it would be so bizarre to have the plotting environment upside down. Who plots graphs from the top down?
(Though I have to admit I have to remind myself which way polar coordinates go each time I use them. Compass directions go clockwise, graphs go anticlockwise.)
on Mar 25th, 2014, 4:31pm, Richard Russell wrote:And it's not even specific to BB4W: as far as I know VDU 23,16 was implemented way back in 1987 on the Acorn Archimedes. |
| 1984(?)/5(?) in the Master MOS 3.xx.
|
|
Logged
|
|
|
|
rtr
Guest
|
 |
Re: Features that are never used
« Reply #8 on: Mar 26th, 2014, 09:31am » |
|
on Mar 26th, 2014, 03:22am, JGHarston wrote:I don't think I've ever encountered a Basic, or even a programming language at all, that plotted from the top downwards. |
|
I find that almost unbelievable! Liberty BASIC, PowerBASIC and Visual Basic all have the positive Y-axis going downwards, as do C#, Java and Python. Indeed since that's the default coordinate system for Windows graphics (both GDI and GDI+) any language designed for Windows might reasonably adopt that convention.
In fact the only other 'programming language' that I can immediately think of which uses the positive-Y upwards convention is Excel!
Richard.
|
|
Logged
|
|
|
|
hitsware
Junior Member
member is offline


Gender: 
Posts: 70
|
 |
The most unused is the sound !
« Reply #9 on: May 8th, 2014, 02:07am » |
|
rem: Awkward, but works ! ....  envelope 1,0,0,0,0,0,0,0,127,0,0,-1,127,0 dim note(3,7),selection(40) for x=1 to 40: read selection(x): next x data 40,88,96,100,116,120,136,144,148,164,168 data 184,192,196,212,232,0,0,0,0,0,0,0,0,0,0 data 0,0,0,0,0,0,0,0,0,0,0,0,0,0 print " hit any key to escape " repeat for count=0 to 7 n=inkey(1) if n<>-1 then quit for voice=0 to 3 random1=rnd(10) random2=rnd(40) if random1=1 then note(voice,count)=selection(random2) next voice if sgn(note(1,count))=1 then sound 1,1,note(1,count),1: sound 4097,1,0,4 else sound 4097,1,0,5 endif if sgn(note(2,count))=1 then sound 2,1,note(2,count),1: sound 4098,1,0,4 else sound 4098,1,0,5 endif if sgn(note(3,count))=1 then sound 3,1,note(3,count),1: sound 4099,1,0,4 else sound 4099,1,0,5 endif next count until false end
|
|
Logged
|
|
|
|
rtr
Guest
|
 |
Re: The most unused is the sound !
« Reply #10 on: May 8th, 2014, 08:18am » |
|
on May 8th, 2014, 02:07am, hitsware wrote:rem: Awkward, but works ! .... :) |
|
No it doesn't, because neither note nor count is a legal variable name when Lowercase Keywords mode is selected, which it must be to load your program as listed! Here is a corrected version with those variables capitalised to make them valid in both modes:
Code: ENVELOPE 1,0,0,0,0,0,0,0,127,0,0,-1,127,0
DIM Note(3,7),selection(40)
FOR x=1 TO 40: READ selection(x): NEXT x
DATA 40,88,96,100,116,120,136,144,148,164,168
DATA 184,192,196,212,232,0,0,0,0,0,0,0,0,0,0
DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0
PRINT " hit any key to escape "
REPEAT
FOR Count=0 TO 7
n=INKEY(1)
IF n<>-1 THEN QUIT
FOR voice=0 TO 3
random1=RND(10)
random2=RND(40)
IF random1=1 THEN Note(voice,Count)=selection(random2)
NEXT voice
IF SGN(Note(1,Count))=1 THEN
SOUND 1,1,Note(1,Count),1: SOUND 4097,1,0,4
ELSE SOUND 4097,1,0,5
ENDIF
IF SGN(Note(2,Count))=1 THEN
SOUND 2,1,Note(2,Count),1: SOUND 4098,1,0,4
ELSE SOUND 4098,1,0,5
ENDIF
IF SGN(Note(3,Count))=1 THEN
SOUND 3,1,Note(3,Count),1: SOUND 4099,1,0,4
ELSE SOUND 4099,1,0,5
ENDIF
NEXT Count
UNTIL FALSE
END I advise running the Cross Reference Utility before uploading code to the forum.
Richard.
|
|
Logged
|
|
|
|
rtr
Guest
|
 |
Re: The most unused is the sound !
« Reply #11 on: May 8th, 2014, 1:12pm » |
|
I'm somewhat puzzled that you've unrolled the SOUND loop. Isn't your program exactly equivalent to this:
Code: ENVELOPE 1,0,0,0,0,0,0,0,127,0,0,-1,127,0
DIM Note(3,7),selection(40)
FOR x=1 TO 40: READ selection(x): NEXT x
DATA 40,88,96,100,116,120,136,144,148,164,168
DATA 184,192,196,212,232,0,0,0,0,0,0,0,0,0,0
DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0
PRINT " hit any key to escape "
REPEAT
FOR beat=0 TO 7
IF INKEY(1)<>-1 QUIT
FOR voice=1 TO 3
IF RND(10)=1 THEN Note(voice,beat)=selection(RND(40))
IF Note(voice,beat)>0 THEN
SOUND voice,1,Note(voice,beat),1
SOUND voice+4096,1,0,4
ELSE
SOUND voice+4096,1,0,5
ENDIF
NEXT voice
NEXT beat
UNTIL FALSE
END Then you can trivially convert it from three-voice to four-voice:
Code: *tempo 133
ENVELOPE 1,0,0,0,0,0,0,0,127,0,0,-1,127,0
DIM Note(3,7),selection(40)
FOR x=1 TO 40: READ selection(x): NEXT x
DATA 40,88,96,100,116,120,136,144,148,164,168
DATA 184,192,196,212,232,0,0,0,0,0,0,0,0,0,0
DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0
PRINT " hit any key to escape "
REPEAT
FOR beat=0 TO 7
IF INKEY(1)<>-1 QUIT
FOR voice=0 TO 3
IF RND(10)=1 THEN Note(voice,beat)=selection(RND(40))
IF Note(voice,beat)>0 THEN
SOUND voice,1,Note(voice,beat),1
SOUND voice+4096,1,0,4
ELSE
SOUND voice+4096,1,0,5
ENDIF
NEXT voice
NEXT beat
UNTIL FALSE
END Richard.
|
|
Logged
|
|
|
|
hitsware
Junior Member
member is offline


Gender: 
Posts: 70
|
 |
Re: Features that are never used
« Reply #13 on: May 9th, 2014, 7:02pm » |
|
> I'm somewhat puzzled that you've > unrolled the SOUND loop.
I don't know what you mean by "unrolled the sound loop" I came up with that code a long time ago strictly by trial and error, and never understood it at all. The purpose is to allow notes with envelopes to overlap when appropriate. I.E. the way most BBC music is written shuts all notes off after any new note, but if each voice is considered an instrument then this is a poor representation of reality. There is probably a way simpler way.
|
|
Logged
|
|
|
|
rtr
Guest
|
 |
Re: Features that are never used
« Reply #14 on: May 9th, 2014, 9:17pm » |
|
on May 9th, 2014, 7:02pm, hitsware wrote:I don't know what you mean by "unrolled the sound loop" |
|
I mean that instead of using a loop you wrote separate code for each SOUND channel (1,2,3), despite the code for each channel being identical - apart from the channel number itself of course!
It seemed particularly odd because you did use a loop when writing to the Note() array:
Code: FOR voice=0 TO 3
random1=RND(10)
random2=RND(40)
IF random1=1 THEN Note(voice,Count)=selection(random2)
NEXT voice If you look at my version, I simply moved the SOUND statements into the existing loop, thereby getting rid of the duplication of code. That made the program shorter and easier to understand, and also meant that changing the program from three-voices to four-voices was trivial.
Quote:the way most BBC music is written shuts all notes off after any new note |
|
"The way most BBC music is written"? I sincerely hope not!
Richard.
|
« Last Edit: May 9th, 2014, 9:22pm by rtr » |
Logged
|
|
|
|
|