LisaList2

General Category => LisaList2 => Topic started by: kewatsdop on January 28, 2022, 02:19:50 am

Title: Newbie: simple Pascal program doesn't work in LisaEm
Post by: kewatsdop on January 28, 2022, 02:19:50 am
Hi all,

I'm new here so please don't be mad at me if this question has an obvious answer. I search the forum and Google and could not find anything obvious...

I input a very simple Pascal program "beep.text" in LisaEm, using Workshop 3.0:

PROGRAM sound;
USES HWINT;

BEGIN
    Beep(3000, 5000);
END.


Then I compile it with P command to beep.obj, then link it with L command using beep.obj, iospaslib.obj and sys1lib.obj. The object files are linked successfully into an output file bp.obj. Then I run the program with R, and it executes successfully but there's no sound from the beeper.

What am I doing wrong?

Adam

Title: Re: Newbie: simple Pascal program doesn't work in LisaEm
Post by: compu_85 on January 28, 2022, 07:59:29 am
If you go into the Preferences window and change the beeper volume does it make a tone?
Title: Re: Newbie: simple Pascal program doesn't work in LisaEm
Post by: kewatsdop on January 28, 2022, 08:13:22 am
I don't see beeper volume option (see attached), but LisaEm _does_ make beeper sounds e.g. when boot drive is missing or similar.
Title: Re: Newbie: simple Pascal program doesn't work in LisaEm
Post by: rayarachelian on January 28, 2022, 09:03:54 am
@compu_85 is talking about the Preferences icon in Lisa Office System (LOS). see: http://toastytech.com/guis/lisaos31prefs.png (http://toastytech.com/guis/lisaos31prefs.png)

(http://toastytech.com/guis/lisaos31prefs.png)


(You'd normally need to install both Lisa Pascal Workshop (LPW) + Lisa Office on the same ProFile drive and then use the Environments window to switch between them, though it's possible to just install LPW by itself.)
see: https://lisafaq.sunder.net/single.html#lisafaq-sw_os_environments (https://lisafaq.sunder.net/single.html#lisafaq-sw_os_environments)

However, first things first, do you hear sound effects such as clicks when the Lisa turns on/off and the floppy is accessed? So looks like you've replied that you do, so that's good.
Next, I'd say try changing the pitch value to some other value, and extend the delay, and see if that helps.

I'd also see if there's some Setvolume() function you can access from your code and try to set that, I guess to 5 or 7 or whatever the max is.

As an aside/reference for other sound issues with LisaEm:

(I know from your screenshot that you're using MacOS so the following doesn't apply to you, this section is for future reference for others who might be searching LisaList2 for sound issues.)
There is an issue on GTK (Linux, FreeBSD, etc.) with wxWidgets where, wxWidgets needs to be compiled with LibSDL in order for sound to work. see: https://docs.wxwidgets.org/trunk/classwx_sound.html (https://docs.wxwidgets.org/trunk/classwx_sound.html)
"Currently this class is implemented on Windows and Unix and can use either Open Sound System (OSS) or Simple DirectMedia Layer (SDL) under the latter. Notice that OSS is not provided any more by most, and maybe even all, Linux systems in 2017 and osspd (OSS Proxy Daemon) package typically needs to be installed to make it work."

So if you're on Linux/FreeBSD, you'll likely need the  pulseaudio/ALSA proxy package bridges installed as well. I know, it's a mess.
All that said, I've seen sounds fail on Windows and MacOS as well.

But generally if you can hear the sound effects in LisaEm, clicks, floppy, etc., and you've said you did in this thread, you should hear the beeps from the Lisa Boot ROM and LOS/LPW as well.
Title: Re: Newbie: simple Pascal program doesn't work in LisaEm
Post by: compu_85 on January 28, 2022, 09:54:23 am
You can access the preferences window within the workshop too - I believe it's under the System heading.
Title: Re: Newbie: simple Pascal program doesn't work in LisaEm
Post by: kewatsdop on January 28, 2022, 10:02:17 am
Thank you both for trying to help!

I did access the Preferences window, and I can hear the sound being played when setting the volume low/up, but the program above still doesn't give me any sound. I did play with frequency/duration values, to no avail.

If that helps in anything, I'm using macOS Monterey, lisaem-1.2.7-RC3a-2020.08.24, Workshop 3.0.

Title: Re: Newbie: simple Pascal program doesn't work in LisaEm
Post by: rayarachelian on January 28, 2022, 10:37:44 am
Welp, I'm out of ideas. :(
Title: Re: Newbie: simple Pascal program doesn't work in LisaEm
Post by: kewatsdop on January 28, 2022, 12:29:56 pm
Thank you for trying to help though...

I'll give it another try during the weekend on my Windows machine, with exactly the same steps, and will update us here.
Title: Re: Newbie: simple Pascal program doesn't work in LisaEm
Post by: rayarachelian on January 28, 2022, 01:25:25 pm
Thank you for trying to help though...

I'll give it another try during the weekend on my Windows machine, with exactly the same steps, and will update us here.

Sure thing. Pro tip, you can just copy the lisaem-profile.dc42 file from your Mac to your Windows machines. You won't be able to copy the preferences file, which on macos is in plist format (I think), but on Windows will be a .ini file, but you can manually copy the LisaEm preferences, etc.

If you want, could you create a blank dc42 floppy in LisaEm and use the LPW F)ile menu to copy both the source code and the compiled program to this new floppy image, and then once you eject that floppy image from LPW, upload it here. If I have time this weekend, I can poke at it and see what happens.

(I can compile LisaEm with debug enabled and add some code around the sound generation routines to see if LisaEm notices sound being invoked, and what frequency, etc.)
Title: Re: Newbie: simple Pascal program doesn't work in LisaEm
Post by: kewatsdop on January 28, 2022, 02:09:17 pm
Sure will do. Thank you Ray for helping. Also in about 10-12 days from now I'll have an opportunity to test this on a physical Lisa...

I will have other newbie questions too, but not sure if I should start a separate thread; I'm new to this forum and don't know the local netiquette. One thing for example is why, no matter how I try, I cannot set the 6552 Shift Register to any value in assembly code. I'm trying to do e.g. MOVE d0, $00FCDD81 or MOVE d0, $0000DD81 (documentation says sometimes former, sometimes latter for the VIA memory location) plus $14 offset to access the Shift Register and it always gives me ADDRESS ERROR when running the program from Pascal. Any ideas what I'm doing wrong? Sorry if this is not for this thread, will start a new one if needed.
Title: Re: Newbie: simple Pascal program doesn't work in LisaEm
Post by: rayarachelian on January 28, 2022, 03:28:51 pm
I've split the reply to this new topic (writing directly to the VIA) to this post: https://lisalist2.com/index.php/topic,242.0.html
Title: Re: Newbie: simple Pascal program doesn't work in LisaEm
Post by: kewatsdop on January 28, 2022, 04:35:45 pm
Thank you Ray, will follow in both threads. But somehow I cannot add my answer to the other thread ("Database Error").
Title: Re: Newbie: simple Pascal program doesn't work in LisaEm
Post by: blusnowkitty on January 28, 2022, 05:22:32 pm
Thank you Ray, will follow in both threads. But somehow I cannot add my answer to the other thread ("Database Error").

SMF (forum software) doesn't like the enhanced character set that OS X/iOS uses for things like apostrophes.
Title: Re: Newbie: simple Pascal program doesn't work in LisaEm
Post by: kewatsdop on January 28, 2022, 05:29:36 pm
Indeed, thank you blusnowkitty. I managed to upload my comment when I removed my m-dashes.
Title: Re: Newbie: simple Pascal program doesn't work in LisaEm
Post by: kewatsdop on January 29, 2022, 09:10:30 am
I started a new thread on being unable to mount a diskette, plus one more on not seeing a *.dc42 image from Mac on a Windows installation.
Title: Re: Newbie: simple Pascal program doesn't work in LisaEm
Post by: kewatsdop on January 29, 2022, 12:35:07 pm
Okay! I managed to copy over my Pascal file (source + compiled + linked) to a diskette, and I'm attaching it here.

Ray or others please let me know if I can help diagnose further.

Files:

beep.text -- source Pascal
beep.obj  -- compiled Pascal
bp.obj     -- linked executable
Title: Re: Newbie: simple Pascal program doesn't work in LisaEm
Post by: rayarachelian on January 29, 2022, 02:22:34 pm
Ok, so having added an ALERT_LOG call in the sound_play() function in lisaem_wx.cpp, I'm seeing output in the log that it's trying to play sounds, however there's some issue where it doesn't actually play the sound. :(

So this is a LisaEm bug. Turning on the RETARDED_SOUND definition makes it work most of the time for freq parameters 400-2200 on Linux. This should, but doesn't work on macos, not sure why.

(Note about the define RETARDED_SOUND is a define that composes a wav file and writes it to /tmp then plays it. The alternative is to compose the wav in memory and tell wxWidgets to play it that way which is better. But not great as it has to be in the proper format so there's a lot of gymnastics to create the file and then play it. There's no way to just give it a buffer with a waveform without the .wav header.)

At some point this code was ofc working.

Some days I really hate wxWidgets. :(
Title: Re: Newbie: simple Pascal program doesn't work in LisaEm
Post by: kewatsdop on January 29, 2022, 02:39:42 pm
Ok, that's actually good news (for me) because I thought I was doing something wrong. Good luck diagnosing the issue in LisaEm! I'm now going to try the other experiments with low-level control of the beeper, with your helpful guidance from the other thread.