[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Difficulty programming sound via AppleSoft & machine language



On Nov 27, 3:10 am, Jerry <awande...@yahoo.ca> wrote:
> KP <kjpm...@gmail.com> writes:
> > I have a program listing that I've typed in from a (very) old issue of
> > 3-2-1 Contact magazine (successor to the old Enter magazine) from the
> > mid-80s.  It is supposed to produce sound, but when it hits line 320
> > (the CALL to location 770), it just hangs.  I have tried everything
> > and can't seem to get it to work.
>
> > Does anyone have a suggestion?
>
> > Here's the program (only about 32 simple lines):
>
> > REM SPACE PHONE
> > REM 3-2-1 CONTACT MAGAZINE
> > REM BASIC TRAINING
> > REM PAGE 36
>
> > 10 HOME
> > 20 FOR AD = 770 TO 790
> > 30 READ BYTE
> > 40 POKE AD,BYTE
> > 50 NEXT AD
> > 60 DATA 173, 48, 192, 136, 208, 5, 20, 6, 1, 3, 240, 9, 202, 208, 245,
> > 174, 0, 3, 76, 2, 3, 96
> > 70 HOME : VTAB 12
> > 80 PRINT "PREPARE TO RECEIVE ALIEN TRANSMISSION
> > 90 K = 32
> > 100 FOR J = 50 TO 17 STEP - 1
> > 110 GOSUB 300
> > 120 NEXT J
> > 130 HOME
> > 140 B = INT (RND(1) * 80 + 1)
> > 150 GOSUB 230
> > 160 VTAB 20 : HTAB 1
> > 170 PRINT "WHAT IS YOUR REPLY?"
> > 180 INPUT R$
> > 190 IF R$ = "BYE" THEN 210
> > 200 GOTO 130
> > 210 B = 5: GOSUB 230
> > 220 END
> > 230 FOR A = 1 TO B
> > 240 J = INT(RND(1) * 45 - 20)
> > 250 K = INT(RND (1) * 45 - 20)
> > 260 PRINT CHR$ (K);
> > 270 GOSUB 300
> > 280 NEXT A
> > 290 RETURN
> > 300 POKE 768,J
> > 310 POKE 769,K
> > 320 CALL 770: RETURN
>
> I think your DATA statement has some bad numbers:  5, 20, 6
>
> It disassembles to this:
>
> 302: ad 30 c0   lda $c030
> 305: 88         dey
> 306: d0 05      bne $30d
> 308: 14 06      trb $06   ; (on 65C02 or 65816)
> 30a: 01 03      ora ($03,x)
> 30c: f0 09      beq $317
> 30e: ca         dex
> 30f: d0 f5      bne $306
> 311: ae 00 03   ldx $300
> 314: 4c 02 03   jmp $302
> 317: 60         rts
>
> The BNE at $306 branches to the middle of the BEQ at $30C which instead
> becomes:
>
> 30d: 09 ca      ora #$ca
> 30f: bne        $306
>
> This will cause an infinite loop which explains why it hangs.
>
> --
> Jerry    awanderin at yahoo dot ca

Thank you!  Any ideas on what I should change the offending numbers to?