LisaList2

Advanced search  

News:

2022.06.03 added links to LisaList1 and LisaFAQ to the General Category

Pages: 1 [2]   Go Down

Author Topic: Directly BEEPING on the Lisa by writing to VIA register  (Read 7994 times)

rayarachelian

  • Administrator
  • Hero Member
  • *****
  • Karma: +101/-0
  • Offline Offline
  • Posts: 772
  • writing the code,writing the code,writing the code
    • LisaEm
Re: Directly BEEPING on the Lisa by writing to VIA register
« Reply #15 on: January 31, 2022, 03:08:15 pm »

Thank you for the help so far. The Lisa Boot ROM Manual looks very helpful indeed, but I'm not getting what I expect here:

I tried its BEEP routine (page 39 in that manual) by executing:

                ORG $800

playsound:
                MOVE.w #$F0,D1
...


This does something with the speaker (short noisy sound), but definitely not the 4 sounds expected. Then it returns to ROM where I can diagnose the memory, etc.
...

Code: [Select]
0B46|                       ;  Do time delay -  enter with count in D1 (about .5 msec per count)


So according to the comments on the source, each cycle on D1 is .5ms. #$f0=240. So, 240*.5ms = 120ms.  1ms=1/1000th of a second, so the delay is something like 0.120s.  Since each D1 is 1/2 a millisecond, 1s should therefore be something like 1000*2 in D1. So try passing a much larger value for D1.
Like #2000, is what I'd guess.
Logged
You don't know what it's like, you don't have a clue, if you did you'd find yourselves doing the same thing, too, Writing the code, Writing the code

stepleton

  • Sr. Member
  • ****
  • Karma: +109/-0
  • Offline Offline
  • Posts: 385
Re: Directly BEEPING on the Lisa by writing to VIA register
« Reply #16 on: January 31, 2022, 04:41:15 pm »

Hmm, I don't really know. (ETA: just saw Ray's response; maybe that's it :) ) Here's an idea though: since your program is pretty small, it probably wouldn't be too hard to try it on a real Lisa even without using a floppy. Just get a hex dump of your assembled program (without the bootloader) and type it into memory using the Lisa's Service Mode.

Appendix A of the BLU manual shows you how to enter Service Mode and load and run a program. You will need to make some changes: specifically, you'll want to change the code itself after the 2900, 2910, 2920 etc. lines to your own code. Also, note that the BLU Simple Serial Loader program resides at address $900, and you've been assembling to $800... although your code doesn't have absolute addresses referring to itself yet, so this doesn't matter.

Take care that you include spaces as shown in the example.

Anyway, consider keying in a program that beeps once or twice and seeing what happens.

One last thing I'd recommend is concluding your program with something that will return control to the ROM, since right now I think you're letting the Lisa run off into uninitialised memory. I would just execute an RTS instruction, as if I'm not mistaken, the boot ROM uses a JSR to jump to the code you've keyed in (per line 292A of the boot ROM source).
« Last Edit: January 31, 2022, 04:42:50 pm by stepleton »
Logged

kewatsdop

  • Full Member
  • ***
  • Karma: +8/-0
  • Offline Offline
  • Posts: 28
Re: Directly BEEPING on the Lisa by writing to VIA register
« Reply #17 on: February 01, 2022, 02:38:22 am »

Thank you both.

Something is still not right with how this $FE00B8 subroutine is executed in LisaEm. Increasing the D1 value makes the pauses, not the sounds, longer. Duration of notes remains very short.

Also, the last note played is always quiet, regardless of the value of D2.

The code below is supposed to play 4 notes, each subsequent separated by an octave from the previous one (half the frequency), each 1-second long, and each with increasing volume. But only the pitches seem to work as expected; the duration is always very short, and the last note's volume is very low.

                ORG $800

                MOVE.b #10,D0
                MOVE.l #2000,D1
                MOVE.b #$4,D2
                JSR $FE00B8
                MOVE.b #20,D0
                MOVE.l #2000,D1
                MOVE.b #$6,D2
                JSR $FE00B8
                MOVE.b #40,D0
                MOVE.l #2000,D1
                MOVE.b #$8,D2
                JSR $FE00B8
                MOVE.b #80,D0
                MOVE.l #2000,D1
                MOVE.b #$A,D2
                JSR $FE00B8


Later in the week I'll try the same on my Windows machine, and next week on an actual Lisa as suggested.
Logged

kewatsdop

  • Full Member
  • ***
  • Karma: +8/-0
  • Offline Offline
  • Posts: 28
Re: Directly BEEPING on the Lisa by writing to VIA register
« Reply #18 on: February 01, 2022, 06:33:21 am »

Well did some more testing and it seems the sound output is inconsistent depending on where and how LisaEm is run. When running the exact same code as above, I get the following results:

- macOS laptop with built-in speakers: results as above (all 4 pitches audible, but duration wrong)
- macOS laptop connected to external speakers: only the first of 4 sounds audible
- Windows LisaEm: only brief noise audible, then nothing

Can't wait to try it out on an actual Lisa to compare...
Logged

rayarachelian

  • Administrator
  • Hero Member
  • *****
  • Karma: +101/-0
  • Offline Offline
  • Posts: 772
  • writing the code,writing the code,writing the code
    • LisaEm
Re: Directly BEEPING on the Lisa by writing to VIA register
« Reply #19 on: February 01, 2022, 08:58:15 am »

Well did some more testing and it seems the sound output is inconsistent depending on where and how LisaEm is run. When running the exact same code as above, I get the following results:

- macOS laptop with built-in speakers: results as above (all 4 pitches audible, but duration wrong)
- macOS laptop connected to external speakers: only the first of 4 sounds audible
- Windows LisaEm: only brief noise audible, then nothing

Can't wait to try it out on an actual Lisa to compare...


https://github.com/rayarachelian/lisaem/blob/unstable/src/host/wxui/lisaem_wx.cpp#L8636
So mea culpa. My bad. This is missing the loop flag:
Code: [Select]
my_lisa_sound.Play(wxSOUND_ASYNC|wxSOUND_LOOP);
Part of what you see is a limitation in wxWidgets - it can only play a single sound at a time, but the delay duration is all my fault.

The way it's supposed to work is that when the Lisa starts to play a sound through the speaker, LisaEm has no idea of how long it should play it for, so it sets the CPU throttle to 5MHz so it will be close to the length of what a real Lisa would play for.

Then when the VIA is told to shut down the SR rotation, or the volume goes to zero, it will stop playing.

(But if any other sound, such as the floppy motor starts to play, it will stop the sound - this part is a wxWidgets limitation.)

That said, even with the wxSOUND_LOOP bit, it will sometimes fail to play any sound anyway.

I have a TODO in my list to switch sound to OpenAL - this will happen either in 1.2.8 or 2.0, but Apple possibly threw a monkey wrench in that by removing it from macos 10.12 around there. That's another discussion. Why OpenAL, because it's available for Linux, FreeBSD, Windows, and macos. So I'll have to include it as a library. That will allow LisaEm to play multiple simultaneous sounds. So I could add widget, imagewriter/ADMP, daisywheel sounds as well.

Another possibility is to require libSDL and directly call it for sound, but I'm not so sure I want to do that for non GTK systems, plus OpenAL is dedicated for sound output and has a lot more features and capabilities that makes it better.
« Last Edit: February 01, 2022, 09:08:39 am by rayarachelian »
Logged
You don't know what it's like, you don't have a clue, if you did you'd find yourselves doing the same thing, too, Writing the code, Writing the code

kewatsdop

  • Full Member
  • ***
  • Karma: +8/-0
  • Offline Offline
  • Posts: 28
Re: Directly BEEPING on the Lisa by writing to VIA register
« Reply #20 on: February 01, 2022, 11:06:36 am »

Understood and thank you for digging into this.

Good luck resolving the issue whenever you have a chance to work on it.

Not knowing anything about writing emulators, I'm wondering if re-using the sound subsystems from other emulators, e.g. FS UAE (Amiga) or Fuse (ZX Spectrum) is possible; these emulators allow running programs in "bare metal" mode and demos/games written that way seem to produce sound correctly. This is not to suggest any direction of course as it may not even be possible for reasons beyond my understanding.

In any case I'm very grateful for LisaEm to exist, as I would be nowhere near understanding how Lisa works before I have a chance to try my experiments on the physical machine.
« Last Edit: February 01, 2022, 11:12:07 am by kewatsdop »
Logged

rayarachelian

  • Administrator
  • Hero Member
  • *****
  • Karma: +101/-0
  • Offline Offline
  • Posts: 772
  • writing the code,writing the code,writing the code
    • LisaEm
Re: Directly BEEPING on the Lisa by writing to VIA register
« Reply #21 on: February 01, 2022, 01:26:11 pm »

Understood and thank you for digging into this.

Good luck resolving the issue whenever you have a chance to work on it.

No worries, I should have RC4 soon-ish. I'm fixing a few other bugs. It'll include this sound fix, which hopefully will make things better, but not the larger move to OpenAL.
Logged
You don't know what it's like, you don't have a clue, if you did you'd find yourselves doing the same thing, too, Writing the code, Writing the code
Pages: 1 [2]   Go Up