View Single Post
Old 17 October 2019, 23:07   #1
mcgeezer
Registered User

 
Join Date: Oct 2017
Location: Sunderland, England
Posts: 1,508
Game Programming Framework

So after a fair bit of thought on what to do next, I've long set my heart on doing some Game programming tutorial streams for the Amiga.

With that said, looking back I made many many mistakes when coding Rygar... things that were just bad habits or because I was under a time constraint to finish the game for the competition.

So what I'd like to do is come up with a set of assembler functions that facilitate making game coding easier, while the implementation will be assembler I'll try and comform to high level languages like C (although I've never written any C before).

So here goes... I've documented (but not written) a couple of functions to set the tone, the idea being writing the actual function will be the assembler tutorial and the hope is that a picture of how to build a game will slowly come across to following...with better games being made for the Amiga.

Here are the off the cuff high level functions (just a brain dump)...I have more to add.

Code:
[+] rawHandle = amgLoadAndUnpackRncAsset(*name, bufsize, memtype)
[+] assetHandle = amgParseAsset(rawHandle)

[+] cameraHandle = amgCreateScreenBuffer(XSize, YSize, BitPlanes)
        Allocate screen memory, Creates Bitplane Handles
	
[+] copperHandle = amgCreateInitalCopperList(cameraHandle,paletteHandle)
        Build a default copper list from a camera handle.
	
[+] spriteSheetHandle = amgGenerateSpriteSheet(assetHandle, *Buffer, SpriteCutSize, MaxCuts, bool Mask)
        Build a list of pointers to the sprites and their masks	
	
[+] spriteHandle = amgCreateSprite(spriteSheetHandle)
[+] result = amgSetSpriteHandler(spriteHandle, *Address, State)
[+] result = amgSetPlayerSprite(spriteHandle *Address)
[+] result = amgDestroySprite(spriteHandle)	

[+] spriteAnimHandle = amgCreateSpriteAnimation(spriteHandle, spriteAnimationType)
[+] result = amgAppendSpriteAnimationFrame(spriteAnimHandle,*Handler, Frame, Speed)
[+] result = amgSetSpriteAnimation(spriteAnimHandle, bool [loop|term])

[+] SpriteNumber = amgCastSprite(spriteHandle,initXpos,initYpos,State)
[+] result = amgSetSpriteStatus(spriteHandle, bool State)
[+] result = amgSetSpriteAnimationSpeed(spriteAnimHandle)

[+] tileHandle = amgSetTileSheetAttributes = (assetHandle, sizeX, size Y)
[+] result = amgSetTilePlatform(tileId,tileHandle,spriteHandle,maskId)
[+] result = amgSetTileObstacle(tileId,tileHandle,spriteHandle,maskId)
[+] result = amgSetTileCeiling(tileId,tileHandle,spriteHandle,maskId)

[+] mapHandle  = amgCreateTileMap(rawHandle,xSize,ySize,size)

[+] canvasHandle = amgCreateCanvas(mapHandle, tileHandle)
[+] result = amgSetCanvasLimits(canvasHandle,x1,y1,x2,y2)
[+] result = amgSetCanvasPlayerLimits(canvasHandle,spriteHandle,x1,y1,x2,y2)

[+] amgBlitTileToCamera(canvasHandle,cameraHandle, sourceTile, destTile)
[+] copperList = amgDrawCurrentCameraPosition(canvasHandle,cameraHandle)

[+] copperListHandle = amgSetCanvasMode(canvasHandle,mode)
                        Mode can be:
                                0 = Static
                                1 = Horizontal Bi-Directional
                                2 = Horizontal Right
                                3 = Horizontal Left
                                4 = Vertical Bi-Directional
                                5 = Vertical Down
                                6 = Vertical Up
                                7 = 8 Way
                                10 = Dual Playfield Static
                                11 = Dual Playfield Horizontal Bi-Directional
                                12 = Dual Playfield Horizontal Right
                                13 = Dual Playfield Horizontal Left
                                14 = Dual Playfield Vertical Bi-Directional
                                15 = Dual Playfield Vertical Down
                                16 = Dual Playfield Vertical Up
                                17 = Dual Playfield 8 Way
				

[+] amgSetCanvasCameraPosition(canvasHandle,cameraHandle,x1,y1,x2,y2)                              ; Can use this to scroll around

And here's the first two functions documented:

Code:
NAME
        amgLoadAndUnpackRncAsset - Load and unpack file


SYNOPSIS
        rawHandle = amgLoadAndUnpackRncAsset(*name, bufsize, memtype)
        d0                                  a0     d0       d1


FUNCTION
        The file 'name' should be a ProPacked file using method 1 or 2.
        Memory of the required type and bufsize in bytes is allocated using AmigaDos
        malloc(), If the supplied bufsize is 0 then the packed file header is read to find
        the number of first before loading and unpacking the file.
        The memtype argument can either by MEMF_CHIP to allocate chip ram, MEMF_FAST to
        allocate Fast Ram or MEMF_ANY to allocate any available ram type, however should
        fast ram be available as well as chip then fast will be used as a priority.


INPUTS
        name - (a0) pointer to null-terminated file name of asset to load.

        bufsize - (d0) buffer size in bytes to allocate

        memtype - (d1) MEMF_CHIP | MEMF_FAST | MEMF_ANY


RESULTS
        rawHandle - (d0) handle code for the loaded asset


ERRORS
        error - (d0) failure to load and unpack the asset will result in any of the following
                                  errors.

                        -1 - File not found
                        -2 - Unable to allocate ram type
                        -3 - Unpack failed
                        -4 - Max handles reached

Code:
NAME
        amgParseAsset - Parse and store the information found in a loaded asset


SYNOPSIS
        assetHandle = amgParseAsset(rawHandle)
        d0                           d0


FUNCTION
        The handle supplied should be the result from calling the 'amgLoadAndUnpackRncAsset'
        function.  The supported assets are Protracker Music Modules, 8SVX Sound samples and
        uncompressed Amiga ILBM image files.  Upon successful execution of the function
        a new handle is returned with the requested information parsed based on the found
        asset type.  See the AMG handles structure for more information.


INPUTS
        handle (d0) - A handle number that has previously been returned from
                                  'amgLoadAndUnpackRncAsset'.


RESULTS
        assetHandle (d0) - Asset handle number.

ERRORS
        error - (d0) failure to parse information found with the associated handle.

                        -1 - Supplied handle not found
                        -2 - No supported Interchangable File Format header could be found (FORM)
                        -3 - Failed to locate Bitmap Header (BMHD)
                        -4 - Failed to locate Body Header (BODY)
                        -5 - Failed to locate Colour Map header (CMAP)
                        -6 - Asset is compressed
                        -7 - Failed to locate Sample header (8SVX)
                        -8 - Failed to locate Module header (MOD)

SEE ALSO
And here's the handle structures...

Code:
Struct handles
        STATUS                  X       byte    (-1 - invlaid, 0 - valid)                                      * AmgLoadAndUnpackRncAsset()
        ADDRESS                 X       long    Pointer in ram to asset                                        * amgLoadAndUnpackRncAsset()
        TYPE                    X       byte    (-1 - undefined, 					       * amgParseAsset()
						  0 - IFF Image, 
						  1 - Music Module, 
						  2 - Sound Sample )    
        IMGIFFSIZE              X       word    Size in bytes of entire                                        * amgParseAsset()
        IMGBODYSIZE             X       long    Size in bytes of body                                          * amgParseAsset()
        IMGCMAPSIZE             X       long    Size in bytes of colour map                                    * amgParseAsset()
        IMGBODYPTR              X       long    Pointer to body data origin                                    * amgParseAsset()
        IMGCMAPPTR              X       long    Pointer to cmap data origin                                    * amgParseAsset()
        IMGCMAPTYPE             X       byte    Type of colour map 0=12bit/1=24bit                             * amgParseAsset()
        IMGWIDTH                X       word    Size in pixels of image width                                  * amgParseAsset()
        IMGDEPTH                X       word    Size in pixels of image depth                                  * amgParseAsset()
        IMGPLANESIZE    	X       byte    Number of bitplanes in the image                               * amgParseAsset()
        IMGBYTEWIDTH    	X       byte    Number of bytes in width of the image                          * amgParseAsset()
        IMGMODULO               X       byte    Image modulo                                                   * amgParseAsset()
        8SXIFFSIZE              X       word    Size in bytes of entire asset                                  * amgParseAsset()
        8SXBODYSIZE             X       long    Size in bytes of body data                                     * amgParseAsset()
        8SXPERIOD               X       word    Sample period                                                  * amgSetAssetData()


result = amgSetAssetData(handle, offset, data)
d0                         d0     d1     d2

result = amgGetAssetData(handle, offset)
d0                         d0     d1

Index to handle data
*ptr = amgIndexToHandle(handle)
  a0

So the hope is that I can build on this. As I have a strong Unix/Shell/Python background I tend to operate everything on file handles and OOP so I'm hoping to take those principles into this.

This project might not go very far... but then again, it might really be useful.
It's certainly something I can take at a much slower pace than coding something like Rygar.

Ideas and comments as usual are really welcome.

Geezer
mcgeezer is offline  
 
Page generated in 0.04276 seconds with 11 queries