Jump to content
IGNORED

Pascal on the 99/4A


apersson850

Recommended Posts

13 hours ago, Vorticon said:

When I initially tried it, the computer crashed until I realized the radians conversion was incorrect. So odd you're getting a usable output...

Don't know why it would not work for you. I just copied and pasted the code above and it works fine.

Link to comment
Share on other sites

48 minutes ago, senior_falcon said:

Don't know why it would not work for you. I just copied and pasted the code above and it works fine.

You mean the pascal code I posted? That has the corrected randians conversion.

Link to comment
Share on other sites

1 hour ago, Vorticon said:

You mean the pascal code I posted? That has the corrected randians conversion.

No, the XB/TML code with the error that I posted that you said crashed the computer.

 

Here is the program modified to avoid having to use COS. This is compiled and you can see it is a bit less leisurely.This is running at normal speed, not CPU overdrive.

But of course, although it works the same, it is no longer the same program.

SPIRAL2.GIF.64cf95db08d6dd807fa82853b870eb2d.GIF

100 DIM SINE(11)
110 FOR I=1 TO 11 :: READ SINE(I):: NEXT I
120 CALL SCREEN(2):: PD=1
130 A=0
135 IF PD=1 THEN CALL LINK("PENHUE",3+INT(RND*14),2)
140 FOR I=1 TO 11
150 CALL LINK("PUTPEN",100,120,A)
160 W=A/180*SINE(I)
170 R=9+A/18
180 CALL LINK("PU"):: CALL LINK("FWD",R-W/200)
190 IF PD=1 THEN CALL LINK("PD")ELSE CALL LINK("PE")
195 CALL LINK("FWD",W/100)
200 A=A+3 :: IF A>1453 THEN 230
210 NEXT I :: GOTO 140
230 PD=PD+1 :: PD=PD AND 1 :: GOTO 130
240 DATA 0,51,97,136,164,178,178,164,136,97,51,0

 

Edited by senior_falcon
  • Like 8
Link to comment
Share on other sites

Posted (edited)

Yes, there was.

It shows that the FCTN-keys 1 to 9 have these definitions:

DEL, INS, FLUSH, BREAK, STOP, ALPHA LOCK, SCREEN LEFT, SCREEN RIGHT, LINE DELETE.

 

As you can see there's an ALPHA LOCK key too. It's redundant on the TI 99/4A, but was there to allow both upper and lower case on the 99/4. Since the p-system loads all character definitions from the file OS:SYSTEM.CHARAC at startup, it doesn't care which definitions are in the ROM chips in the console.

Edited by apersson850
  • Like 5
  • Thanks 1
Link to comment
Share on other sites

On 4/29/2024 at 11:59 PM, Vorticon said:

Not bad...

20240429_232432.thumb.jpg.3d563f7197ae3f8dece0da993881dfc9.jpg

Here are fully functionl versions of the p-Code strip in both possible /4A formats. . .this is actually one of the harder TI keystrips to find as an original. They turn up once in a while, but nowhere near as often as the other TI-sourced keystrips.

TI_Keyboard_Strip-PCode-(Restored-Eng).png

TI_Keyboard_Strip-PCode-(Restored-Eng-Beige3).png

  • Like 5
  • Thanks 1
Link to comment
Share on other sites

I have a set of data (53 character definitions) I'd like to use in a segment procedure. Since Pascal does not have the equivalent of a DATA basic statement, what is the most efficient way of embedding that data into the procedure? I could create an array and explicitly fill each element with the corresponding data, but is there a better way of doing it?

Another option is to create a raw data file and read it into a large array with BLOCKREAD, but for that I will have to create an assembly language program to create that raw file using the standard EA and transfer it to a Pascal disk using Pcode Tool. I could leverage Magellan for that last option. That said I would prefer to completely stay within the pcode environment.

Link to comment
Share on other sites

I ended up creating a small program to read the values of each character set colors from the keyboard and create a raw data file using BLOCKWRITE which can be easily retrieved using BLOCKREAD. For the hex definitions of the characters, I just imported the data from Magellan into a plain text file and used Pcode Tool to transfer it to a pcode disk. 

It's labor intensive for sure.

Here's the color data entry program as an example :

Spoiler
program dataentry;

type
 byte = 0..255;

 dual = record
  case boolean of
   true :(val :integer);
   false:(bytes : packed array[0..1] of byte);
 end; (* dual *)

var
 i, n, blocks : integer;
 buffer : packed array[0..511] of byte;
 chrnum, fcolor, bcolor : dual;
 outfile : file;
 
begin
 page(output);
 i := 0;
 n := 1;
 fillchar(buffer, 512, chr(0));
 repeat
  gotoxy(0, 1);
  writeln('enter char#, fcolor, bcolor # ',n);
  gotoxy(0, 2);
  writeln('             ');
  gotoxy(0, 2);
  read(chrnum.val, fcolor.val, bcolor.val);
  buffer[i] := chrnum.bytes[1];
  buffer[i + 1] := fcolor.bytes[1];
  buffer[i + 2] := bcolor.bytes[1];
  i := i + 3;
  n := succ(n);
 until i > 68;
 
 rewrite(outfile, '#9:colordata.data');
 blocks := blockwrite(outfile, buffer, 1);
 close(outfile, lock);
end.
 

 

 

  • Like 2
Link to comment
Share on other sites

I don't remember a lot of Pascal but...

 

I am wondering if you could declare a type 

Type chardef array[1..16] of char

Then make Const array of  type chardef.

And initialize the Const array as text strings of hex numbers like BASIC uses, in the source code.

 

They write a function that reads the const array HEX numbers, one at a time, converting each to a byte and writing the byte into VDP RAM. 

 

thinkin' out loud.

 

 

 

 

 

  • Like 2
Link to comment
Share on other sites

UCSD Pascal on the TI has a function to assign a hex definition string to a character called SET_PATTERN, very similar to Basic. What I ended up doing was simply have a text file with the definition strings which could be easily read string by string and assigned to SET_PATTERN. I have a matching file with the character numbers to use with it. But it's by no means a straightforward process compared to a DATA statement.

My original question was if there is a way to emulate a DATA statement somehow, and what you suggested is as close as one can get. One of my pet peeves with Pascal.

  • Like 3
Link to comment
Share on other sites

3 hours ago, Vorticon said:

UCSD Pascal on the TI has a function to assign a hex definition string to a character called SET_PATTERN, very similar to Basic. What I ended up doing was simply have a text file with the definition strings which could be easily read string by string and assigned to SET_PATTERN. I have a matching file with the character numbers to use with it. But it's by no means a straightforward process compared to a DATA statement.

My original question was if there is a way to emulate a DATA statement somehow, and what you suggested is as close as one can get. One of my pet peeves with Pascal.

It's that eternal story of protection vs freedom for the programmer.

When you think about how simple your requirement is;  you simply want to put some random data into a space in memory that you can point to later, it's hard to believe there isn't a simple way. 

BASIC does it with a DATA statement as does Assembler.  Forth uses a comma. 

Interestingly I went looking to see how to do it in C and there seems to a lot discussion about the best way to make the compiler do your bidding. :)

Seems to be a "feature" of the languages in the Algol family line. 

 

 

Link to comment
Share on other sites

Here's one way to leverage Magellan to get a screen character map as a text file which can be converted to a raw bytes file for quick loading. I imported the text file onto a pcode disk using Pcode Tool then created a program to do the conversion. Is there a more efficient way of doing this?

Below is the screen character data text file (graphics mode 32x24):

Spoiler
32,32,32,1,2,8,9,16,16,32,24,29,29,29,29,29,
29,29,29,29,29,29,29,29,29,29,29,29,29,29,25,32,
32,32,32,3,4,10,11,17,17,32,26,32,32,32,32,32,
32,32,32,32,32,32,32,32,32,32,32,32,32,32,27,32,
32,32,32,1,2,8,9,16,16,32,30,28,28,28,28,28,
28,28,28,28,28,28,28,28,28,28,28,28,28,28,31,32,
32,32,32,3,4,10,11,17,17,32,32,32,32,32,32,32,
32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,
32,32,32,1,2,8,9,16,16,32,24,29,29,29,29,29,
29,29,29,29,29,29,29,29,29,29,29,29,29,29,25,32,
32,32,32,3,4,10,11,17,17,32,26,32,32,32,32,32,
32,32,32,32,32,32,32,32,32,32,32,32,32,32,27,32,
32,32,32,1,2,8,9,16,16,32,26,32,32,32,32,32,
32,32,32,32,32,32,32,32,32,32,32,32,32,32,27,32,
32,32,32,3,4,10,11,17,17,32,26,32,32,32,32,32,
32,32,32,32,32,32,32,32,32,32,32,32,32,32,27,32,
32,32,32,1,2,8,9,16,16,32,26,32,32,32,32,32,
32,32,32,32,32,32,32,32,32,32,32,32,32,32,27,32,
32,32,32,3,4,10,11,17,17,32,26,32,32,32,32,32,
32,32,32,32,32,32,32,32,32,32,32,32,32,32,27,32,
32,32,32,1,2,8,9,16,16,32,26,32,32,32,32,32,
32,32,32,32,32,32,32,32,32,32,32,32,32,32,27,32,
32,32,32,3,4,10,11,17,17,32,26,32,32,32,32,32,
32,32,32,32,32,32,32,32,32,32,32,32,32,32,27,32,
32,32,32,1,2,8,9,16,16,32,26,32,32,32,32,32,
32,32,32,32,32,32,32,32,32,32,32,32,32,32,27,32,
32,32,32,3,4,10,11,17,17,32,26,32,32,32,32,32,
32,32,32,32,32,32,32,32,32,32,32,32,32,32,27,32,
32,32,32,1,2,8,9,16,16,32,26,32,32,32,32,32,
32,32,32,32,32,32,32,32,32,32,32,32,32,32,27,32,
32,32,32,3,4,10,11,17,17,32,30,28,28,28,28,28,
28,28,28,28,28,28,28,28,28,28,28,28,28,28,31,32,
32,32,32,1,2,8,9,16,16,32,32,32,32,32,32,32,
32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,
32,32,32,3,4,10,11,17,17,32,24,29,29,29,29,29,
29,29,29,29,29,29,29,29,29,29,29,29,29,29,25,32,
32,32,32,1,2,8,9,16,16,32,26,32,32,32,32,32,
32,32,32,32,32,32,32,32,32,32,32,32,32,32,27,32,
32,32,32,3,4,10,11,17,17,32,26,32,32,32,32,32,
32,32,32,32,32,32,32,32,32,32,32,32,32,32,27,32,
32,32,32,1,2,8,9,16,16,32,26,32,32,32,32,32,
32,32,32,32,32,32,32,32,32,32,32,32,32,32,27,32,
32,32,32,3,4,10,11,17,17,32,26,32,32,32,32,32,
32,32,32,32,32,32,32,32,32,32,32,32,32,32,27,32,
32,32,32,1,2,8,9,16,16,32,26,32,32,32,32,32,
32,32,32,32,32,32,32,32,32,32,32,32,32,32,27,32,
32,32,32,3,4,10,11,17,17,32,30,28,28,28,28,28,
28,28,28,28,28,28,28,28,28,28,28,28,28,28,31,32,
 
 

 

 

And here's the conversion program:

Spoiler
program getscreen;

type
 byte = 0..255;
 
 dual = record
  case boolean of
   true :(val :integer);
   false:(bytes : packed array[0..1] of byte);
  end; (* dual *)
  
var
 c : char;
 i, blocks, dnum, digit1, digit2 : integer;
 cvalue : dual;
 buffer : packed array[0..511] of byte;
 outfile : file;
 screenfile : text;
 
begin
 reset(screenfile, '#9:screendat.text');
 rewrite(outfile, '#9:screendat.data');
 fillchar(buffer, 512, chr(0));
 dnum := 0;
 i := 0;
 while not eof(screenfile) do
  begin
   read(screenfile, c);
   if c in['0','1','2','3','4','5','6','7','8','9',','] then
    begin
     if c = ',' then
      begin
       if dnum = 2 then
        cvalue.val := digit1 * 10 + digit2
       else
        cvalue.val := digit1;
  
       dnum := 0;
       buffer[i] := cvalue.bytes[1];
       i := succ(i);
       if i > 511 then
        begin
         blocks := blockwrite(outfile, buffer, 1);
         i := 0;
         fillchar(buffer, 512, chr(0));
        end;
      end
     else
      begin
       dnum := succ(dnum);
       if dnum = 1 then
         digit1 := ord(c) - 48
       else
        digit2 := ord(c) - 48;
      end;
    end;
  end;
 
 blocks := blockwrite(outfile, buffer, 1);
 close(outfile, lock);
 close(screenfile);
end.

 

 

  • Like 1
Link to comment
Share on other sites

No, there's no really handy way of doing this in Pascal.

Some Pascal versions allow you to define variables, including arrays, where you do an assignment of the variable right in the declaration. The equivalent of defining a constant, declaring a variable and in the code assign the constant to the variable, but in one fell swoop. UCSD doesn't.

You can define the data in assembly and store it in a PUBLIC variable, but that's also awkward.

You can type in the data (if that's the source you have) directly into a file with PATCH, and then read that file.

 

Or do as you did.

  • Like 4
  • Sad 1
Link to comment
Share on other sites

21 hours ago, LarryFromBuffalo said:

Has anyone played with the SOUND UNIT on UCSD PASCAL running on CLASSIC99?  I am simply trying to get the sounds to play but cannot seem to get it working.  Something simple i am missing?

 

Thanks!

 

image.thumb.png.8a6ab141c6692d97bf3442c1e584963d.png

I added an SND_VOLUME statement to your program but I still could not hear anything. I don't see anything wrong with that test program otherwise.

Incidentally, if you replace PLAY_SND(1) with PLAY_ALL_SND, you do hear some noise, but it does not appear to be related to the notes you set. 

I'll test it out on real hardware tonight.

program soundt;
uses sound;

var
 sl : sndlstptr;
 
begin
 make_snd_list(sl, 200);
 snd_tone(sl, 220, 4);
 snd_note(sl, 440, 8);
 end_snd(sl);
 snd_volume(sl, 15);
 set_snd(1, sl);
 play_all_snd;
 writeln('hello world!');
end.

 

Link to comment
Share on other sites

Although the p-system allows you to redefine characters between 0 and 31, several of these characters have terminal functions which are retained and thus lead to weird effects when displayed, a fact which betrays the essential nature of the UCSD Pascal system as a terminal-based system even when in graphics mode. This caused me a lot of head scratching before I figured it out. Here is a list of characters you should not redefine (there may be others):

  • 8 [BS]
  • 10 [LF]
  • 12 [FF]
  • 13 [CR]
  • 16 [DLE]
  • 30 [RS]

I would advise that unless you are very short on character space, try to avoid characters 1-31 altogether. Incidentally, character 0 is the cursor. This limitation is more than mitigated by the fact that you can redefine all the way to character 255.

  • Like 2
Link to comment
Share on other sites

12 hours ago, Vorticon said:

I added an SND_VOLUME statement to your program but I still could not hear anything. I don't see anything wrong with that test program otherwise.

Incidentally, if you replace PLAY_SND(1) with PLAY_ALL_SND, you do hear some noise, but it does not appear to be related to the notes you set. 

I'll test it out on real hardware tonight.

program soundt;
uses sound;

var
 sl : sndlstptr;
 
begin
 make_snd_list(sl, 200);
 snd_tone(sl, 220, 4);
 snd_note(sl, 440, 8);
 end_snd(sl);
 snd_volume(sl, 15);
 set_snd(1, sl);
 play_all_snd;
 writeln('hello world!');
end.

 

Tried it on real hardware and still no sound. A bit stumped here...

 

EDIT: OK figured it out. SND_VOLUME needs to be inside the sound list and before the notes that you want played. The program below works. I added a SET_SND_TEMPO as well.

SNDTEST.jpg.18995a3eea5999342382f87009db24d2.jpg

  • Like 3
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...