English Amiga Board

English Amiga Board (https://eab.abime.net/index.php)
-   Coders. Tutorials (https://eab.abime.net/forumdisplay.php?f=73)
-   -   Blitz2 blit and block statements inside procedures (https://eab.abime.net/showthread.php?t=68973)

htdreams 28 April 2013 13:44

Blitz2 blit and block statements inside procedures
 
Hi!

As i keep on learning Blitz2 and try different things out, i have the following code

Code:

; init code and img loading & shape adquiring...
; now the problematic code:
statement paintmap{bitmapnum, startx, starty}
  shared map()
 
  use bitmap bitmapnum
  for y=0 to 15
    for x=0 to 19
      blit map.b(startx + x, starty + y), x asl 4, y asl 4
    next
  next
end statement

blitz
slice 0,44,320,256,$fff8,5,8,32,320,320

paintmap{0,mapx,mapy}
show 0
use palette 0

mousewait
end

If i use the statement as shown, and it's the same using blit or block statemens to paint, i have a execution error telling me Blit or Block are only available in AMIGA mode... and i don't understand what is wrong...

I managed to get the above example working replacing the procedure paintmap with a subroutine:

.paintmap:
all the same code as in the procedure
return

And now it runs ok... but i would preffer to use procedures instead of subroutines...

Any ideas? :-)

leathered 28 April 2013 18:16

Just a shot in the dark, but is that a compile time error? Is it simply because blitz expects a Blit command after a BLITZ call in the program listing - even though it's in a statement?

Graham Humphrey 29 April 2013 00:50

It's a runtime error, I had the same thing recently. Basically though you're right - you'll need to ensure that the BLITZ command is before your statement code. It's a bit strange it works like that but that solved the problem for me.

htdreams 29 April 2013 02:19

I see... the thing is that i was choosing to use procedures instead of subroutines to have a clear code, in a more organized way, but this way i would have procedures all over my code, before and after mode changes... this is ridiculous :-D

I'll keep using subroutines then

Graham Humphrey 29 April 2013 08:36

Not necessarily. What might work is if you have certain routines that you use in Blitz mode, and some in Amiga mode, precede all the Blitz mode statements with the BLITZ command and then put all your Amiga mode statements under the AMIGA command. Preferably put them right at the top of your code.

I agree it is ridiculous, it surely must be a bug in Blitz.


All times are GMT +2. The time now is 17:34.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.

Page generated in 0.04801 seconds with 11 queries