English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Language > Coders. Blitz Basic

 
 
Thread Tools
Old 14 January 2018, 09:29   #61
peceha
Registered User
 
peceha's Avatar
 
Join Date: Dec 2017
Location: Poland
Age: 47
Posts: 282
Thanks!
Now it is not magic anymore
peceha is offline  
Old 16 January 2018, 18:38   #62
peceha
Registered User
 
peceha's Avatar
 
Join Date: Dec 2017
Location: Poland
Age: 47
Posts: 282
Hello
Two basic questions:

1. is it possible to pass a list to a function as an argument?

2. is it possible to declare a list within a function?
When I try to do this inside the function i get error "ARRAY IS NOT A LIST":
Code:
NEWTYPE.myType
 a.b
 b
 c
End NEWTYPE
Dim List lista.myType(100)
If AddItem(lista()) Then lista()\a=1 ;here the error shows up
When i move NEWTYPE...End NEWTYPE and DIM outside the function everything is working fine

Thanks.


EDIT
3.What is going on here:
Code:
NEWTYPE.bspArea
 c.b
 r
 w
 h
End NEWTYPE

Statement test{c,r,w,h}
 nPrint c," ",r," ",w," ",h
 ;DEFTYPE.bspArea panel    ;<- when i uncomment this line strange results are showing
End Statement

test{0,0,10,10}
MouseWait
End
without DEFTYPE: 0 0 10 10
with DEFTYPE: 0 0 10.9997 10

Last edited by peceha; 16 January 2018 at 21:39.
peceha is offline  
Old 16 January 2018, 22:54   #63
Daedalus
Registered User
 
Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,334
1: Not that I know of. You can use the Shared keyword to allow the procedure to access the same list as the main program. Newtypes can be passed as a pointer, but I don't think lists can be assigned to pointers so I don't think passing a list is possible. Maybe someone else knows a way though?

2: No, only indexed arrays can be declared within a function. As before however, you can use a global list with the Shared keyword, so long as you remember to clear it each time and don't do any recursion.

3: Hmmm, looks like a bug. What version of Blitz are you using? I vaguely remember in the AmiBlitz changenotes that there was a fix for some bug in parameter passing that you may have stumbled upon. It looks like a mismatch of types that's not getting picked up by the compiler / debugger. I would suggest always declaring types for parameters like that, and that should avoid the problem:

Statement test{c.b, r.b, w.b, h.b}
Daedalus is offline  
Old 16 January 2018, 23:07   #64
peceha
Registered User
 
peceha's Avatar
 
Join Date: Dec 2017
Location: Poland
Age: 47
Posts: 282
ad.3
Im using BB2 release 2.1, TED v2.24

When I replace Statement test{c,r,w,h,} with:
..{c.b, r.b, w.b, h.b} then i have 0 0 -8 10
..{c.w, r.w, w.w, h.w} then i have 0 0 -12 10
..{c.l, r.l, w.l, h.l} then i have 0 0 65516 10
peceha is offline  
Old 17 January 2018, 09:44   #65
Daedalus
Registered User
 
Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,334
Hmmm, that's very weird. There appears to be an extra byte or something assigned to the 3rd parameter. I would use a later version of Blitz 2 fro a start, see if that fixes the problem. The Ultimate Blitz Basic CD has a later version, and other updates are available from Blitz-2000.co.uk.
Daedalus is offline  
Old 17 January 2018, 09:54   #66
peceha
Registered User
 
peceha's Avatar
 
Join Date: Dec 2017
Location: Poland
Age: 47
Posts: 282
Thanks for help.
You were right about a bug:
Quote:
3rd parameter bugfix" Fixes an important and serious bug in the passing of the third parameter to functions.
I'll try to update everything now.

Thank you.
peceha is offline  
Old 18 January 2018, 23:10   #67
E-Penguin
Banana
 
E-Penguin's Avatar
 
Join Date: Jul 2016
Location: Darmstadt
Posts: 1,213
If there an equivalent of If ... Else If ... Else?

I've tried "Else If" "Elseif" and "Elsif" but it doesn't like any of them. There must be a way, surely?
E-Penguin is offline  
Old 19 January 2018, 11:42   #68
peceha
Registered User
 
peceha's Avatar
 
Join Date: Dec 2017
Location: Poland
Age: 47
Posts: 282
Hi,
how does QUALIFIER work?

I typed the script from manual but it doesnt work for me:
Code:
...
While (Qualifier AND $8)=0
...
Wend
...
what key press quits the loop?
peceha is offline  
Old 19 January 2018, 21:18   #69
TurboCrash
Registered User
 
Join Date: Dec 2015
Location: Lisbon/Portugal
Posts: 51
Quote:
Originally Posted by E-Penguin View Post
If there an equivalent of If ... Else If ... Else?

I've tried "Else If" "Elseif" and "Elsif" but it doesn't like any of them. There must be a way, surely?
If

Else

EndIf

I recommend having a PDF with OCR scan of the manual, it's available online.
TurboCrash is offline  
Old 19 January 2018, 21:33   #70
E-Penguin
Banana
 
E-Penguin's Avatar
 
Join Date: Jul 2016
Location: Darmstadt
Posts: 1,213
Also; how does one get dual playfields to work? I just can't seem to get the background to display. I guess it's a palette issue, but I'm not sure which colour to set.

To make matters more complicated (because an easy life isn't for me), I want to have an 8-coloured background and a 4-coloured foreground. The hardware should support this, but does Blitz? I'd rather not have 8-colours in my foreground as I want to minimize the amount of blitting.

http://amigadev.elowar.com/read/ADCD.../node0079.html

Is the secret to have 8 bitplanes in both fields but only blit the planes I actually want, using something like BitPlanesBitMap?

I realise that I may be running before I can walk... but I thought it should be relatively straightforward to have one box moving in front of the other...
E-Penguin is offline  
Old 19 January 2018, 21:40   #71
E-Penguin
Banana
 
E-Penguin's Avatar
 
Join Date: Jul 2016
Location: Darmstadt
Posts: 1,213
Quote:
Originally Posted by TurboCrash View Post
If

Else

EndIf

I recommend having a PDF with OCR scan of the manual, it's available online.
Thanks. I meant like (if it was java)

Code:
if (test1){
  do_thing_1
}
else if (test2){
  do_thing_2
}
else{
 do_default_thing
}
If test1=true then I needn't bother testing test2, which would save doing a comparison.

A concrete exampe; I'm bouncing a box around a screen, and I want to bounce it off the edges of the screen. So, I test for the 4 extremities. However, if the box hits one edge I needn't bother testing the opposite one, as it can't possibly hit both.

Last edited by E-Penguin; 19 January 2018 at 21:46.
E-Penguin is offline  
Old 20 January 2018, 07:52   #72
MickGyver
Registered User
 
MickGyver's Avatar
 
Join Date: Oct 2008
Location: Finland
Posts: 643
Quote:
Originally Posted by E-Penguin View Post
If there an equivalent of If ... Else If ... Else?

I've tried "Else If" "Elseif" and "Elsif" but it doesn't like any of them. There must be a way, surely?
As far as I know, there is no ElseIf. You should be able to do this:
Code:
If
  ...
Else
  If
    ...
  EndIf
EndIf
MickGyver is offline  
Old 20 January 2018, 12:26   #73
TurboCrash
Registered User
 
Join Date: Dec 2015
Location: Lisbon/Portugal
Posts: 51
Regarding the playfield and bitplanes take a look at page 80
https://archive.org/details/blitz-basic-2-user-guide

I think this applies to slices but the last version of Blitz 2.1 can do more with AGA and copperlist if I'm not mistaken, because I'm noob too
TurboCrash is offline  
Old 21 January 2018, 19:01   #74
Daedalus
Registered User
 
Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,334
Yep, witchmaster is correct, there's on ElseIf. Nesting the following If/Then in the Else portion as he suggested is about as close as you can get.

As for the dual playfields, both playfields should be treated as separate displays, so use colours 0-7 for the graphics in both (assuming 3+3 bit depths). These are used directly for the front playfield, and the rear playfield pens are remapped to pens 8-15. So pen 3 on a bitmap will be shown as colour 3 in the palette on the front playfield, but colour 11 on the rear playfield. If you don't set colours 8-15 in the palette or only allocated 8 colours when you set up the display, they default to black so that could explain why you're not seeing your graphics. This applies to both slices and Display Library displays, though I recommend using the Display Library as it's more powerful and flexible, and supports AGA.

As for splitting the display like that, the hardware does indeed support it but Blitz does not - displays can only be set up with the same number of bitplanes on both playfields. Blitting 3 bitplanes is pretty fast though so I would suggest just going with that until you discover you really need more blitter time. If that does turn out to be the case, you're on the right track - the BitplanesBitmap command allows you to blit fewer planes than the bitmap contains by using an intermediate dummy bitmap.
Daedalus is offline  
Old 21 January 2018, 19:40   #75
Daedalus
Registered User
 
Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,334
Quote:
Originally Posted by peceha View Post
Hi,
how does QUALIFIER work?

I typed the script from manual but it doesnt work for me:
Code:
...
While (Qualifier AND $8)=0
...
Wend
...
what key press quits the loop?
That should just quit pressing any key with Control held down. Qualifier is a function that returns a code telling you which qualifier key was pressed when the last keypress Intuition event was triggered. Bear in mind however that you need to be collecting Intuition events for that to work, so you should have either Event or WaitEvent within the While loop.
Daedalus is offline  
Old 21 January 2018, 20:10   #76
idrougge
Registered User
 
Join Date: Sep 2007
Location: Stockholm
Posts: 4,332
If…Else...ElseIf…Else constructs lead to the "dangling else" problem ( https://en.wikipedia.org/wiki/Dangling_else ), so it's understandable that the Acid guys avoided that in Blitz.

Most cases of ElseIf are usually just a more complex way of writing Select…Case…Case…End Select.
idrougge is offline  
Old 21 January 2018, 21:42   #77
E-Penguin
Banana
 
E-Penguin's Avatar
 
Join Date: Jul 2016
Location: Darmstadt
Posts: 1,213
Thanks all. I'll have another go at the dual playfield then and just blit the ones I need.

idrougge, I thought about replacing it with a select/case. In the end a nested if block did the trick.

My intended game is to be an Asteroids clone, and naively I created a bunch of x, y pairs in some newtypes, which I translate and draw with Poly onto a bitmap each frame. Just bouncing around the screen not doing much, I can get about 20 on my a1200 + b1230, but barely 6 on a stock A500.

Am I relying too much on the processor? My Plan B is to draw to a bitmap, cut out shapes and then QBlit those, but, surely, the 2d drawing functions should be able to handle more than 6 polygons? Any 3d game must be doing more than that, and I'm not dealing with a z-axis at all.
E-Penguin is offline  
Old 22 January 2018, 15:27   #78
peceha
Registered User
 
peceha's Avatar
 
Join Date: Dec 2017
Location: Poland
Age: 47
Posts: 282
Thanks Daedalus.

Now I think I have e quick one

Code:
var.q=2.9
fr.b = Frac(var)*10
print fr
And the result is... 8
Shouldn't be 9?
peceha is offline  
Old 22 January 2018, 17:30   #79
E-Penguin
Banana
 
E-Penguin's Avatar
 
Join Date: Jul 2016
Location: Darmstadt
Posts: 1,213
what if you change it to fr.q? I wonder if it is truncating too soon.
E-Penguin is offline  
Old 22 January 2018, 17:43   #80
peceha
Registered User
 
peceha's Avatar
 
Join Date: Dec 2017
Location: Poland
Age: 47
Posts: 282
I changed the type to [quick] and the result is: 8.9999

It means:
0.9 * 10 = 8.9999
and since type [byte] cuts everything after coma I get 8.

Looks like I need to be more careful when it comes to [quick] type.
peceha is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Blitz basic 2 Help Havie Coders. Blitz Basic 30 08 September 2013 09:15
blitz basic petza request.Apps 11 08 April 2007 01:49
Blitz Basic 2 anyone? jobro request.Apps 12 28 November 2005 18:15
Blitz Basic StopCD32 Tony Landais Coders. General 2 08 May 2003 22:51
Blitz Basic 2 LaundroMat Retrogaming General Discussion 5 24 July 2001 08:10

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 18:15.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.27077 seconds with 14 queries