Lesson P25 - Hardware Sprites on the NeoGeo

ASM Development for the NeoGeo
Post Reply
User avatar
akuyou
Posts: 563
Joined: Mon Apr 22, 2019 3:19 am
Contact:

Lesson P25 - Hardware Sprites on the NeoGeo

Post by akuyou » Tue Oct 22, 2019 8:52 pm

The Neogeo has no tile layer, instead it does EVERYTHING with sprites... Because of not having tiles, the NeoGeo is capable of a massive 380 16x16 Sprites! Although each sprite pattern is 16x16, they can contain up to 32 vertical tiles, and multiple sprites can be 'Chained' to make them wider... they can also be scaled down to make them smaller... Lets learn how!



https://www.chibiakumas.com/68000/platf ... #LessonP25
Chibi Akuma(s) Comedy-Horror 8-bit Bullet Hell shooter! // 「チビ悪魔」可笑しいゴシックSTG ! // Work in Progress: ChibiAliens

Interested in CPU's :Z80,6502,68000,6809,ARM,8086,RISC-V
Learning: 65816,ARM,8086,6809

puppydrum64
Posts: 34
Joined: Thu Apr 22, 2021 9:30 pm

Re: Lesson P25 - Hardware Sprites on the NeoGeo

Post by puppydrum64 » Fri Jun 04, 2021 11:19 pm

I added just one line of code to your SetSprite routine to enable animations.

Code: Select all

SetSprite:
	movem.l d0-d7,-(sp)
	;d0 = hdwr sprite number
	;d1 = x pos
	;d2 = y pos
	;d3 = pattern number
	;d4 = palette.
	;d5 = animation type (#$00 = no anim, #$08 or #$0C = 8 frames, #$04 = 4 frames. All animation frames must be next to each other in .c1/.c2 files.)
	
		KickWatchdog
		move.l d0,d7				;store sprite number in d7
		add.l #$8000,d7				;add #$8000 to get sprite setting offset
		
		;Handle Shrink Factor
		
		move.w d7,REG_VRAMADDR		;$3C0000, equivalent of $2006 on NES
		move.w #$0FFF,REG_VRAMRW	;$3C0002, equivalent of $2007 on NES.		;#$0FFF = HHHH VVVV VVVV (FULL SIZE)
		
		;Handle Y Pos
		add.l #$200,d7				;Y POS AT $8200+sprite number
		move.w d7,REG_VRAMADDR		;WHERE to write graphics data
		
		rol.l #7,d2
		or.l #$0001,d2
		
		move.w d2,REG_VRAMRW		;WHAT data to write
		
		;Handle X Pos
		add.l #$200,d7				;X POS AT $8400+sprite number
		move.w d7,REG_VRAMADDR		;WHERE to write graphics data
		
		rol.l #7,d1
		move.w d1,REG_VRAMRW		;WHAT data to write
		
		move.l d0,d7
		rol.l #6,d7					;multiply by 64 to get sprite number.
		move.w d7,REG_VRAMADDR
		move.w d3,REG_VRAMRW		;NNNNNNNN NNNNNNNN tile
									;tiles start at $2000, set by MAME XML
		
		addq.l #1,d7
		move.w d7,REG_VRAMADDR		;Tile palette at $0001+SpriteNo.*64
		
		rol.l #8,d4					;Roll palette into top byte.
		;;;;;;;;;;;;;;;;;;;;;;;ADD THIS TO ENABLE ANIMATIONS
		or.w d5,d4					;Animate sprite (animation frames must be next to each other)
		;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
		move.w d4,REG_VRAMRW
		
	movem.l (sp)+,d0-d7
	RTS
These are the values you can set D5 to before calling this sub.
#$00 = No animation.
#$04 = Auto-animate 4 frames. Frame 00 is the sprite you are setting. Frame 01 is the sprite after that, Frame 02 is the sprite after that, and so on. In other words if you want an animation to work this way you need all sprites next to each other.
#$08 or #$0C = Auto-animate 8 frames.

One issue I'm having is that AkuSprite Editor crashes if I try to load a NEOGEO sprite file ".c1" or ".c2" extension. I think it's because both files are needed to get the full picture. I tried loading both simultaneously but the program wouldn't let me. I can create that file type just fine but editing one won't work. And since the crosshairs sprites in "Sprites.c1" and "Sprites.c2" aren't all next to each other this method of animation doesn't work too well. :(

User avatar
akuyou
Posts: 563
Joined: Mon Apr 22, 2019 3:19 am
Contact:

Re: Lesson P25 - Hardware Sprites on the NeoGeo

Post by akuyou » Tue Jun 15, 2021 12:14 pm

Yes, NeoGeo Animation is pretty easy!... I didn't cover it in the tutorial, as I'd put too much time into writing that one already, it's on my 'ToDo' list to go back to it at some point and cover animation.

Re AkuSprite Editor, I take it you're using the menu option
68000->NeoGeo->LoadSprite

The option was designed to work with pairs of sprite files, but I only tested it on a few files from Metal slug roms and the like, so it's very possible it has bugs.

If you can get the sprite files you're trying to load to me some how I can take a look and see if there's a bug.
Chibi Akuma(s) Comedy-Horror 8-bit Bullet Hell shooter! // 「チビ悪魔」可笑しいゴシックSTG ! // Work in Progress: ChibiAliens

Interested in CPU's :Z80,6502,68000,6809,ARM,8086,RISC-V
Learning: 65816,ARM,8086,6809

User avatar
akuyou
Posts: 563
Joined: Mon Apr 22, 2019 3:19 am
Contact:

Re: Lesson P25 - Hardware Sprites on the NeoGeo

Post by akuyou » Tue Jun 15, 2021 12:39 pm

Bah! Ignore me, It can't even load my own file!

There were a couple of bugs in it, I've fixed them now, please download the sources again, the fixed version is in there.

Note:
Please check the NeoGeo Section of the FileFormat tab for advanced options relating to sprite loading if things don't import to your liking.

As a bonus (!) I've added an extra importer, to import NeoGeo CD sprites - which are not split into two files, but are otherwise in the same format.

https://www.chibiakumas.com/68000/sources.7z
Chibi Akuma(s) Comedy-Horror 8-bit Bullet Hell shooter! // 「チビ悪魔」可笑しいゴシックSTG ! // Work in Progress: ChibiAliens

Interested in CPU's :Z80,6502,68000,6809,ARM,8086,RISC-V
Learning: 65816,ARM,8086,6809

puppydrum64
Posts: 34
Joined: Thu Apr 22, 2021 9:30 pm

Re: Lesson P25 - Hardware Sprites on the NeoGeo

Post by puppydrum64 » Sun Aug 22, 2021 5:28 pm

Awesome, thanks! I had been using another tool called Neo-Geo Graphics Tool Suite (NGGTS, or "Nuggets" as I affectionately call it) that was holding me over in the meantime.

Post Reply

Return to “NeoGeo Assembly Programming”