Post by Riko on Oct 11, 2023 17:09:51 GMT
Useful Neo Geo Technical and Programming Information
I thought I would make this thread for people to share technical and programming information that they think would be useful to other Neo Geo programmers.
---------------------------------------------------------------------------------------------------------------------
I just added a couple of simple new commands to my Neo Geo Dev Kit. For me these are really useful to have so I hope they will be for other people (I know there are a few other people who use the Dev Kit here). Both commands were based on the erase_sprites function. Not everyone will need these functions so only add them if you think you will use them.
For both these new commands : nb = number of sprites and ht = sprite height
sprite_on(int nb,int ht);
Starting from the "current_sprite" : turns on the specified number of sprites (nb) and sets the specified height (0-33) for each sprite
sprite_off(int nb);
Turn off the specified number of sprites (nb), starting from the "current_sprite". Retains all sprite information in VRAM apart from the sprite height (which must be set to zero to turn the sprite off)
These two commands allow you to turn sprites on and off while KEEPING all the sprite information (apart from the sprite height) in VRAM. Currently with the dev kit you can only switch a sprite off and on by erasing it and then rewriting all the data again. Or alternatively - by moving it off screen and on again. These new functions mean you don't have to store positional information for these sprites (this was the useful part for me). They are also much faster than the current devkit options.
You could also use these functions to make a sprite transparent by turning a sprite on and off on alternate frames (at 60fps) To the human eye the sprite will look transparent (not flickery!).
Remember not to re-use any sprites you intend to "switch on" again later or their original data will be lost
How to add the commands to your dev-kit :
1. Please make a backup copy of your video.h and video.s files (just in case you make a mistake while editing them)
2. Copy & Paste the following code after the "erase_sprites" function in the video.s file
3. At the top of the video.s file :
AFTER
ADD :
4. In the video.h file :
AFTER
ADD :
5. Run the build-libs make file to rebuild the libraries and read the text display to check no errors come up
6. You can now use the functions in your own programs (make sure to set the current_sprite first!)
I thought I would make this thread for people to share technical and programming information that they think would be useful to other Neo Geo programmers.
---------------------------------------------------------------------------------------------------------------------
I just added a couple of simple new commands to my Neo Geo Dev Kit. For me these are really useful to have so I hope they will be for other people (I know there are a few other people who use the Dev Kit here). Both commands were based on the erase_sprites function. Not everyone will need these functions so only add them if you think you will use them.
For both these new commands : nb = number of sprites and ht = sprite height
sprite_on(int nb,int ht);
Starting from the "current_sprite" : turns on the specified number of sprites (nb) and sets the specified height (0-33) for each sprite
sprite_off(int nb);
Turn off the specified number of sprites (nb), starting from the "current_sprite". Retains all sprite information in VRAM apart from the sprite height (which must be set to zero to turn the sprite off)
These two commands allow you to turn sprites on and off while KEEPING all the sprite information (apart from the sprite height) in VRAM. Currently with the dev kit you can only switch a sprite off and on by erasing it and then rewriting all the data again. Or alternatively - by moving it off screen and on again. These new functions mean you don't have to store positional information for these sprites (this was the useful part for me). They are also much faster than the current devkit options.
You could also use these functions to make a sprite transparent by turning a sprite on and off on alternate frames (at 60fps) To the human eye the sprite will look transparent (not flickery!).
Remember not to re-use any sprites you intend to "switch on" again later or their original data will be lost
How to add the commands to your dev-kit :
1. Please make a backup copy of your video.h and video.s files (just in case you make a mistake while editing them)
2. Copy & Paste the following code after the "erase_sprites" function in the video.s file
.align 4
*** void sprite_off(int nb)
** nb = number of sprites
sprite_off:
.set _ARGS, 4
lea 0x3C0002,a1
* setup mod
move.w #1,2(a1)
* setup vid_ptr
move.w _current_sprite,d0
add.w #0x8200,d0
move.w d0,-2(a1)
move.l _ARGS(a7),d0
0:
*set height of sprite to zero (bits 0-5 set to zero)
and.w #0xFFC0,(a1)
subq.l #1,d0
jne 0b
rts
.align 4
*** void sprite_on(int nb,int ht)
** nb = number of sprite, ht = height (0-33)
sprite_on:
.set _ARGS, 4
lea 0x3C0002,a1
* setup mod
move.w #1,2(a1)
* setup vid_ptr
move.w _current_sprite,d0
add.w #0x8200,d0
move.w d0,-2(a1)
move.l _ARGS(a7),d0
move.l _ARGS+4(a7),d1
0:
*or in sprite height while keeping rest of register
or.w d1,(a1)
subq.l #1,d0
jne 0b
rts
3. At the top of the video.s file :
AFTER
.globl erase_sprites
ADD :
.globl sprite_off
.globl sprite_on
4. In the video.h file :
AFTER
extern void erase_sprites(int nb);
ADD :
extern void sprite_off(int nb);
extern void sprite_on(int nb,int ht);
5. Run the build-libs make file to rebuild the libraries and read the text display to check no errors come up
6. You can now use the functions in your own programs (make sure to set the current_sprite first!)