Post Reply 
Pascal language for HP49-50
11-17-2020, 10:42 PM (This post was last modified: 11-17-2020 10:44 PM by Gilles.)
Post: #1
Pascal language for HP49-50
Did you know that you can program in Pascal your HP49-50g? (By the way the compiler need a PC) :

What you can get :



And the source :

Code:
Program CasseBriques;

{ =======================================
  v1.3 Août 2017  - Nemo_59
  HP Pascal v2.1 pour HP50g-HP49g+               
 --------------------------------------- }

Uses SystemHP,CrtHPmini_49,GraphHP,GameHP_49,
     MathsHP_49, SoundHP_49;

Ressource Breakout;

Const NbTableau=5; HzMur=200; MsMur=5; HzBord=600; MsBord=5;
      HzRqt=800; MsRqt=5; HzOut=100; MsOut=500;

Mvt : Array[1..8, 1..3, 1..2] Of Byte =
{ Chaque déplacement de la balle est décomposé en 3 mouvements de 1x1 pixel}
  1, 0, 1,-1, 1,-1 { Direction 1    -3---2-  }
, 0,-1, 1,-1, 1,-1 { Direction 2    4-----1  }
, 0,-1,-1,-1,-1,-1 { Direction 3    -------  }
,-1, 0,-1,-1,-1,-1 { Direction 4    ---O---  }
,-1, 0,-1, 1,-1, 1 { Direction 5    -------  }
, 0, 1,-1, 1,-1, 1 { Direction 6    5-----8  }
, 0, 1, 1, 1, 1, 1 { Direction 7    -6---7-  }
, 1, 1, 1, 0, 1, 1;{ Direction 8             }

Tableau : Array[1..NbTableau, 0..15] Of String[14] =

'..............', { Tableau 1 }
'..............',
'..............',
'XXXXXXXXXXXXXX',
'XXXXXXXXXXXXXX',
'XXXXXXXXXXXXXX',
'XXXXXXXXXXXXXX',
'XXXXXXXXXXXXXX',
'..............',
'..............',
'..............',
'..............',
'..............',
'..............',
'..............',
'..............',


'..............', { Tableau 2 }
'..............',
'XXXXXXXXXXXXXX',
'XXXXXXXXXXXXXX',
'..............',
'..............',
'XXXXXXXXXXXXXX',
'XXXXXXXXXXXXXX',
'XXXXXXXXXXXXXX',
'..............',
'..............',
'..............',
'..............',
'..............',
'..............',
'..............',

'..............', { Tableau 3 }
'..X........X..',
'...X......X...',
'..XXXXXXXXXX..',
'..XX.XXXX.XX..',
'.XXXXXXXXXXXX.',
'XXXXXXXXXXXXXX',
'XXXXXXXXXXXXXX',
'X.X........X.X',
'X.X........X.X',
'...XXX..XXX...',
'...XXX..XXX...',
'..............',
'..............',
'..............',
'..............',

'..............', { Tableau 4 }
'..............',
'....XXXXXX....',
'..XXXXXXXXXX..',
'.XX.XXXXXX.XX.',
'XX...XXXX...XX',
'XXX.XXXXXX.XXX',
'XXXXXXXXXXXXXX',
'XX.XXXXXXXX.XX',
'XXX........XXX',
'.XXXX....XXXX.',
'..XXXXXXXXXX..',
'.....XXXX.....',
'..............',
'..............',
'..............',

'..............', { Tableau 5 }
'..............',
'....XXXXXX....',
'..XX.XXXXXXX..',
'.XX.XXXXX...XX',
'XX.XXXXX.XX.XX',
'X...XXXX.XX.XX',
'X.XX.XX.XX.XXX',
'X.XX.XX...XXXX',
'X.XX.XX.XXXXXX',
'.XXXXXX.XXXXX.',
'..XXXXX.XXXX..',
'....XXXXXX....',
'..............',
'..............',
'..............';

Static BestScore:Integer=350;

Var i, j, Rx, Bx, By, Bx2, By2,
 Dir, Choc, b, Vies, LrgRqt,
 Vitesse, Difficulte, Niveau, NBrique, TotBrique : Byte;
 TapeMur, Perdu, GagneNiveau, SoundOn: Boolean;
 Score,k : Integer;
 c: Char;

{--------------------------}
Procedure DessineMur;
Begin
 PutBloc(10,10,g_Level);
 GotoXY(11,6); Write(Niveau);
 GotoXY(3,8); Write('Press ENTER to play');
 If SoundOn Then Begin
  Beep(349,100); Beep(392,200); Beep(349,100); Beep(392,200); Beep(493,200); Beep(523,400);End 
 Else c:=ReadKey;
 Clearbar(5,5,95,70);
 TotBrique:=0;
 Box(0,0,100,80); 

 For i:=1 To 14 Do
  For j:=0 To 15 Do
   If Tableau[((Niveau-1) MOD NbTableau)+1,j][i]='X' Then Begin 
     Bar((i-1)*7+2,j*4+2,i*7,j*4+4); TotBrique:=TotBrique+1; 
     If SoundOn Then Beep(Random(1000)+200,15);
    End;

 Bar(Rx,78,Rx+LrgRqt,79);
 GotoXY(26,2); Write(Score);
 GotoXY(26,5); Write(BestScore);
 GotoXY(26,8); Write(Vies); 
 GotoXY(26,11);Write(Niveau);
 Perdu:=False; GagneNiveau:=False;
 Vitesse:=Difficulte-(Niveau Div (NbTableau+1)*3); 
 If Vitesse<2 Then Vitesse:=1;
 NBrique:=0;
End;

{--------------------------}
Procedure BougeRaquette;
Var D : Char; 
Begin
 D:=' ';
 For j:=1 To Vitesse Do Begin
  If RightPressed Then D:='R';
  If LeftPressed  Then D:='L';
 End;

 Case D Of
  'R': If Rx<86 Then
         Begin
          ClearLineV(Rx,78,79);
          LineV(Rx+LrgRqt+1,78,79);
          Rx:=Rx+1;
         End;
   'L': If Rx>1 Then
         Begin
          ClearLineV(Rx+LrgRqt,78,79);
          LineV(Rx-1,78,79);
          Rx:=Rx-1;
         End;
 End;
End;

{------------------------------}
Procedure BougeBalle;
Var Mx,My : Integer; Interm : Byte;
Begin
 Interm:=1;
 
 Repeat
  BougeRaquette;
  Bx2:=Bx+Mvt[Dir,Interm,1];
  By2:=By+Mvt[Dir,Interm,2];

  If Bx2>=99 Then Begin
   Case Dir Of
    1: Dir:=4;
    2: Dir:=3;
    7: Dir:=6;
    8: Dir:=5;
   End;
   Bx2:=98; If SoundOn Then Beep(HzBord,MsBord);
   Exit;
  End;

  If Bx2<=0 Then Begin
   Case Dir Of
    3: Dir:=2;
    4: Dir:=1;
    5: Dir:=8;
    6: Dir:=7;
   End;
   Bx2:=2; If SoundOn Then Beep(HzBord,MsBord);
   Exit;
  End;

  If By2<=0 Then Begin
   Case Dir Of
    1: Dir:=8;
    2: Dir:=7;
    3: Dir:=6;
    4: Dir:=5;
   End;
   By2:=4; If SoundOn Then Beep(HzBord,MsBord);
   Exit;
  End;

  BougeRaquette;

  If By2=77 Then Begin
   k:=Bx2; k:=k-Rx+1; 
   If Dir in [7,8] And (k=-1 Or (k=-2 And LeftPressed)) Then k:=0;
   If Dir in [5,6] And (k=15 Or (k=16 And RightPressed)) Then k:=14;
          
   If k>=0 And k<=LrgRqt+1 Then Begin
    Case k Of
     0     : Dir:=4;
     1,2  : Case Dir Of 5,6: Dir:=4; 7,8: Dir:=2; End;
     3..11 : Dir:=9-Dir;
     12,13: Case Dir Of 5,6: Dir:=3; 7,8: Dir:=1; End;
     14    : Dir:=1;
    End;
    If SoundOn Then Beep(HzRqt,MsRqt);
   End Else Begin 
    Perdu:=True; ClearBar(Bx,By,Bx+1,By+1); 
    If SoundOn Then Beep(HzOut,MsOut);
   End;
    Exit;
  End;

  Choc:=0; TapeMur:=False;

  ClearBar(Bx,By,Bx+1,By+1);
  If Point(Bx2,By2)     Then Choc:=1;
  If Point(Bx2+1,By2)   Then Choc:=Choc+2;
  If Point(Bx2+1,By2+1) Then Choc:=Choc+4;
  If Point(Bx2,By2+1)   Then Choc:=Choc+8;
  Bar(Bx,By,Bx+1,By+1);

  Case Dir Of
   1,2: Case Choc Of
    1,3: Begin TapeMur:=True; Dir:=9-Dir; End;
    2  : Begin TapeMur:=True; Dir:=Dir+4; End;
    6,4: Begin TapeMur:=True; Dir:=Dir+2; End;   
   End;
   3,4: Case Choc Of
    2,3: Begin TapeMur:=True; Dir:=Dir+2; End;         
    1  : Begin TapeMur:=True; Dir:=Dir+4; End;
    9,8: Begin TapeMur:=True; Dir:=5-Dir; End; 
   End;
   5,6: Case Choc Of
    4,12: Begin TapeMur:=True; Dir:=9-Dir; End;
    8   : Begin TapeMur:=True; Dir:=Dir-4; End;
    1,9 : Begin TapeMur:=True; Dir:=Dir+2; End;
   End;
   7,8: Case Choc Of
    8,12: Begin TapeMur:=True; Dir:=9-Dir; End;
    4   : Begin TapeMur:=True; Dir:=Dir-4; End;
    2,6 : Begin TapeMur:=True; Dir:=Dir-2; End;
   End;
  End;
 
  If TapeMur Then Begin
   NBrique:=NBrique+1;
   Mx:=((Bx2-1) Div 7)*7 + 1;
   My:=((By2-1) Div 4)*4 + 1;
   ClearBar(Mx,My,Mx+6,My+3); 
   If SoundOn Then Begin Beep(HzMur,MsMur); Beep(HzMur*2,MsMur); End;
   Score:=Score+5; GotoXY(26,2); Write(Score); Interm:=3;
  End;

  Interm:=Interm+1;
  If By2<77 Then Begin
   ClearBar(Bx,By,Bx+1,By+1);
   Bar(Bx2,By2,Bx2+1,By2+1);
  End;
  Bx:=Bx2; By:=By2;
 Until Interm=4;
End;

Procedure Parametres(c :Char); 
Begin
  If Ord(c)=16 Then Halt;
  Case c Of
   'A' : Begin ClearBar(118,22,125,44); PutSprite(118,22,Check); Difficulte:=15; End;
   'B' : Begin ClearBar(118,22,125,44); PutSprite(118,31,Check); Difficulte:=11; End;
   'C' : Begin ClearBar(118,22,125,44); PutSprite(118,40,Check); Difficulte:=8;  End;
   'D': Begin
         If SoundOn Then SoundOn:=False Else SoundOn:=True;
         ClearBar(63,49,70,61);
         If SoundOn Then PutSprite(64,49,Check) Else PutSprite(64,56,Check);         
        End;
  End;
End;

Procedure Initialisation;
Begin 
 EnableInterrupt;ClearBar(0,0,130,79);
 If SoundOn Then SoundOn:=False Else SoundOn:=True; 
 AppearCool(Instructions);
 Parametres(Chr(68));
 Case Difficulte Of
  15 : Parametres(Chr(65));
  11 : Parametres(Chr(66));
  8  : Parametres(Chr(67)); 
 End;
 While KeyPressed Do c:=ReadKey; 
 Repeat 
  c:=ReadKey;
  If SoundOn Then Beep(440,20);
  Parametres(c);
 Until Ord(c)=13;
 DisappearCool;
End;

{-------- Programme principal -----------}
Begin
 

 AppearCool(Breakout2); LineV(128,0,59); LineV(129,0,59);
 GotoXY(7,11); Write('Press ENTER to Play');
 GotoXY(7,12); Write('Press DEL<- to Exit');
 c:=ReadKey; If c=Chr(16) Then Halt;
 DisappearCool;

 SoundOn:=True; Difficulte:=15; Contraste(15); 

 Repeat 
  Initialisation;
 
  Score:=0; Vies:=6; Niveau:=1; Rx:=35; LrgRqt:=13;

  ClrScr; PutBloc(100,0,Menu);

  Repeat
   {Nouveau Niveau}
   Vies:=Vies+2; DessineMur;
   DisableInterrupt;

   Repeat
    {Nouvelle balle}
    By:=75; Bx:=Rx+5; Dir:=Random(3)+1; 
    GotoXY(26,8); Write(Vies);
    Repeat BougeRaquette; Until UpPressed Or ExitPressed Or EnterPressed;
    If SoundOn Then Beep(740,300); 
    Bx:=Rx+6;
    Perdu:=False;

    Repeat
     BougeBalle;
     If NBrique=TotBrique Then GagneNiveau:=True;
    Until GagneNiveau Or Perdu Or ExitPressed;

    ClearBar(Bx,By,Bx+1,By+1);
    If Perdu Then Vies:=Vies-1; GotoXY(26,8); Write(Vies);
   Until Vies=0 Or GagneNiveau Or ExitPressed; 

   Niveau:=Niveau+1;
   EnableInterrupt;
  Until Vies=0 Or ExitPressed;
 
  GotoXY(8,8); Write('GAME OVER'); Box(30,46,68,54);

  If Score>BestScore Then Begin 
   ClearBar(1,1,99,79);PutBloc(4,6,Best);
   BestScore:=Score;
   If SoundOn Then Begin
    Beep(233,400);Beep(349,400);Beep( 311,133);Beep( 293,133);Beep( 261,133);Beep( 466,400);Beep( 349,400);
    Beep( 311,133);Beep( 293,133);Beep( 261,133 );Beep(466,400 );Beep(349,400 );Beep(311,133 );
    Beep(293,133 );Beep(311,133 );Beep(260,533); 
   End;
  End;
  GotoXY(5,11); Write('ENTER to replay');
  GotoXY(5,12); Write(' DEL<- to exit');
  ClearBar(1,78,99,79);
  Repeat Until EnterPressed Or ExitPressed;
 Until ExitPressed;

End.

Link for upload : HPCALC
Find all posts by this user
Quote this message in a reply
11-18-2020, 04:02 AM (This post was last modified: 11-18-2020 04:05 AM by CMarangon.)
Post: #2
RE: Pascal language for HP49-50
I am not Allan Jackson, but I'll Try.

Do you know this online Pascal Compiller?

https://www.onlinegdb.com/online_pascal_compiler




(11-17-2020 10:42 PM)Gilles Wrote:  Did you know that you can program in Pascal your HP49-50g? (By the way the compiler need a PC) :

What you can get :



And the source :

Code:
Program CasseBriques;

{ =======================================
  v1.3 Août 2017  - Nemo_59
  HP Pascal v2.1 pour HP50g-HP49g+               
 --------------------------------------- }

Uses SystemHP,CrtHPmini_49,GraphHP,GameHP_49,
     MathsHP_49, SoundHP_49;

Ressource Breakout;

Const NbTableau=5; HzMur=200; MsMur=5; HzBord=600; MsBord=5;
      HzRqt=800; MsRqt=5; HzOut=100; MsOut=500;

Mvt : Array[1..8, 1..3, 1..2] Of Byte =
{ Chaque déplacement de la balle est décomposé en 3 mouvements de 1x1 pixel}
  1, 0, 1,-1, 1,-1 { Direction 1    -3---2-  }
, 0,-1, 1,-1, 1,-1 { Direction 2    4-----1  }
, 0,-1,-1,-1,-1,-1 { Direction 3    -------  }
,-1, 0,-1,-1,-1,-1 { Direction 4    ---O---  }
,-1, 0,-1, 1,-1, 1 { Direction 5    -------  }
, 0, 1,-1, 1,-1, 1 { Direction 6    5-----8  }
, 0, 1, 1, 1, 1, 1 { Direction 7    -6---7-  }
, 1, 1, 1, 0, 1, 1;{ Direction 8             }

Tableau : Array[1..NbTableau, 0..15] Of String[14] =

'..............', { Tableau 1 }
'..............',
'..............',
'XXXXXXXXXXXXXX',
'XXXXXXXXXXXXXX',
'XXXXXXXXXXXXXX',
'XXXXXXXXXXXXXX',
'XXXXXXXXXXXXXX',
'..............',
'..............',
'..............',
'..............',
'..............',
'..............',
'..............',
'..............',


'..............', { Tableau 2 }
'..............',
'XXXXXXXXXXXXXX',
'XXXXXXXXXXXXXX',
'..............',
'..............',
'XXXXXXXXXXXXXX',
'XXXXXXXXXXXXXX',
'XXXXXXXXXXXXXX',
'..............',
'..............',
'..............',
'..............',
'..............',
'..............',
'..............',

'..............', { Tableau 3 }
'..X........X..',
'...X......X...',
'..XXXXXXXXXX..',
'..XX.XXXX.XX..',
'.XXXXXXXXXXXX.',
'XXXXXXXXXXXXXX',
'XXXXXXXXXXXXXX',
'X.X........X.X',
'X.X........X.X',
'...XXX..XXX...',
'...XXX..XXX...',
'..............',
'..............',
'..............',
'..............',

'..............', { Tableau 4 }
'..............',
'....XXXXXX....',
'..XXXXXXXXXX..',
'.XX.XXXXXX.XX.',
'XX...XXXX...XX',
'XXX.XXXXXX.XXX',
'XXXXXXXXXXXXXX',
'XX.XXXXXXXX.XX',
'XXX........XXX',
'.XXXX....XXXX.',
'..XXXXXXXXXX..',
'.....XXXX.....',
'..............',
'..............',
'..............',

'..............', { Tableau 5 }
'..............',
'....XXXXXX....',
'..XX.XXXXXXX..',
'.XX.XXXXX...XX',
'XX.XXXXX.XX.XX',
'X...XXXX.XX.XX',
'X.XX.XX.XX.XXX',
'X.XX.XX...XXXX',
'X.XX.XX.XXXXXX',
'.XXXXXX.XXXXX.',
'..XXXXX.XXXX..',
'....XXXXXX....',
'..............',
'..............',
'..............';

Static BestScore:Integer=350;

Var i, j, Rx, Bx, By, Bx2, By2,
 Dir, Choc, b, Vies, LrgRqt,
 Vitesse, Difficulte, Niveau, NBrique, TotBrique : Byte;
 TapeMur, Perdu, GagneNiveau, SoundOn: Boolean;
 Score,k : Integer;
 c: Char;

{--------------------------}
Procedure DessineMur;
Begin
 PutBloc(10,10,g_Level);
 GotoXY(11,6); Write(Niveau);
 GotoXY(3,8); Write('Press ENTER to play');
 If SoundOn Then Begin
  Beep(349,100); Beep(392,200); Beep(349,100); Beep(392,200); Beep(493,200); Beep(523,400);End 
 Else c:=ReadKey;
 Clearbar(5,5,95,70);
 TotBrique:=0;
 Box(0,0,100,80); 

 For i:=1 To 14 Do
  For j:=0 To 15 Do
   If Tableau[((Niveau-1) MOD NbTableau)+1,j][i]='X' Then Begin 
     Bar((i-1)*7+2,j*4+2,i*7,j*4+4); TotBrique:=TotBrique+1; 
     If SoundOn Then Beep(Random(1000)+200,15);
    End;

 Bar(Rx,78,Rx+LrgRqt,79);
 GotoXY(26,2); Write(Score);
 GotoXY(26,5); Write(BestScore);
 GotoXY(26,8); Write(Vies); 
 GotoXY(26,11);Write(Niveau);
 Perdu:=False; GagneNiveau:=False;
 Vitesse:=Difficulte-(Niveau Div (NbTableau+1)*3); 
 If Vitesse<2 Then Vitesse:=1;
 NBrique:=0;
End;

{--------------------------}
Procedure BougeRaquette;
Var D : Char; 
Begin
 D:=' ';
 For j:=1 To Vitesse Do Begin
  If RightPressed Then D:='R';
  If LeftPressed  Then D:='L';
 End;

 Case D Of
  'R': If Rx<86 Then
         Begin
          ClearLineV(Rx,78,79);
          LineV(Rx+LrgRqt+1,78,79);
          Rx:=Rx+1;
         End;
   'L': If Rx>1 Then
         Begin
          ClearLineV(Rx+LrgRqt,78,79);
          LineV(Rx-1,78,79);
          Rx:=Rx-1;
         End;
 End;
End;

{------------------------------}
Procedure BougeBalle;
Var Mx,My : Integer; Interm : Byte;
Begin
 Interm:=1;
 
 Repeat
  BougeRaquette;
  Bx2:=Bx+Mvt[Dir,Interm,1];
  By2:=By+Mvt[Dir,Interm,2];

  If Bx2>=99 Then Begin
   Case Dir Of
    1: Dir:=4;
    2: Dir:=3;
    7: Dir:=6;
    8: Dir:=5;
   End;
   Bx2:=98; If SoundOn Then Beep(HzBord,MsBord);
   Exit;
  End;

  If Bx2<=0 Then Begin
   Case Dir Of
    3: Dir:=2;
    4: Dir:=1;
    5: Dir:=8;
    6: Dir:=7;
   End;
   Bx2:=2; If SoundOn Then Beep(HzBord,MsBord);
   Exit;
  End;

  If By2<=0 Then Begin
   Case Dir Of
    1: Dir:=8;
    2: Dir:=7;
    3: Dir:=6;
    4: Dir:=5;
   End;
   By2:=4; If SoundOn Then Beep(HzBord,MsBord);
   Exit;
  End;

  BougeRaquette;

  If By2=77 Then Begin
   k:=Bx2; k:=k-Rx+1; 
   If Dir in [7,8] And (k=-1 Or (k=-2 And LeftPressed)) Then k:=0;
   If Dir in [5,6] And (k=15 Or (k=16 And RightPressed)) Then k:=14;
          
   If k>=0 And k<=LrgRqt+1 Then Begin
    Case k Of
     0     : Dir:=4;
     1,2  : Case Dir Of 5,6: Dir:=4; 7,8: Dir:=2; End;
     3..11 : Dir:=9-Dir;
     12,13: Case Dir Of 5,6: Dir:=3; 7,8: Dir:=1; End;
     14    : Dir:=1;
    End;
    If SoundOn Then Beep(HzRqt,MsRqt);
   End Else Begin 
    Perdu:=True; ClearBar(Bx,By,Bx+1,By+1); 
    If SoundOn Then Beep(HzOut,MsOut);
   End;
    Exit;
  End;

  Choc:=0; TapeMur:=False;

  ClearBar(Bx,By,Bx+1,By+1);
  If Point(Bx2,By2)     Then Choc:=1;
  If Point(Bx2+1,By2)   Then Choc:=Choc+2;
  If Point(Bx2+1,By2+1) Then Choc:=Choc+4;
  If Point(Bx2,By2+1)   Then Choc:=Choc+8;
  Bar(Bx,By,Bx+1,By+1);

  Case Dir Of
   1,2: Case Choc Of
    1,3: Begin TapeMur:=True; Dir:=9-Dir; End;
    2  : Begin TapeMur:=True; Dir:=Dir+4; End;
    6,4: Begin TapeMur:=True; Dir:=Dir+2; End;   
   End;
   3,4: Case Choc Of
    2,3: Begin TapeMur:=True; Dir:=Dir+2; End;         
    1  : Begin TapeMur:=True; Dir:=Dir+4; End;
    9,8: Begin TapeMur:=True; Dir:=5-Dir; End; 
   End;
   5,6: Case Choc Of
    4,12: Begin TapeMur:=True; Dir:=9-Dir; End;
    8   : Begin TapeMur:=True; Dir:=Dir-4; End;
    1,9 : Begin TapeMur:=True; Dir:=Dir+2; End;
   End;
   7,8: Case Choc Of
    8,12: Begin TapeMur:=True; Dir:=9-Dir; End;
    4   : Begin TapeMur:=True; Dir:=Dir-4; End;
    2,6 : Begin TapeMur:=True; Dir:=Dir-2; End;
   End;
  End;
 
  If TapeMur Then Begin
   NBrique:=NBrique+1;
   Mx:=((Bx2-1) Div 7)*7 + 1;
   My:=((By2-1) Div 4)*4 + 1;
   ClearBar(Mx,My,Mx+6,My+3); 
   If SoundOn Then Begin Beep(HzMur,MsMur); Beep(HzMur*2,MsMur); End;
   Score:=Score+5; GotoXY(26,2); Write(Score); Interm:=3;
  End;

  Interm:=Interm+1;
  If By2<77 Then Begin
   ClearBar(Bx,By,Bx+1,By+1);
   Bar(Bx2,By2,Bx2+1,By2+1);
  End;
  Bx:=Bx2; By:=By2;
 Until Interm=4;
End;

Procedure Parametres(c :Char); 
Begin
  If Ord(c)=16 Then Halt;
  Case c Of
   'A' : Begin ClearBar(118,22,125,44); PutSprite(118,22,Check); Difficulte:=15; End;
   'B' : Begin ClearBar(118,22,125,44); PutSprite(118,31,Check); Difficulte:=11; End;
   'C' : Begin ClearBar(118,22,125,44); PutSprite(118,40,Check); Difficulte:=8;  End;
   'D': Begin
         If SoundOn Then SoundOn:=False Else SoundOn:=True;
         ClearBar(63,49,70,61);
         If SoundOn Then PutSprite(64,49,Check) Else PutSprite(64,56,Check);         
        End;
  End;
End;

Procedure Initialisation;
Begin 
 EnableInterrupt;ClearBar(0,0,130,79);
 If SoundOn Then SoundOn:=False Else SoundOn:=True; 
 AppearCool(Instructions);
 Parametres(Chr(68));
 Case Difficulte Of
  15 : Parametres(Chr(65));
  11 : Parametres(Chr(66));
  8  : Parametres(Chr(67)); 
 End;
 While KeyPressed Do c:=ReadKey; 
 Repeat 
  c:=ReadKey;
  If SoundOn Then Beep(440,20);
  Parametres(c);
 Until Ord(c)=13;
 DisappearCool;
End;

{-------- Programme principal -----------}
Begin
 

 AppearCool(Breakout2); LineV(128,0,59); LineV(129,0,59);
 GotoXY(7,11); Write('Press ENTER to Play');
 GotoXY(7,12); Write('Press DEL<- to Exit');
 c:=ReadKey; If c=Chr(16) Then Halt;
 DisappearCool;

 SoundOn:=True; Difficulte:=15; Contraste(15); 

 Repeat 
  Initialisation;
 
  Score:=0; Vies:=6; Niveau:=1; Rx:=35; LrgRqt:=13;

  ClrScr; PutBloc(100,0,Menu);

  Repeat
   {Nouveau Niveau}
   Vies:=Vies+2; DessineMur;
   DisableInterrupt;

   Repeat
    {Nouvelle balle}
    By:=75; Bx:=Rx+5; Dir:=Random(3)+1; 
    GotoXY(26,8); Write(Vies);
    Repeat BougeRaquette; Until UpPressed Or ExitPressed Or EnterPressed;
    If SoundOn Then Beep(740,300); 
    Bx:=Rx+6;
    Perdu:=False;

    Repeat
     BougeBalle;
     If NBrique=TotBrique Then GagneNiveau:=True;
    Until GagneNiveau Or Perdu Or ExitPressed;

    ClearBar(Bx,By,Bx+1,By+1);
    If Perdu Then Vies:=Vies-1; GotoXY(26,8); Write(Vies);
   Until Vies=0 Or GagneNiveau Or ExitPressed; 

   Niveau:=Niveau+1;
   EnableInterrupt;
  Until Vies=0 Or ExitPressed;
 
  GotoXY(8,8); Write('GAME OVER'); Box(30,46,68,54);

  If Score>BestScore Then Begin 
   ClearBar(1,1,99,79);PutBloc(4,6,Best);
   BestScore:=Score;
   If SoundOn Then Begin
    Beep(233,400);Beep(349,400);Beep( 311,133);Beep( 293,133);Beep( 261,133);Beep( 466,400);Beep( 349,400);
    Beep( 311,133);Beep( 293,133);Beep( 261,133 );Beep(466,400 );Beep(349,400 );Beep(311,133 );
    Beep(293,133 );Beep(311,133 );Beep(260,533); 
   End;
  End;
  GotoXY(5,11); Write('ENTER to replay');
  GotoXY(5,12); Write(' DEL<- to exit');
  ClearBar(1,78,99,79);
  Repeat Until EnterPressed Or ExitPressed;
 Until ExitPressed;

End.

Link for upload : HPCALC

Carlos - Brazil
Time Zone: GMT -3
http://area48.com
Visit this user's website Find all posts by this user
Quote this message in a reply
11-18-2020, 03:22 PM
Post: #3
RE: Pascal language for HP49-50
Hello!

This code does not compile. It returns errors:-(

Carlos - Brazil
Time Zone: GMT -3
http://area48.com
Visit this user's website Find all posts by this user
Quote this message in a reply
11-18-2020, 03:24 PM
Post: #4
RE: Pascal language for HP49-50
I wouldn't really consider this Pascal language for the HP calculators. It's a cross-compiler for the PC that generates code for the HPs.

Tom L
Cui bono?
Find all posts by this user
Quote this message in a reply
11-18-2020, 05:39 PM
Post: #5
RE: Pascal language for HP49-50
(11-18-2020 03:24 PM)toml_12953 Wrote:  I wouldn't really consider this Pascal language for the HP calculators. It's a cross-compiler for the PC that generates code for the HPs.

Yes it is... And the compiler produce Saturn Code. So you can also use it on HP48 series. And its not obvious to install the environment on Win10 because it's a very old stuf (you need compatibilty mode). As Pascal is perhaps my favorite langage I was very surprise with this and have lot of fun to use it.

More information here : http://hppascal.free.fr/pages/home.htm

But dont expect a perfect thing with the 49-50g. It's more for fun than for serious things. I had to change some units to work with then 50g and there are limitations with the biger screen vs H48 series. By the way I was surprise that this very old software works quite fine. I would have be very happy to knows this in the past ;D
Find all posts by this user
Quote this message in a reply
11-18-2020, 07:02 PM
Post: #6
RE: Pascal language for HP49-50
The download link on that site is disabled. Sad

Is that the same as the Win32 cross compiler seen here on hpcalc.org:

https://www.hpcalc.org/details/6035

If you have a newer/better version, please send a copy to Eric so he can add it on hpcalc.org.

Thanks Gilles! Smile

--Bob Prosperi
Find all posts by this user
Quote this message in a reply
11-18-2020, 08:17 PM
Post: #7
RE: Pascal language for HP49-50
(11-18-2020 07:02 PM)rprosperi Wrote:  The download link on that site is disabled. Sad

Is that the same as the Win32 cross compiler seen here on hpcalc.org:

https://www.hpcalc.org/details/6035

If you have a newer/better version, please send a copy to Eric so he can add it on hpcalc.org.

Thanks Gilles! Smile

I see it's still there where it was when I found it, about 20 years ago, a pity.
I think it's the same as Eric's version, 2.1 from 2001

Greetings,
    Massimo

-+×÷ ↔ left is right and right is wrong
Visit this user's website Find all posts by this user
Quote this message in a reply
11-19-2020, 03:11 PM
Post: #8
RE: Pascal language for HP49-50
I wonder if the GNU Pascal front-end to gcc could be combined with gcc for ARM and used with the HPGCC or HPGCC3 libraries.

You could have Pascal language with all the advantages of direct ARM execution in the 49g+ and 50g models.
Find all posts by this user
Quote this message in a reply
11-19-2020, 03:28 PM
Post: #9
RE: Pascal language for HP49-50
(11-18-2020 05:39 PM)Gilles Wrote:  
(11-18-2020 03:24 PM)toml_12953 Wrote:  I wouldn't really consider this Pascal language for the HP calculators. It's a cross-compiler for the PC that generates code for the HPs.

Yes it is... And the compiler produce Saturn Code. So you can also use it on HP48 series. And its not obvious to install the environment on Win10 because it's a very old stuf (you need compatibilty mode). As Pascal is perhaps my favorite langage I was very surprise with this and have lot of fun to use it.

So you can use it to compile right on the calculator? If not then it's not "Pascal for the HP-49/50" It's "Pascal for the PC that generates code for the HP-49/50" That's by definition in English.

Tom L
Cui bono?
Find all posts by this user
Quote this message in a reply
11-19-2020, 10:09 PM
Post: #10
RE: Pascal language for HP49-50
(11-18-2020 07:02 PM)rprosperi Wrote:  The download link on that site is disabled. Sad

Is that the same as the Win32 cross compiler seen here on hpcalc.org:

https://www.hpcalc.org/details/6035

If you have a newer/better version, please send a copy to Eric so he can add it on hpcalc.org.

Thanks Gilles! Smile

I've been trying to get that one working for a few years but it it appears to have some sort of old Microsoft proprietary C language extensions so it won't compile.
Find all posts by this user
Quote this message in a reply
11-20-2020, 08:40 AM
Post: #11
RE: Pascal language for HP49-50
(11-19-2020 03:28 PM)toml_12953 Wrote:  So you can use it to compile right on the calculator? If not then it's not "Pascal for the HP-49/50" It's "Pascal for the PC that generates code for the HP-49/50" That's by definition in English.

That would at least be a more honest description of this application. The calculator itself does not understand any other language than the one implemented in its core and that is as everyone knows RPL. At this point it should also be noted that the code from a cross-compiler would be comparatively inefficient compared to the native code of the calculator. This affects both runtime and storage space and can therefore not be a reasonable alternative.
__________________________________
"Move forward and do what you think is best. If you make a mistake, you’ll learn something. But don’t make the same mistake twice." - Akio Morita
Find all posts by this user
Quote this message in a reply
11-20-2020, 02:42 PM
Post: #12
RE: Pascal language for HP49-50
(11-20-2020 08:40 AM)OtakuLab Wrote:  At this point it should also be noted that the code from a cross-compiler would be comparatively inefficient compared to the native code of the calculator. This affects both runtime and storage space and can therefore not be a reasonable alternative.

There is nothing that inherently prevents a cross compiler from generating code that is just as efficient as "native code". Cross compilers are quite common in the embedded device arena, where the device does not have sufficient resources itself to host a compiler. It is entirely possible that a cross compiler environment can produce superior code to a native compiler due to additional resources on the cross compiler's host that allows better optimizations.
Find all posts by this user
Quote this message in a reply
11-20-2020, 03:46 PM
Post: #13
RE: Pascal language for HP49-50
Think DM42...

Free42 and the Intel Decimal Floating Point library are cross-compiled using an ARM toolchain on a standard PC.

There are only 10 types of people in this world. Those who understand binary and those who don't.
Find all posts by this user
Quote this message in a reply
11-20-2020, 07:37 PM (This post was last modified: 11-20-2020 07:40 PM by pier4r.)
Post: #14
RE: Pascal language for HP49-50
(11-20-2020 08:40 AM)OtakuLab Wrote:  The calculator itself does not understand any other language than the one implemented in its core and that is as everyone knows RPL.

As far as I know with additional libraries you can run C, using HPGCC or with another firmware you have a different RPL, newRPL.

Additionally I remember that there was also a Lua port of sort (unstable) https://sourceforge.net/projects/hplua/ .

Then there is the HRAST basic https://www.hpmuseum.org/forum/thread-3774.html

There may be others (my memory is not recalling anything else). This to say that the 50g can understand something else if there are libraries for it. Any other capable computing system is similar, in the way that it needs libraries/programs to understand other languages (and yes everyone knows that at the end of the chain all of it will be some sort of assembly code for ARM on the HP 50g).

I still stick with userRPL most of the time because, although slow to execute, it is relatively fast and accomodating to develop. I check the results only every now and then (days pass in between), thus the computation is mostly finished by the time I check it. Plus many have left some snippets here and there that I try to collect here to form an organic library that is missing ( https://www.hpmuseum.org/forum/thread-10271.html additions are welcomed). Those libraries are somewhat missing for other languages.

Wikis are great, Contribute :)
Find all posts by this user
Quote this message in a reply
11-20-2020, 11:20 PM
Post: #15
RE: Pascal language for HP49-50
(11-20-2020 07:37 PM)pier4r Wrote:  This to say that the 50g can understand something else if there are libraries for it. Any other capable computing system is similar, in the way that it needs libraries/programs to understand other languages (and yes everyone knows that at the end of the chain all of it will be some sort of assembly code for ARM on the HP 50g).

A library can expand the translation of a language, but the tool with which it was created is always decisive for the quality of the machine code, no matter which high-level language is involved. Cross-compilers like GCC can also generate executable code in the same way, the compilation of GCC is thus the machine code of a typical C-compiler. But the generated code is ultimately always a compromise between the extended instruction set of any high-level language and that which is permanently installed in the calculator. External code optimization can improve the quality of the compilation, but it is in no way equal to the quality of natively created machine code. This can only be surpassed with hand-optimized assembler code.

The truth is, there is no Pascal compiler for the HP 49 or 50g, not without external tools or libraries that do a translation that is processed by a non-language compiler, and that's principally a foul compromise in its nature. The GCC in particular is famous for such applications, which all have one thing in common, inefficient, lousy code!
__________________________________
"Move forward and do what you think is best. If you make a mistake, you’ll learn something. But don’t make the same mistake twice." - Akio Morita
Find all posts by this user
Quote this message in a reply
11-22-2020, 08:30 PM
Post: #16
RE: Pascal language for HP49-50
(11-20-2020 11:20 PM)OtakuLab Wrote:  The truth is, there is no Pascal compiler for the HP 49 or 50g, not without external tools or libraries that do a translation that is processed by a non-language compiler, and that's principally a foul compromise in its nature. The GCC in particular is famous for such applications, which all have one thing in common, inefficient, lousy code!

Yes my point was not on Pascal. My point was that on the calculator itself one can use other languages as well (well maybe not really C, as it has to get compiled first). This independently if at the end they get converted in sysrpl/assembly.

Wikis are great, Contribute :)
Find all posts by this user
Quote this message in a reply
11-23-2020, 12:02 AM
Post: #17
RE: Pascal language for HP49-50
(11-22-2020 08:30 PM)pier4r Wrote:  Yes my point was not on Pascal. My point was that on the calculator itself one can use other languages as well (well maybe not really C, as it has to get compiled first). This independently if at the end they get converted in sysrpl/assembly.

I know what you mean, but the problem with such code remains the same as long as it's not natively compiled into the machine code of the calculator. In the very moment a cross compiler or even worst a source-to-source compiler is used, the end result is executable but hopelessly of more or less poor quality, and this is not an acceptable solution, external or internal. One more thing in passing: the two terms concerning assembly and compiled code shouldn't be mixed up in this context, since both are object code of the respective processor, but also of different quality as I have mentioned before.
__________________________________
"Move forward and do what you think is best. If you make a mistake, you’ll learn something. But don’t make the same mistake twice." - Akio Morita
Find all posts by this user
Quote this message in a reply
11-23-2020, 01:40 AM (This post was last modified: 11-23-2020 01:47 AM by Valentin Albillo.)
Post: #18
RE: Pascal language for HP49-50
.
Hi, pier4r:

(11-22-2020 08:30 PM)pier4r Wrote:  [...] (well maybe not really C, as it has to get compiled first).

Not exactly, this baby does include a C interpreter as its built-in high-level language:

[Image: Other%20Picture%20VA001%20-%20CASIO%20PB...C02538.jpg]

"The CASIO PB-2000C is one of the rarest pocket computers, a multi-language one that included a buit-in standard (K&R) C interpreter but would accept ROM modules for programming in BASIC and Pascal, among others (Prolog, CASL, ...). It has 32 Kb of RAM (expandable via RAM card to 64 Kb) as well as a dot-matrix LCD display (4x32 char, 32x192 px), in a somewhat large, heavy unit [...] On the positive side, it admits a number of peripherals including printing, plotting, storing to tape and floppy. and RS-232 Centronics inteface, which is nice and offers lots of possibilities."

Best regards.
V.

  
All My Articles & other Materials here:  Valentin Albillo's HP Collection
 
Visit this user's website Find all posts by this user
Quote this message in a reply
11-23-2020, 06:04 AM
Post: #19
RE: Pascal language for HP49-50
(11-23-2020 12:02 AM)OtakuLab Wrote:  
(11-22-2020 08:30 PM)pier4r Wrote:  Yes my point was not on Pascal. My point was that on the calculator itself one can use other languages as well (well maybe not really C, as it has to get compiled first). This independently if at the end they get converted in sysrpl/assembly.

I know what you mean, but the problem with such code remains the same as long as it's not natively compiled into the machine code of the calculator. In the very moment a cross compiler or even worst a source-to-source compiler is used, the end result is executable but hopelessly of more or less poor quality, and this is not an acceptable solution, external or internal. One more thing in passing: the two terms concerning assembly and compiled code shouldn't be mixed up in this context, since both are object code of the respective processor, but also of different quality as I have mentioned before.
__________________________________
"Move forward and do what you think is best. If you make a mistake, you’ll learn something. But don’t make the same mistake twice." - Akio Morita

This is simply incorrect - there is absolutely no reason that a cross compiler should produce less efficient code than a compiler for the same language running on the target machine. In fact, it is typically the other way round, as the cross compiler host is normally more powerful, and can spend more resources (memory, cpu cycles, ...) on optimizing the compiled code.

Note that a cross compiler normally outputs optimized machine code for the target machine; the exception is typically when the target machine is a poor match for the source language (example: 8-bit processors, when most high-level languages assume at least 16-bit integers).
Find all posts by this user
Quote this message in a reply
11-24-2020, 08:37 AM
Post: #20
RE: Pascal language for HP49-50
(11-23-2020 06:04 AM)rwiker Wrote:  This is simply incorrect - there is absolutely no reason that a cross compiler should produce less efficient code than a compiler for the same language running on the target machine. In fact, it is typically the other way round, as the cross compiler host is normally more powerful, and can spend more resources (memory, cpu cycles, ...) on optimizing the compiled code.

That is pure theory, unfortunately it looks different in practice. The degree of code optimization is only rudimentary in most cross compilers, so native compilers are always preferable. This is especially true when the available hardware resources of a system offer little scope for this. The more differences that have to be overcome, the greater the conversion losses. Cross compilers certainly have their advantages in many areas, but not for the mentioned calculators!
__________________________________
"Move forward and do what you think is best. If you make a mistake, you’ll learn something. But don’t make the same mistake twice." - Akio Morita
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 4 Guest(s)