Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
IF Nesting problem and +D Emulation (*solved*)
#1
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 compiler does not like this, and revolts against WEND (should it not work?), but after removing some IFs this works:
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
        end If
    wend

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.
------------------------------------------------------------
http://lcd-one.da.ru redirector is dead
Visit my http://members.inode.at/838331/index.html home page!
Reply
#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
#3
boriel Wrote: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.
You are right, the code was very old and I wanted to reuse it for my new project. Sorry, forgot to remove the spaces.

boriel Wrote: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 :!:
+D is a very common Disc interface with parallel port, and very compatible because it does not use any extra RAM from Spectrum. It has syntax like LOAD d1"file" which rely on RST #08. 8 KB ROM and 8 KB RAM are build in.
<!-- m --><a class="postlink" href="http://www.worldofspectrum.org/infoseekid.cgi?id=1000246">http://www.worldofspectrum.org/infoseek ... id=1000246</a><!-- m -->

The Soundtracker BG Music was possible with my Interrupt Maker. All the Interrupt and Music code was linked to my game after it was compiled. BorIDE should include a Interrupt maker later.
------------------------------------------------------------
http://lcd-one.da.ru redirector is dead
Visit my http://members.inode.at/838331/index.html home page!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)