Split from:
https://lisalist2.com/index.php/topic,240.0.htmlJust had another thought, perhaps the Beep procedure runs asynchronously? That is it immediately returns to the caller, but then in that case, your executable would immediately quit, perhaps stopping the beep from happening.
Maybe you can add some kind of Sleep() or Delay() procedure before quitting to see if it does anything different?
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.
Yes, please open a new topic with this and give details as to how you're doing this, etc.
I can tell you that this is incorrect:
MOVE d0, $0000DD81
Because there's no VIA at that address. All I/O exists at $00fcxxxx - but this is only available in context 0 (supervisor mode). If you're running that from LPW, it will never work because your code won't run in supervisor mode, and only the OS has access to I/O (and SIO) spaces.
You'd ofc have to set the ACR on via #1 to enable the CB1 or CB2 output of the shift register of the VIA, but sounds like you already know about that. Also take a look at the Lisa Boot ROM source code, should be available on bitsavers which has code for beeping.
0AF6| ; Routine to beep the speaker
0AF6| ; Assumes regs set up as
0AF6| ; D0 = desired frequency ($00 - $AA)
0AF6| ; D1 = duration (0 = .5 msec)
0AF6| ; D2 = volume (0,2,4,...,E)
0AF6| ;-------------------------------------------------------------------------
0AF6|
0AF6| 48E7 1088 TONE MOVEM.L A0/A4/D3,-(SP) ;save regs
0AFA| BSRS4 TONE2 ;go do tone
0AFA| 49FA 0004 # LEA @1,A4
0AFE| 6006 # BRA.S TONE2
0B00| #@1
0B00| 4CDF 1108 MOVEM.L (SP)+,A0/A4/D3 ;restore and exit
0B04| 4E75 RTS
0B06|
0B06| ; separate entry point for call without memory usage
0B06|
0B06| 207C 00FC DD81 TONE2 MOVEA.L #VIA1BASE,A0 ;set VIA ptr
0B0C| 0028 000E 0004 ORI.B #$0E,DDRB1(A0) ;set volume bits for output
0B12| 0210 00F1 ANDI.B #$F1,ORB1(A0) ;clear and then
0B16| 8510 OR.B D2,ORB1(A0) ; set volume bits
0B18| 0228 00E3 0016 ANDI.B #$E3,ACR1(A0) ;clear shift mode bits
0B1E| 0028 0010 0016 ORI.B #$10,ACR1(A0) ;set shift reg for continuous rotate
0B24|
0B24| ; check system type
0B24|
0B24| 4A39 00FC C031 TST.B DISKROM ;test for Lisa 1 board CHG014
0B2A| 6A10 BPL.S @3 ;no changes if yes CHG014
0B2C| 0839 0005 00FC C031 BTST #SLOTMR,DISKROM ;else check if slow timers CHG029
0B34| 6606 BNE.S @3 ;skip if yes CHG029
0B36| 1600 MOVE.B D0,D3 ;else adjust input parm CHG014
0B38| E40B LSR.B #2,D3 ; by factor of .25 CHG014
0B3A| D003 ADD.B D3,D0 ; CHG014
0B3C|
0B3C| 1140 0010 @3 MOVE.B D0,T2CL1(A0) ;set frequency
0B40| 117C 000F 0014 MOVE.B #$0F,SHR1(A0) ;set for square wave and trigger
0B46|
0B46| ; Do time delay - enter with count in D1 (about .5 msec per count)
0B46|
0B46| 363C 00D0 @1 MOVE.W #$00D0,D3 ;set delay constant
0B4A| 51CB FFFE @2 DBF D3,@2
0B4E| 51C9 FFF6 DBF D1,@1
0B52|
0B52| 0228 00E3 0016 SILENCE ANDI.B #$E3,ACR1(A0) ;disable tone
0B58| RTS4 ;and return
0B58| 4ED4 # JMP (A4)
You might be able to do this from Service Mode, or by writing your code to a floppy in the 1st boot sector (it will start to execute from $20000) by setting tags 4,5 on that sector 0 to AA,AA.
If you dislike Service mode, you can also mess around with my nanoBug image -
https://github.com/rayarachelian/nanobug but you'll need to use the serial port for this.
Neither Service Mode, nor nanoBug have built in assemblers, so you'd assemble your code, copy your hex values somewhere and then enter them again in these and then execute the code and see what happens.
You can find prebuilt ones here:
https://lisalist2.com/index.php/topic,241.0.html (just uploaded them.)
Another option is to run your code from MacWorks - that is inside of MacOS using something like Macsbug or whatever assembler, or C/Pascal compiler you like. MacWorks runs in MMU context 0 and therefore has full access to I/O address space.
As "newbie" as you might be, you're doing awesome.
Welcome to LisaList2