English Amiga Board


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

 
 
Thread Tools
Old 18 August 2017, 15:42   #121
E-Penguin
Banana

 
Join Date: Jul 2016
Location: Darmstadt
Posts: 363
Quote:
Originally Posted by Daedalus View Post
In the original Blitz 2.1, you still need to specify a maximum size, so

Dim List Things.l(200)

allocates enough memory for containing your list with 200 items in it, even though it contains 0 objects. They're still "dynamic" in that they only show the number of items you put in, but you'll get crashes if you go above the maximum.
Could create your own linked list implementation though, with a NewTypes containing the thing you want and pointers to the previous/next (or some START/END placeholder)?

Code:
NewType .thing
    name.s
End NewType

NewType .thingListItem
    myThing.thing
    *some_pointer_thing_here.thingListListem
End NewType
and so on.

I'm getting ready to dive into Blitz Basic and will have endless questions coming over the weekend. Watch this space.
E-Penguin is offline  
AdSense AdSense  
Old 18 August 2017, 20:16   #122
idrougge
Registered User
 
Join Date: Sep 2007
Location: Stockholm
Posts: 3,047
Are you sure you can do that?
idrougge is offline  
Old 18 August 2017, 20:43   #123
E-Penguin
Banana

 
Join Date: Jul 2016
Location: Darmstadt
Posts: 363
Not at all sure. Hence the question!

Well, I would do it in c but that's a boring language. Every man and his dog does c.

I think pointers are stored as data.l so perhaps the pointer needs to be cast to / from the appropriate NewType. Is casting a thing in Blitz Basic?
E-Penguin is offline  
Old 19 August 2017, 01:18   #124
Daedalus
Registered User

Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 2,269
You can just store the pointers as longwords in Blitz and they'll work fine. Pointers are broadly the same in Blitz as in C, but there are subtle differences in their implementation. You can define a pointer in a Newtype, but you access it without the *, so for your example you would access your link pointer as:

*nextItem = MyVariable.thingListItem\some_pointer_thing_here

The awkwardness comes from actually creating the items, which I think will have to be allocated in memory manually and then assigned to a pointer when that item is required. You can use SizeOf .thingListItem to get the size of the allocation, and use the standard exec memory routines. It should be relatively doable as a set of functions that you could put in an include is you wished to use them in multiple programs.
Daedalus is offline  
Old 19 August 2017, 02:05   #125
Cylon
Registered User

 
Join Date: Oct 2014
Location: Europe
Posts: 466
@E-Penguin
Yes, you can do those things with BlitzBasic2.

There are caveats, of course.

here is an example:

It creates a list of titem and then adds the first node, then another. And links them together to a ring-like structure.
Code:
NEWTYPE.thing

  data.w

End NEWTYPE

NEWTYPE.titem

  ola.thing

  *nxt.titem

End NEWTYPE

Dim List exmpl.titem(10)


NPrint &exmpl(0) , " >> ",exmpl(0)\nxt
NPrint &exmpl(1)

If AddLast (exmpl())

  root.l= &exmpl()

  Print    root , " >> nxt ="

  exmpl()\nxt = root ;or 0 to end this

  NPrint   exmpl()\nxt

  store.l=exmpl()\nxt

  If AddLast (exmpl())

    Print    &exmpl(), " >> nxt ="

    exmpl()\nxt = store.l ; or root or 0 to end this

    NPrint   exmpl()\nxt
  EndIf

EndIf

NPrint "SizeOf thing : ",SizeOf.thing
NPrint "SizeOf titem : ",SizeOf.titem

MouseWait

End
Here is one tricky thing: In the example above you can see me using an index value for accessing list items. This is not (really) working in BB2. At least, it works until you change the list items somehow. then everything gets newly allocated and the index's points to ... somewhere. So don't do that. Even if it works somehow sometimes.

Pointers are casted and treated as LONGs, but you have to take care for yourself to not free a pointer to something or refer via a pointer to an address without veryfying the address. Blitz will also try to cast ANYTHING to ANYOTHER without telling you. Your job, Coder (well, you might get compiler errors, syntax errors, overflow errors - make the best of it).

Last edited by Cylon; 19 August 2017 at 02:27.
Cylon is offline  
Old 03 September 2017, 12:29   #126
E-Penguin
Banana

 
Join Date: Jul 2016
Location: Darmstadt
Posts: 363
Sprite Multiplexing - what is it and how can you do it in blitz2
E-Penguin is offline  
Old 03 September 2017, 15:10   #127
Cylon
Registered User

 
Join Date: Oct 2014
Location: Europe
Posts: 466
You have only 8 sprites in hardware to display, so called sprite channels.
If you want to display more sprites than 8, you have to reuse the channels multiple times.

so, lets say you display one sprite in the upper part of the screen. a couple of milliseconds later the video hardware has passed that part of screen and therfore already displayed this sprite. Now you can use this channel to display another sprite lower on the screen, where the screen has not yet been drawd.
Cylon is offline  
Old 05 September 2017, 01:02   #128
Daedalus
Registered User

Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 2,269
Blitz includes a DisplayLibrary command that sets this up in the Coplist for you, though I've never used it myself. Check out the CustomSprites command, bearing in mind that you'll need to add the desired value (4*number of sprites + 2) to the Custom space in your InitCopList line. This gives you a second use of each of the eight sprite channels, with channels numbered 8-15 instead.
Daedalus is offline  
Old 23 October 2017, 04:34   #129
Cobe
Registered User

 
Join Date: Jan 2014
Location: Belgrade / Serbia
Age: 34
Posts: 513
Ok, guys, is it just too late or AGA dualplayfield playfield 2 by default uses colors 8-23??

I'd say it is. Had to set bplcon3 bit 12-10 to 100 with displaycontrols 0,0,$1c00,0 now its 16-31.

Last edited by Cobe; 23 October 2017 at 05:31.
Cobe is offline  
Old 23 October 2017, 14:28   #130
Daedalus
Registered User

Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 2,269
By default the AGA dual playfield display uses colours 8-23 because that is compatible with ECS, which uses 0-7 for the first playfield and 8-15 for the second. As you point out, bits 10-12 set the pen offset of the second playfield, with %000 being no offset (starts at 0), %001 being 2, %011 being 8 (default ECS mode), all the way up to %111 being 128.
Daedalus is offline  
AdSense AdSense  
 


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] How much amiga-blitz friendly is this? saimon69 Coders. Blitz Basic 104 29 November 2016 21:45
Blitz Basic (1) Retro1234 Coders. Blitz Basic 9 18 February 2016 18:54
Blitz basic 2 Help Havie Coders. Blitz Basic 30 08 September 2013 10:15
Blitz Basic 2 anyone? jobro request.Apps 12 28 November 2005 19:15
Blitz Basic 2 LaundroMat Retrogaming General Discussion 5 24 July 2001 09: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 10:51.


Powered by vBulletin® Version 3.8.8 Beta 1
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Page generated in 0.20790 seconds with 15 queries