News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu
avatar_AMSDOS

WINDOW.PAS - Turbo Pascal 3 Disk

Started by AMSDOS, 13:14, 28 August 10

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

AMSDOS

One of the few treats on the Turbo Pascal 3 Disk is a program demonstrating the use of Windows. Quite nice to actually see it there given other CP/M versions of TP3 don't include it, mainly because it's a machine specific instruction - only other versions which provides this is the PCDOS version of TP3.

Unfortunately the WINDOW.PAS program which comes on the Turbo Pascal 3 Disk Image on NVG is bugged which stops it from being compiled. Fortunately it's easily fixed.

{$C-}
{$U-}
program TestWindow;
const
   Windows    = 3;
   Wtab       : array[1..Windows,1..5] of Integer
                = (( 5,  2,  35, 11,  1), { X0,Y0,X1,Y1,LineNo }
                   (45,  2,  75, 11,  1),
                   ( 5, 15,  75, 23,  1)
                  );
type
   String255  = String[255];
var
   i          : Integer;
   Ch         : Char;

   procedure window(x1,x2,y1,y2:byte);
   begin
     write(#26,chr(x1-1),chr(y1-1),chr(x2-1),chr(y2-1));
   end;
   procedure Frame(UpperLeftX, UpperLeftY, LowerRightX, LowerRightY: Integer);
   var
      i: Integer;
   begin
      GotoXY(UpperLeftX, UpperLeftY);
      Write(#150);
      for i:=UpperLeftX+1 to LowerRightX-1 do Write(#154);
      Write(#156);
      for i:=UpperLeftY+1 to LowerRightY-1 do
      begin
         GotoXY(UpperLeftX , i);  Write(#149);
         GotoXY(LowerRightX, i);  Write(#149);
      end;
      GotoXY(UpperLeftX, LowerRightY);
      Write(#147);
      for i:=UpperLeftX+1 to LowerRightX-1 do Write(#154);
      Write(#153);
   end  { Frame };

   function RanStr(Len: Integer): String255;
   var
      S: String255;
      i: Integer;
   begin
      S[0]:=Chr(Len);
      for Len:=1 to Len do
      begin
         i:=Random(223);
         i:=i + 32;
         S[Len]:=Chr(i);
      end;
      RanStr:=S;
   end  { RanStr };

   procedure SelectWindow(Win: Integer);
   begin
      Window(Wtab[Win,1], Wtab[Win,2], Wtab[Win,3], Wtab[Win,4])
   end  { SelectWindow };

   procedure Window1;
   begin
      LowVideo;
      SelectWindow(1);
      GotoXY(1,24);
      Write('Line ', Wtab[1,5]:5, ' ' ,#207,' ', RanStr(16));
      Wtab[1,5]:=Succ(Wtab[1,5]);
      NormVideo;
   end  { Window1 };
   procedure Window2;
   begin
      LowVideo;
      SelectWindow(2);
      GotoXY(1,24);
      Write('Line ', Wtab[2,5]:5, ' ' ,#207,' ', RanStr(16));
      Wtab[2,5]:=Succ(Wtab[2,5]);
      NormVideo;
   end  { Window2 };

   procedure Window3;
   begin
      LowVideo;
      SelectWindow(3);
      GotoXY(1,1);
      Write(#13#11);
      GotoXY(1,1);
      Write('Line ', Wtab[3,5]:5, ' ' ,#207,' ',  RanStr(56));
      Wtab[3,5]:=Succ(Wtab[3,5]);
      NormVideo;
   end  { Window3 };
begin
   clrscr;
   GotoXY(15,25);
   Write('TURBO PASCAL Window Demo  -  Press any key to stop');
   for i:=1 to Windows do
      Frame(Wtab[i,1]-1, Wtab[i,2]-1, Wtab[i,3]+1, Wtab[i,4]+1);
   repeat
      Window1;
      Window2;
      Window3;
   until KeyPressed;
   Read(KBD, Ch);
   window(1,1,80,25);
   clrscr;
end.


Quite straightfoward actually, the program sets up 3 Windows and makes all this stuff flow through it!  ;D  The Procedure Window uses Control Character #26 which is the Text Window equivalent to the BASIC Window command and the additional paramaters reflect the dimensions of the Window.

Here's the output of that program!

* 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

TFM

Ok, it's nice to see that the CPC can use Windows! And there may be few applications, where windows make sense (f. e. a window with file-names). But (IMHO) in most cases a screen with 80 * 25 charactes really need no windows. I mean, where is the gain in using a Window? The only thing that a window does for you is to SHRINK the usable space on screen.
Personally I can't understand the hype about windows. They just cut down you freedom. Look at windows on CPC, except the soundtrakker/Starkos there is not one application running with / in a window, that wouldn't be better in fullscreen. But ok, for some people it's more important that it looks nice, instead of being usable. "the sizzle sells the steak". The eye eats, too ;-)
Anyway, it's a pleasure to see that it is possible in TP3 on CPC, at least to kick to butt of some commodore guys ;-)
TFM of FutureSoft
Also visit the CPC and Plus users favorite OS: FutureOS - The Revolution on CPC6128 and 6128Plus

norecess


AMSDOS

Ooh - take that Windows!  ;D

I know I have a bit of a thing for Windows (probably because the Windows Demo program in the CPC464 manual was so cool!). I'm guilty of having them for my Menu programs where, in that I would change the paper colour and clear screen that as an effective means to make it look like a Filled in Box.
Another program I wrote (in BASIC of course) where I thought Windows were very effective was a Memory Dumper, it would simply divide the screen - I could have a bar at the top of the screen with the address, hexadecimal byte & decimal byte in one window, and below that boxes for the address, hexadecimal byte & decimal byte. Around that I had all text graphics (border edge graphics) - of course the main idea was to scroll the addresses and bytes down without interfering with the rest of screen. I think the only setback there was speed cause scrolling things down in Windows Text Boxes does this - though it doesn't present the problem of realigning something like the Status Bar.

It might have other uses perhaps in a Game one could setup a Status Bar to keep things like Score & Lives in and then elsewhere maybe a Graphics Window with a Scrolly game in it.

Windows is simply there as a cosmetic feature though, in Mode 2 (80x25) it probably doesn't have many applications, which leaves Mode 1 & Mode 0 to add more colour to it and in some ways can be an alternate way to eliminating the issues of scrolling.
* 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

TFM

Well, right. As long as "windows" are not thrown chaotic over each other there are some applications which may like them :-)
TFM of FutureSoft
Also visit the CPC and Plus users favorite OS: FutureOS - The Revolution on CPC6128 and 6128Plus

norecess

Actually, the only "windows-based" system that convinced me was Discology user interface.. was usable, but not too much intrusive !


At some point, Ocp Art Studio is also interesting for that.

TFM

I totally agree! Are you coming home now? Must be really late in France (think 28:08 errr...4:08). Here in NOLA it's "only" 22:08. I will great the French Quarter from you, which I will visite now... :-)
TFM of FutureSoft
Also visit the CPC and Plus users favorite OS: FutureOS - The Revolution on CPC6128 and 6128Plus

AMSDOS

Yeah, No, well that's fine  :-[  Each to their own I say!!  :)

I just thought it would be something useful to have in Turbo Pascal, given I've seen some interesting BASIC games which make use of the Windows. It can be used as a glorifying tool, or simply a means or organising. Okay I'm perhaps not the best person to be writing about this, given I was over the moon when I understood how Window works, and yes I suppose it can be misused just like anything else.
* 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

Devilmarkus

Quote from: TFM/FS on 03:26, 04 September 10
Well, right. As long as "windows" are not thrown chaotic over each other there are some applications which may like them :-)

Well, for example SymbOS is well organized with it's windows and works fine.
Really, it's very user friendly because it's Win-style.
It's easy to bring windows to front because each window has it's task symbol in a task bar.
And the screen rendering is really fast enough.
So thumbs up for windows on CPC!
When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

norecess

QuoteI totally agree! Are you coming home now? Must be really late in France (think 28:08 errr...4:08). Here in NOLA it's "only" 22:08. I will great the French Quarter from you, which I will visite now... :-)


Sure, enjoy visiting France ! But you won't find me there - I'm living in Montreal (Canada) actually ! And got my 2 CPCs there... :P

AMSDOS

Okay more fuel for the Fire - it's on my Website!  ;D
* 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

TFM

#11
Quote from: norecess on 23:01, 04 September 10

Sure, enjoy visiting France ! But you won't find me there - I'm living in Montreal (Canada) actually ! And got my 2 CPCs there... :P

Have a good evening neighbour!  ;D


Quote from: Devilmarkus on 13:13, 04 September 10
Well, for example SymbOS is well organized with it's windows and works fine.
Really, it's very user friendly because it's Win-style.
It's easy to bring windows to front because each window has it's task symbol in a task bar.
And the screen rendering is really fast enough.
So thumbs up for windows on CPC!

You must be right!  :o  We can see it here:
http://en.wikipedia.org/wiki/File:Symbos-cpc.png
TFM of FutureSoft
Also visit the CPC and Plus users favorite OS: FutureOS - The Revolution on CPC6128 and 6128Plus

AMSDOS

TFM/FS wrote:

You must be right!  :o  We can see it here:
http://en.wikipedia.org/wiki/File:Symbos-cpc.png

The Windows used in my examples are Text Based so in this instance the Text Window is &BB66 which uses registers H for the Left Side of the Window, D for the Right, L for the Top & E for the Bottom.

To do Graphical Based Windows again requires two Firmware Routines with GRA WIN WIDTH and GRA WIN HEIGHT. GRA WIN WIDTH (&BBCF) sets the left and right hand edges, both of the Edges is defined using DE and HL (it doesn't matter which edge is which). Likewise to use GRA WIN HEIGHT (&BBD2) top and bottom is defined with DE and HL (it doesn't matter which is which).

But having said all that Symbos probably has it's own special routine for defining Windows given it's an OS in it's own right - it probably scraps the Firmware for something more meaningful for it.
* 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

TFM

Quote from: CP/M User on 09:21, 06 September 10
The Windows used in my examples are Text Based so in this instance the Text Window is &BB66 which uses registers H for the Left Side of the Window, D for the Right, L for the Top & E for the Bottom.

To do Graphical Based Windows again requires two Firmware Routines with GRA WIN WIDTH and GRA WIN HEIGHT. GRA WIN WIDTH (&BBCF) sets the left and right hand edges, both of the Edges is defined using DE and HL (it doesn't matter which edge is which). Likewise to use GRA WIN HEIGHT (&BBD2) top and bottom is defined with DE and HL (it doesn't matter which is which).

Yes, and as long as you don't shuffle windows over each other you still have some order and you can work with it. Chaos always begins when windows become "thrown" on each other.

Actually I like the very first pic in this thread, because there is still order on the screen. But on the other hand windows (used in an unordered way) always have the potential to bring chaos. ;)
TFM of FutureSoft
Also visit the CPC and Plus users favorite OS: FutureOS - The Revolution on CPC6128 and 6128Plus

AMSDOS

Oh yeah I hear what you're saying, I think I only had Windows over one another if I was doing a Box and wanted like a small Bordering effect in another colour behind it just to make it look a bit multidimensional. Otherwise it gets a bit confusing.
* 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

Powered by SMFPacks Menu Editor Mod