English Amiga Board


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

 
 
Thread Tools
Old 08 January 2021, 16:02   #1
Amiga1992
Registered User
 
Join Date: May 2001
Location: ?
Posts: 19,645
Including graphics?

Forgive me for i am a complete and total blitz 2 neophyte, and I have been reading through the manual (though not entirely, who does that? :P), but I couldn't find a way to include my graphic assets into the code.

I don't want the program to load graphic files externally at runtime, I want to do what on other languages would be like an "incbin" so the graphic assets are compiled into the executable.

Is this possible? I read references in these forums to INCLUDE, it is in the index page of this site: http://docs.amiblitz.de/blitzprogrammers/0001.html ,but I really cannot see how it works in the manual.
Amiga1992 is offline  
Old 08 January 2021, 16:05   #2
StingRay
move.l #$c0ff33,throat
 
StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
I think Blitz Basic 2 supports "INCBIN" which can be used to include any binary files. I may be wrong though.
StingRay is offline  
Old 08 January 2021, 16:35   #3
Amiga1992
Registered User
 
Join Date: May 2001
Location: ?
Posts: 19,645
Quote:
Originally Posted by StingRay View Post
I think Blitz Basic 2 supports "INCBIN" which can be used to include any binary files. I may be wrong though.
You mean using inline assembler to do an incbin?

Blitz seems to have two commands, INCLUDE and XINCLUDE, according to the index of that manual I linked to above, that I am *guessing* would do what I want, but I can't find where they are mentioned because the index does not link to the rest of the manual, just has page numbers (but the online manual has no page numbers :/)
Amiga1992 is offline  
Old 08 January 2021, 16:42   #4
StingRay
move.l #$c0ff33,throat
 
StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
INCBIN is a native BB2 directive if memory serves me right. INCLUDE is for including sources (i.e. text files), XINCLUDE can be used to include a file only one (exlusive).
StingRay is offline  
Old 08 January 2021, 16:44   #5
Amiga1992
Registered User
 
Join Date: May 2001
Location: ?
Posts: 19,645
Quote:
Originally Posted by StingRay View Post
INCBIN is a native BB2 directive if memory serves me right. INCLUDE is for including sources (i.e. text files), XINCLUDE can be used to include a file only one (exlusive).
YES you are right, going section by section, I found the right page:
http://docs.amiblitz.de/blitzprogrammers/0154.html

Thanks a lot, I feel like a right twat for not finding this before. I guess I needed some hand holding.

I guess my trouble now is figuring out where this is put and how to access it. Maybe it's not worth the trouble but I rather produce a single executable to be distributed than a bunch of files.
Amiga1992 is offline  
Old 08 January 2021, 18:13   #6
idrougge
Registered User
 
Join Date: Sep 2007
Location: Stockholm
Posts: 4,336
You can make use of the INCBINed assets using the Decode range of commands, pointing them at a label at the line where you INCBIN a given asset using ?label.
idrougge is online now  
Old 08 January 2021, 19:54   #7
Adrian Browne
Jackie Chan
 
Join Date: Mar 2012
Location: Ireland
Age: 46
Posts: 986
Quote:
Originally Posted by Akira View Post
Forgive me for i am a complete and total blitz 2 neophyte, and I have been reading through the manual (though not entirely, who does that? :P), but I couldn't find a way to include my graphic assets into the code.

I don't want the program to load graphic files externally at runtime, I want to do what on other languages would be like an "incbin" so the graphic assets are compiled into the executable.

Is this possible? I read references in these forums to INCLUDE, it is in the index page of this site: http://docs.amiblitz.de/blitzprogrammers/0001.html ,but I really cannot see how it works in the manual.
Are you making a game?
Adrian Browne is offline  
Old 09 January 2021, 06:10   #8
Amiga1992
Registered User
 
Join Date: May 2001
Location: ?
Posts: 19,645
Quote:
Originally Posted by idrougge View Post
You can make use of the INCBINed assets using the Decode range of commands, pointing them at a label at the line where you INCBIN a given asset using ?label.
Where do I find these commands? The manual I linked to above is a mess to use as no page is cross referenced, there is no search, etc.

Quote:
Originally Posted by Adrian Browne View Post
Are you making a game?
Does that matter at all? If that's because you wonder if I am making an OS friendly program, the answer is no.

Last edited by lilalurl; 09 January 2021 at 09:56.
Amiga1992 is offline  
Old 09 January 2021, 15:08   #9
Amiga1992
Registered User
 
Join Date: May 2001
Location: ?
Posts: 19,645
So far Blitz has proved to be a little confusing and weird compared to more modern languages. I also realized the hard way, that some things don't work depending on where you put them. Like, procedures you want to use during BLITZ mode, need to be declared inside BLITZ mode

Also am I missing something or can I not send as argument to a procedure a reference to an object? This really grinds my gears. It wouldn't be such a probelm if I could make functions that return newtypes, but seems like this is not possible or I am unable to find how.

Mainly wish the manual was a lot better...
Amiga1992 is offline  
Old 09 January 2021, 17:31   #10
idrougge
Registered User
 
Join Date: Sep 2007
Location: Stockholm
Posts: 4,336
Quote:
Originally Posted by Akira View Post
Where do I find these commands? The manual I linked to above is a mess to use as no page is cross referenced, there is no search, etc.
There are several revisions of the Blitz paper manual, as well as addenda published over the years (the so-called BUMs). So try to find a more complete scan of the proper manual.

Me, I’ve just mashed together a lot of Amigaguide files in one file which I search.
idrougge is online now  
Old 09 January 2021, 17:39   #11
idrougge
Registered User
 
Join Date: Sep 2007
Location: Stockholm
Posts: 4,336
Quote:
Originally Posted by Akira View Post
So far Blitz has proved to be a little confusing and weird compared to more modern languages. I also realized the hard way, that some things don't work depending on where you put them. Like, procedures you want to use during BLITZ mode, need to be declared inside BLITZ mode
Yes, that is extremely confusing.

Quote:
Originally Posted by Akira View Post
Also am I missing something or can I not send as argument to a procedure a reference to an object? This really grinds my gears. It wouldn't be such a probelm if I could make functions that return newtypes, but seems like this is not possible or I am unable to find how.
Depends on what you mean by »object«, that’s a specific term in Blitz.

You can pass newtypes into procedures using a declaration like:

Code:
Statement MoveEnemy{*enemy.Enemy}
Then you call it using:

Code:
MoveEnemy{enemy}
Quote:
Originally Posted by Akira View Post
Mainly wish the manual was a lot better...
Yes, it’s totally hopeless.
idrougge is online now  
Old 09 January 2021, 18:22   #12
Master484
Registered User
 
Master484's Avatar
 
Join Date: Nov 2015
Location: Vaasa, Finland
Posts: 525
Quote:
Where do I find these commands? The manual I linked to above is a mess to use as no page is cross referenced, there is no search, etc.
This is the manual that I myself use:
https://archive.org/details/bb21manual

It has all the commands of the classic Blitz Basic 2.1, as well as reference cards for the rawkey codes, and also you can search for certain words in the PDF.
Master484 is offline  
Old 11 January 2021, 16:32   #13
Amiga1992
Registered User
 
Join Date: May 2001
Location: ?
Posts: 19,645
Quote:
Originally Posted by idrougge View Post
You can pass newtypes into procedures using a declaration like:

Code:
Statement MoveEnemy{*enemy.Enemy}
Then you call it using:

Code:
MoveEnemy{enemy}
Ah you legend, that's how it works then. I thought you declared the type like:
Code:
Statement.MyNewType {}
so that wasn't working. And what's the asterisk for?
Again I found no such info in the manual or Amigacoding.
With "object" I meant any data structure I create. I'm used in things like C# that I can just reference an object (pointer to the data structure?) and modify it.

As for the manual, I'll give a look at these suggestions. I'd prefer something online I can search through, but at this point, anything helps.
Amiga1992 is offline  
Old 11 January 2021, 22:26   #14
Daedalus
Registered User
 
Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,346
Quote:
Originally Posted by Akira View Post
Where do I find these commands? The manual I linked to above is a mess to use as no page is cross referenced, there is no search, etc.
Yeah, the manual is a bit of a mess - you need to have a rough idea of what you're looking for and then browse the relevant sections. And then it doesn't include the additional 3rd party command libraries, which are more or less standard in all but the most basic installation. I'm not sure if you're using Blitz 2 or Amiblitz 3, but the help file that comes with AB3 includes the manual plus the additional libraries in AmigaGuide format, and browsing the library list for a command is kinda easier that way. Even if you're using BB2, you could grab the guide file and have a rummage. There are a number of separate files involved, but you can grab them here, or download the entire AB3 archive to get them.

Quote:
Originally Posted by Akira View Post
So far Blitz has proved to be a little confusing and weird compared to more modern languages. I also realized the hard way, that some things don't work depending on where you put them. Like, procedures you want to use during BLITZ mode, need to be declared inside BLITZ mode
Yep, it's a little confusing alright, and is really down to the Blitz compiler actually being a bit simple. You just have to remember that those commands are compiler directives and not regular commands, and that might help you to sort it out in your mind. The compiler switches from Blitz to Amiga mode as it scans the code, and will compile different versions of some commands based on whichever mode it's in. So if you have segments of code that are to be used in both Blitz and Amiga modes, it might be a good idea to have separate versions of the routine for each mode.

Quote:
Originally Posted by Akira View Post
Ah you legend, that's how it works then. I thought you declared the type like:
Code:
Statement.MyNewType {}
so that wasn't working. And what's the asterisk for?
Functions can only return primitive types in Blitz.

The * denotes a pointer, similarly to C. Pointers are a bit of a broad subject and aren't strictly an object, but you can sort of treat them as one in this instance. They carry the address in memory of a struct / Newtype, so are simply a number (long type) with a special meaning. With that in mind, it's possible to pass them to or from procedures if necessary. Idrougge's method should let you modify the data directly without having to actually return anything ans is probably the most elegant solution, but if necessary you can also do it using a return value: You can receive a pointer from a function that returns it as a long value, but you have to be careful: if the pointer is to a local variable or struct in the function, the data will no longer exist once the function exits, so the pointer will point to garbage. For this reason, you could use global variables (primitive or Newtype) and return a pointer to one of them if needed, and that will work as expected:
Code:
Deftype .mytype var

Function.l myFunction{value.w}
  Shared var
  var\count + value
  Function Return &var
End Function

[...]

*myStruct.mytype = myFunction{3}
NPrint *myStruct\count
But if that's your only reason for using pointers, then it's probably simpler to just use the globals as-is.

Quote:
Again I found no such info in the manual or Amigacoding.
Hmmmm, good point - I thought I had included a section on pointers, but I haven't. I'll add it to the list and add it at some point unless someone else gets there first

Quote:
As for the manual, I'll give a look at these suggestions. I'd prefer something online I can search through, but at this point, anything helps.
As I said above, even if you compile in Blitz 2, the AmiBlitz 3 environment has the manual and 3rd party guides in AmigaGuide format, and as an editor, also provides nicer help (shift+Help when the cursor is on a keyword to open the guide on that page, for example), and comes with a library browser that lists all the commands and their basic syntax in a given library.

But even in Blitz2, typing a command and pressing Help with the cursor on the command will give you a quick syntax reference in the screen bar.
Daedalus is offline  
Old 11 January 2021, 23:24   #15
Amiga1992
Registered User
 
Join Date: May 2001
Location: ?
Posts: 19,645
Thanks for your help guys. I'm using Blitz 2.1 to compile, but Notepad++ to make the code in, I have no interest in using the Amiga editors of BB2 or AB3.

So the asterisk is a pointer! good to know. Yeah what idrougge described is exactly what I wanted to do. I was trying to make a procedure to initialize my newtype elements, and doing it that way is maybe the best way. As it is, I had already used the SHARED keyword, even if it is a little confusing.

Sorry I have dragged this so off topic. I'll get back to including graphics in my code. I need to test this as I haven't yet. Besides wanting to produce what I am working of as a single executable file, I also have a little secret part in it that I don't want spoiled by having files outside that would reveal it
Amiga1992 is offline  
Old 12 January 2021, 10:24   #16
Daedalus
Registered User
 
Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,346
Cool beans. Even if not using the editor for the actual code though, the AmigaGuide documentation might be worth having. The Decode commands live in the sections of the manual for what you're actually decoding - DecodeILBM is what you need for decoding a bitmap, and is in the Bitmaps chapter of the manual.

Include and XInclude are both for including additional source files, like #include in C. IncBin on the other hand is for embedding an actual chunk of binary data in the executable. Putting a label directly before it will allow you to find the address location to decode, but you need to make sure you don't actually execute the IncBin'd data.

Code:
Bitmap 0, 320, 256, 4
DecodeILBM 0, ?image1

[ rest of main program ]

End

.image1
IncBin "Data:image.iff"
Note, it's not something I've actually used myself, but that's my understanding of how it works. Also, depending on your use, there's also DecodeShapes which might be more suited. It loads a shapes file (previously saved by the SaveShapes Blitz command), which might be more useful if you're loading lots of individual images for blitting rather than complete bitmaps.

Last edited by Daedalus; 13 January 2021 at 16:56. Reason: Fixed error in code
Daedalus is offline  
Old 12 January 2021, 17:05   #17
Amiga1992
Registered User
 
Join Date: May 2001
Location: ?
Posts: 19,645
Quote:
Originally Posted by Daedalus View Post
Cool beans. Even if not using the editor for the actual code though, the AmigaGuide documentation might be worth having.
I just never liked Amigaguide, it's really cumbersome for me. I'm gonna try the manuals on PDF that have searchable text and see how I get on.

Quote:
but you need to make sure you don't actually execute the IncBin'd data.
And I assure that just by putting it after the "END" bit?

Quote:
might be more useful if you're loading lots of individual images for blitting rather than complete bitmaps.
I am only loading two bitmaps, one is a background image, the other is a brush, which is a spritesheet of elements I am blitting. At some point I'll add a third bitmap which will be my font image. That's all. I don't think I need to save shapes, don't see how it would be any better filesize wise, or speed wise, than what I am already doing.
Amiga1992 is offline  
Old 12 January 2021, 17:13   #18
Daedalus
Registered User
 
Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,346
Quote:
Originally Posted by Akira View Post
And I assure that just by putting it after the "END" bit?
Yep, either that or jumping over it with a Goto. You just don't want the CPU to ever reach that part of the program and try and execute it, or it's an instant crash.

Quote:
I am only loading two bitmaps, one is a background image, the other is a brush, which is a spritesheet of elements I am blitting. At some point I'll add a third bitmap which will be my font image. That's all. I don't think I need to save shapes, don't see how it would be any better filesize wise, or speed wise, than what I am already doing.
Yeah, DecodeILBM is the way to go so.

Last edited by Daedalus; 13 January 2021 at 16:49.
Daedalus is offline  
Old 13 January 2021, 16:22   #19
Amiga1992
Registered User
 
Join Date: May 2001
Location: ?
Posts: 19,645
Quote:
Originally Posted by Daedalus View Post
Yeah, DecodeILBM is the way to go so.
What about the palette then? Fuck me, I can;'t even find LoadPalette in this manual
Is there a way to pinch the palette from the incbin'd file or a bitmap object already in memory?

[edit]
I just tried using DecodeILBM, and I get an error "Can't find IFF 'BMHD'", what does this even mean?

[edit 2]
Fuck me, the way you reference the label is ?label, not &label. That was the error. Thanks idrougge for pointing it out before and thanks me for blatantly ignoring it like a moron

[edit 3]
Sorry for all the edits. Found DecodePalette in the manual, but when I use it, the program takes FOREVER to run/compile. I don't know why this is, but it's weird. For the time being, I am loading the palette externally, I cut a 1x1px brush with the palette I need and that's it.

Last edited by Amiga1992; 13 January 2021 at 16:47.
Amiga1992 is offline  
Old 13 January 2021, 16:52   #20
E-Penguin
Banana
 
E-Penguin's Avatar
 
Join Date: Jul 2016
Location: Darmstadt
Posts: 1,214
If it was easy it wouldn't be nearly as much fun
E-Penguin 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
Gobliins 3 M5 including spanish version Sandro project.TOSEC (amiga only) 13 09 April 2014 17:43
Since 2.4.0 including 2.4.1b7 little display corruption Ridrok support.WinUAE 3 19 April 2012 11:45
Lots of games for sale including some Amiga. Big-Byte MarketPlace 0 29 December 2005 17:38
Amiga Pyromania CLOSEOUT for only $18.95 including shipping. Pyromania MarketPlace 0 28 June 2003 06:38

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 01:02.

Top

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