Not as a function, (there is no need for an 'output' afterall) but the attached example has a specific procedure for the job.
You can then fold the procedure away an never worry about it again one it is doing what you need.
The example rips 4 sets of graphics, each stored in a 3x3 grid of 16x16 pixels each, and allows for one pixel 'gap' between each one, which i always think ie easier for using with Dpaint etc.
I see your code and can I say I love it! I also realized 16 X 16 is the best sprite size when it comes to blitting for the Amiga computer and 32 X 32 for the big boss sized monsters.
I have some questions to ask for learning process in your code
I understand from the procedure _GETCHAR it is a function that actually loads the sprite from the sprite sheet. In the comment you said
' uncomment this to stop the screen from appearing at all
' Screen Hide 2
Here is the question. Say that I cannot put all the sprites in one sprite sheet, say there are lot for some reason and i need to have three to four spritesheets. Does that mean I need to have one screen specific that stores all these spritesheets and I must hide them to avoid seeing the spritesheets before say for example loading a title of the game?
In your comment you said: ' this variable counts how many sprites have being ripped (image number)
COUNT=1
My question, is this counts how many sprites show at one time and thus always and must always be 1.
So for example:
Array 0: Sprite A, Array 1: Sprite B, Array 2:Sprite C, Array 3:Sprite D
and I say Count=1..it loops first from Array 0, then Array 1 as it increments by 1 but if I said Count=2
it loops to Array 1, then array 3 instead of 0 and 2? Is that what you mean by Count=1?
In the procedure _GETCHAR right after determining width and height equals 16 why did you say Ink 14?
Under Wait Vbl does it wait for 50 Hz or it does not matter either 50 or 60 depending on your Amiga NTSC/PAL setting? Like for example R-Type is PAL and if you attempt to run it on NTSC Amiga it freezes with black screen. However, is it because they just entered Wait Vbl or there is more to it with R-Type? The reason I am asking this because I want to get the smoothest frame rate possible, regardless of amount of sprite or tiles and if it means banging right into the vertical line of the screen to produce smoothness and the program relies heavily on timing then I would want to do it but I do not know if Wait Vbl is all I need for that or there assembly or more code needed for that?
Now there is something here that confuses me completely you said in this comment:
' my whole routine is repeated 4 times (variable (), with different X offset
' this allows for 4 cars to be ripped
For C=0 to 3
Question: I do not understand these two lines here. Why? What does it do? Can you explain this to me? How do I know when to do offsetx, offsety or not? Why did you say C*51 and not C*24 or C+51?
_OFFSETX=1+(C*51)
_OFFSETY=1
What do you mean by blockwidth and blockheight and why you specify 3? Why not 4? Why not 5? Why not 0?
BLOCKWIDTH=3
BLOCKHEIGHT=3
Why do you have a loop inside another loop? Why do you have a for loop for B and A and why you are using BLOCKWIDTH, BLOCKHEIGHT and why -1 after that?
For B=0 to BLOCKHEIGHT-1
For A=0 to BLOCKWIDTH-1
From here to
INX=OFFSETX+(A*WIDTH)+A
INY=OFFSETY+(B*WIDTH)+B
OUTX=INX+WIDTH
OUTY=INY+HEIGHT
here I am soooooo confused. I have no idea what you are doing here and why you are doing it? Can you please explain the above code for me?
Get Bob COUNT, INX, INY to OUTX, OUTY
' I thought this above code is to be used on the main program? Why are we getting bob in the procedure if we are not plotting bob now? Yo have placed the get bob inside the loop with the inx, iny, and the count variable. Does that mean you are storing the actual sprite from the spritesheet in an "ARRAY" of Bobs from Count and in the main program we can then display that sprite by simply just changing the number of Count from say 1 to 4 or 5, etc and plot the X,Y coordinate of that bob?
How does that work?
I realized after the Next A, Next B loop you said Count=Count-1. Why?
After that you have another loop which says inverse,. Why do you need an inverse loop? Why did you add Bar, paste and get bob right after the original get bob? What is the purpose of the inverse loop you have made?
Again you said count=count-1 after the inverse loop. Why?
After leaving the Next C you have made another tiny loop that says
For A=1 to Count-1
Hot Spot A, $11
Next A
WHY? What is that? What is the purpose of that? Why did you say Screen Close 2?
Thanks that is all I need to know right now.
Thanks for your patience with me.