Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
sprites like MJ's Trabajo Basura (not unregr. Fourspriter)
#9
britlion Wrote:I ran into similar problems. I understand the concepts behind it, I just can't work out

a) where the actual assembly is
b) how it's called
c) where it's documented.

I don't speak C, which doesn't help.

You are welcome to adapt whatever of sp1 you would like to. The library works pretty much as nathan mentioned and is the successor to splib2. These are original libraries not based on anything else and are more sophisticated than anything you will find in magazines or the stuff they sold in the day Smile

The source is everything in this directory: <!-- m --><a class="postlink" href="http://z88dk.cvs.sourceforge.net/viewvc/z88dk/z88dk/libsrc/sprites/software/sp1/spectrum/">http://z88dk.cvs.sourceforge.net/viewvc ... /spectrum/</a><!-- m --> and below. You can ignore the collision directory as that was never implemented properly. The code is standalone except for the dynamic memory allocation/deallocation done by sp1_CreateSpr and sp1_DeleteSpr. These two functions call to an external user-supplied function that does memory allocation. Typically, a C program simply uses standard malloc and free to satisfy the requests.

The library can be configured by editing the file 'spectrum-cusomize.asm' (customize.asm is a backup copy of the defaults) before generating the sp1 library. Customization allows configuration of the screen size and the memory map. A reduced screen size means less memory used by the library. The defaults set up a full size 32x24 screen and set the memory map detailed at the end of that file.

The C header file 'spectrum-sp1.h' lists all the sp1 functions and data structure definitions. I am not sure if Boriel's basic has the equivalent of a struct or pointer to a struct? but something like that is necessary.

* The section 'DATA STRUCTURES' lists all the struct definitions used by the library. The sub-section under 'SPRITES' containing all that SP1_DRAW_* stuff exposes the sprite draw primitives as function pointer addresses so that the draw primitives can be specified while creating sprites (see sprites/draw). That way you can choose between MASK, OR, XOR sprites, etc. The programmer doesn't do anything with them except pass them as values (memory addresses) to the creation functions.

* Lines 209 to 225 are the sprite related functions

* Lines 230 to 232 are sprite character functions -- these are character squares not attached to sprites than can be placed on the display to act like middle-ground elements (background elements that can be in front of some sprites as they have a z value associated with them).

* Lines 314 to 329 deal with background tiles (ie background character squares). Basically you PRINT AT characters to the background.

* Lines 370 to 389 are functions that deal with updating the screen.

The associated asm code is in the subdirectories; all implementations will be in *callee.asm files except for fastcall functions which will have no callee suffix. All callee files will also have a non-callee version that only jumps into the callee file. These are only there to be used by function pointers and can be ignored.


So the idea is the user configures the library by editing 'spectrum-cusomize.asm' and then creates the library by assembling it. This generates a standalone sp1.lib library and sp1.h header. The C program includes the header file so the compiler knows how to call the functions and the user adds '-lsp1' to the compile line so the linker looks for functions in sp1.lib.

One thing you do not want to do is have all the sp1 code always included in a project. This will reduce the amount of memory to the program. For example, a program that only uses MASK sprites does not need to include all the code for OR, XOR, LOAD, etc sprites in the project. z88dk has a linker that only pulls in functions that are actually called so this is how it's done in z88dk. I don't know if Boriel's compiler has a linker feature.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)