English Amiga Board


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

 
 
Thread Tools
Old 07 September 2018, 15:59   #1
neumanix
Registered User
 
Join Date: Jan 2017
Location: Jakobstad/Finland
Posts: 13
INCBIN weirdness

I'd like to include an image, a shape, or module into the executable, just as a challange to see what I can make, for example in just 64k.


I have both BB2.1 and Amiblitz2 and haven't been able to get this to work
properly in either.


This little example sort of works, but if I run it with the debugger on, it always gives a GURU warning at exit. It might run a few times, but then it always crashes.


Code:
BLITZ
Bitmap 0,320,256,2
DecodeILBM 0,?img
Slice 0,44,2
Show 0
Mousewait

img:
IncBin "image.iff"
In AmiBlitz2 I tried adding the Chip command before the img: label to make sure it goes into chipmem, but same result.


There must be a solution to this right?
neumanix is offline  
Old 07 September 2018, 17:11   #2
Daedalus
Registered User
 
Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,334
I think you need to have an End statement before the img: label, otherwise when you click the mouse at the end of the program, the code runs on and tries to execute your image data... Which will not end well.
Daedalus is offline  
Old 07 September 2018, 17:38   #3
neumanix
Registered User
 
Join Date: Jan 2017
Location: Jakobstad/Finland
Posts: 13
Of course. I didn't think of that. I omitted the End command, just so I could see the
debugger message at exit. I was hoping to see a "End of program" message, but with the End command the debugger just closes if there is no error it seems.
neumanix is offline  
Old 08 September 2018, 13:33   #4
idrougge
Registered User
 
Join Date: Sep 2007
Location: Stockholm
Posts: 4,332
Use "Stop" if you want to break into the debugger.
idrougge is offline  
Old 08 September 2018, 14:14   #5
Daedalus
Registered User
 
Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,334
AmiBlitz3 gives you a "Program finished" message in the console, but Blitz just quits back to the IDE. A simple fix:

Code:
NPrint "Program finished. Press Enter."
x$ = Edit$(1)
End
The reason the debugger gives you an End Program message is that you shouldn't just let the program run out like that. The End statement does some things like freeing resources, closing files etc. For a simple program it won't make much difference, but if you run the program many times you might find your free RAM slowly disappearing.
Daedalus is offline  
Old 08 September 2018, 16:03   #6
idrougge
Registered User
 
Join Date: Sep 2007
Location: Stockholm
Posts: 4,332
By the way, is there no way to force Incbin to include files into chip RAM? If your picture or sound data ends up in fast RAM, you're wasting memory en masse.
idrougge is offline  
Old 09 September 2018, 13:23   #7
Daedalus
Registered User
 
Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,334
No, there's no way - IncBin files are packed as part of the executable object and so are loaded into fast RAM along with the program itself (if Fast RAM exists). The Decode#? commands then extract this data to chip RAM. So yeah, I guess it is a waste of RAM...
Daedalus is offline  
Old 09 September 2018, 18:35   #8
carrion
Registered User
 
carrion's Avatar
 
Join Date: Dec 2016
Location: Warsaw area
Posts: 152
Yeah That's actually a big bummer. I stepped at this problem when coding my "Alien Apparat" demo. Too bad Blitz doesn't have SECTIONS

There's also one more problem I encountered while coding the demo. Sometimes DecodePalette command didn't work and hanged the code causing Guru. Till this time I don't know what was the problem. Other Decode commands worked fine but DecodePalette didn't. One of my clues was that maybe the gfx tool I used (Grafx2) didn't save IFF files the right way, but it wasn't the case, as I reproduced the problem with files saved by PPaint... If you guys had the same problems with DecodePalette or other Decode commands pls lat us know here.
carrion is offline  
Old 09 September 2018, 21:47   #9
Daedalus
Registered User
 
Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,334
I think Blitz's loading and saving of IFF palettes in general is a little buggy - I ran into some bugs when I was writing a palette manipulation program and ended up just implementing my own load/save routines.
Daedalus is offline  
Old 10 September 2018, 20:30   #10
neumanix
Registered User
 
Join Date: Jan 2017
Location: Jakobstad/Finland
Posts: 13
Thanks for your tips on the debugger. I got INCBIN to work with protracker modules (PT Player) by checking if fastmem is installed and copying the module data to a bank in chipmem. I skip the copying if no fastmem is found.
neumanix is offline  
Old 13 September 2018, 16:10   #11
bjadams
Registered User
 
Join Date: Sep 2018
Location: Chesterfield
Posts: 44
The command DecodeModule doesn't seem to exist.
How can you play a MOD that has been INCBINed?
bjadams is offline  
Old 13 September 2018, 16:26   #12
Daedalus
Registered User
 
Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,334
Perhaps it's the DecodeMedModule? Interestingly, it seems it doesn't actually do any decoding:

Quote:
DecodeMedModule replaces the cludgemedmodule, as med modules are not packed but used
raw, DecodeMedModule simply checks to see the memory location passed is in ChipMem
(if not it copies the data to chip) and points the Blitz MedModule object to that
memory.
Daedalus is offline  
Old 13 September 2018, 21:49   #13
bjadams
Registered User
 
Join Date: Sep 2018
Location: Chesterfield
Posts: 44
What about non-MED modules?
As Blitz supports 2 types of modules: standard tracker mods and MED mods
bjadams is offline  
Old 13 September 2018, 22:11   #14
Daedalus
Registered User
 
Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,334
There doesn't seem to be an equivalent for MODs unfortunately.
Daedalus is offline  
Old 13 September 2018, 23:55   #15
bjadams
Registered User
 
Join Date: Sep 2018
Location: Chesterfield
Posts: 44
I found out the XBONES CIA Lib on the Blitz Extras CD
DecodeModule is actually a CIA lib command!
However once I started to use this, my prog now crashes completely at END
If I don't use the StartTracker command all works fine

If i switch DEBUGGER ON, all works fine!!!

Any ideas?

Last edited by bjadams; 14 September 2018 at 11:22.
bjadams is offline  
Old 14 September 2018, 20:28   #16
neumanix
Registered User
 
Join Date: Jan 2017
Location: Jakobstad/Finland
Posts: 13
I used the ptplayer which is a protracker player routine that idrougge converted, get it here:
http://eab.abime.net/showthread.php?...light=ptplayer
You incbin the mod, but you need to check if fastmem is available, if it is then
the module will most likely end up there.
So you make a bank in chipmem, the size of the module, and copy the data from
fastmem to chipmem.

Code:
fastmem.b=AvailMem_(4) ; 4=fast, 2=chip
if fastmem ; is fastmem available? if so, better copy the module to chipmem
  music_length.l=?musicE-?music
  InitBank 0,music_length,2
  For n.l=0 To music_length-1 Step 4
    Poke.l Bank(0)+n, Peek.l(?music+n)
  Next
  MTInit 0,0
Else ; if no fastmem is detected, the module must be in chipmem
  MTInit ?music,0,0
EndIf

MTPlay On

Mousewait

MTEnd

If fastmem
  Freebank 0 ; free up the bank we allocated
endif
End

music:
IncBin "yourmodule.mod"
musicE:

Last edited by neumanix; 14 September 2018 at 20:43.
neumanix is offline  
Old 15 September 2018, 20:40   #17
bjadams
Registered User
 
Join Date: Sep 2018
Location: Chesterfield
Posts: 44
@neumanix

Thanks a lot, looks very straightforward.
Worked great for me!

Last edited by bjadams; 16 September 2018 at 19:38.
bjadams 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
Mouse weirdness esc support.WinUAE 4 18 October 2016 07:49
DOpus startup weirdness cmsj support.Apps 2 17 February 2016 13:04
blitz incbin.. yoki Coders. General 5 03 April 2009 12:29

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 04:50.

Top

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