Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
IF Nesting problem and +D Emulation (*solved*)
#2
LCD Wrote:
Code:
    while (a band 16)=0
        h=a band 5
        v=a band 10
        if oldh=4 then
            if h=5 then newx=x+1
            elseif h=0 then newx=x-1
            end If
        else if oldh=5 then
            if h=1 then newx=x+1
            elseif h=4 then newx=x-1
            end If
        else if oldh=1 then
            if h=0 then newx=x+1
            elseif h=5 then newx=x-1
            end If
        else if oldh=0 then
            if h=4 then newx=x+1
            elseif h=1 then newx=x-1
            end If
        end If
    wend
The syntax above is not right. The right one is:
Code:
while (a band 16)=0
        h=a band 5
        v=a band 10
        if oldh=4 then
            if h=5 then newx=x+1
            elseif h=0 then newx=x-1
            end If
=>>    elseif oldh=5 then
            if h=1 then newx=x+1
            elseif h=4 then newx=x-1
            end If
=>>    elseif oldh=1 then
            if h=0 then newx=x+1
            elseif h=5 then newx=x-1
            end If
=>>    elseif oldh=0 then
            if h=4 then newx=x+1
            elseif h=1 then newx=x-1
            end If
        end If
    wend
I introduce ELSEIF to reduce the IF-nesting complexity. If you use ELSE IF (separately) you'll need an extra END IF at the end for every ELSE IF instance.
Try this and tell me.
LCD Wrote:And I also noticed that one of my games crahes the Spectrum if ZX Spin is started with enabled +D emulation. Boriel, could you check all your compiler tests with ZX Spin and enabled +D? The game preview of QFJ I sent to you some time ago: If I try to play, the gems cannot be swaped. Without +D Emulation anything works okay.
What does +D do? At this 1st stage the compiler is supposed to be used only in 48K Speccy. I was astounded to hear the BG music in your chess game :!:
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)