Quick update…

Just to keep everyone updated, I’ve had to get a bit of home maintenance done recently which has distracted me from series, coupled with Christmas looming I’m having to take some time out.

Episode 5 part 2 is on its way and should arrive this weekend.

Pretty much all of the code is done up to episode #12 and the game we’re going to be building is a nice Scramble clone for the Amiga A500.

Episode #5 (Part 1) – Structures, Bitmaps & the Copper

Unzip these into your projects source folder

https://www.amigagamedev.com/Downloads/Episode5_Source.zip

Download the following packed files to your DH1 hard drive folders

https://www.amigagamedev.com/Downloads/NexMachina2x.rnc

https://www.amigagamedev.com/Downloads/safcemblem.RNC

Slides are here:

https://www.amigagamedev.com/Downloads/AmigaGameDevEp5.pptx

Episode #3 – Loops, Memory & A Simple Sprite Handler

Continuing on with more assembler this episode takes you through some more simple concepts and then takes a look at how a simple sprite handler might work in a shmmmmup!

Power Point Slides for the presentation are here: https://www.amigagamedev.com/Downloads/AmigaGameDevEp3.pptx

;Episode #3 - Example For Loop.

START:  move.w	#0,d0	; Set i do 0
	
.loop:	cmp.w	#31,d0	; is i = 31?
	beq	.done	; yes, take branch
	add.w	#1,d0	; no, add 1 to i
; do something
	bra	.loop	; continue loop

.done:
	nop
	
.exit:  moveq	#0,d0
	rts
	
	

; Episode #3 - Example While Loop.

START:  move.w	#31,d0	; set i to 31
	
.loop:	
; do something
	dbf	d0,.loop
	
.exit:
	moveq	#0,d0
	rts
	
; Episode #3 - Bitshifting Example

START:

	move.w	#1,d0	; Set d0 = 1
	lsl.w	#1,d0	; Shift bits left by 1
	lsr.w	#1,d0	; Shift bits right by 1

	nop
	nop
	
	move.w	#$1234,d0	; Set d0 = $1234
	lsl.b	#$4,d0		; Mutliply byte in d0 by 16 (2^4)
	move.w	#$BEEF,d0	; set d0 = $BEEF
	lsr.w	#4,d0		; Divide word by 4 (2^2) 

	nop
	nop
	
	move.w	#$6789,d0	; Set d0 = $6789
	ror.w	#4,d0		; Rotate nybble right by 1
	rol.w	#8,d0		; Rotate nybble left by 2
	
	
.exit:
	moveq	#0,d0
	rts
	
; Episode #3 - Copying a block of memory

MAX_MESSAGE_SIZE:	equ	100	; Declare constant value

START:
	move.l	#MAX_MESSAGE_SIZE-1,d7	; Load d7 with 99
	lea	SOURCE,a0		; Point a0 register to source block
	lea	DEST,a1			; Point a1 register to destination block
.copy:	move.b	(a0)+,(a1)+		; Copy from dereferenced a0 to a1
	beq.s	.exit			; Exit if the Zero flag was set
	dbf	d7,.copy		; Otherise copy bytes until max reached

.exit:	moveq	#0,d0			; Exit program
	rts

SOURCE:	dc.b	"THIS MEMORY WILL BE COPIED",0
	even

DEST:	ds.b	MAX_MESSAGE_SIZE
	even	
	
	
; Episode #3 - Simple Sprite handler example
; AmigaGameDev Episode #3 - Simple Sprite Handler Example.
MAX_SPRITES:		equ	12
MAX_ENEMIES:		equ	10

SPR_PLAYER:		equ	0		; Player ship
SPR_ORB:		equ	1		; Player Orb Helper
SPR_ENEMY_SMALL_BULLET:	equ	2		; Small enemy bullet
SPR_ENEMY_BIG_BULLET:	equ	3		; Big enemy bullet
SPR_ENEMY_TYPE_1:	equ	4		; 16x16 Enemy 1
SPR_ENEMY_TYPE_2:	equ	5		; 16x32 Enemy 2
SPR_ENEMY_TYPE_3:	equ	6		; 32x48 Enemy 3


START:
; Game start
			move.l	#SPR_PLAYER,d0		; Player spawned
			bsr	ADD_SPRITE
			tst	d0
			bmi	.fail
			move.b	d0,PLAYER_SPRITE	; Save the player sprite handle
	
; Collectable
			move.l	#SPR_ORB,d0		; Player got Orb
			bsr	ADD_SPRITE
			tst	d0
			bmi	.fail	
			move.b	d0,PLAYER_ORB		; Save the orb sprite handle
		
; Enemy appear event		
			move.l	#SPR_ENEMY_TYPE_1,d0	;  Create enemy in the game
			bsr	ADD_SPRITE
			tst	d0
			bmi	.fail
; Add d0 to list of enemies...			

; Player destroyed the enemy...
			bsr	REMOVE_SPRITE		; Remove the sprite.

				
.fail:			nop
			nop
			
.exit:			moveq	#0,d0
			rts


; Add a sprite to the game
;Inputs 
; d0=Sprite type to allocate
;Output
; d0=Allocated sprite handle / -minus if failure
ADD_SPRITE:		
			move.l	#0,d6			; Set index to 0
			move.l	#MAX_SPRITES-1,d7	; Set maximum number of sprites to check
			lea	SPRITES,a0		; Point a0 to Sprite allocations
.loop:			tst.b	(a0)+			; Is the allocation free?
			bmi	.allocate		; Yes it is so use it!
			add.b	#1,d6			; No, add 1 to the index
			dbf	d7,.loop		; Loop if max not reached
			move.l	#-1,d0			; Max was reached so exit with failure
			bra	.exit			; branch to the exit

.allocate:		move.b	d0,-1(a0)		; Found a free allocation do use it
			move.b	d6,d0			; Return the index number in d0
.exit:			rts				; Return from sub-routine.


;--- Remove a sprite from the game.
;Inputs
; d0=Sprite handle to remove
;Outputs
; None
REMOVE_SPRITE:		
			lea	SPRITES,a0
			move.b	#-1,(a0,d0)
			rts


; Data Segment
SPRITES:		
			rept	MAX_SPRITES
			dc.b	-1
			endr
			
PLAYER_SPRITE:		dc.b	0
PLAYER_ORB:		dc.b	0

	

Episode #1 – Tool Chain Install and Configuration

In this episode I’ll be taking you through the steps on how to setup a modern tool chain using Windows, WinUAE, Notepad++ and VASM.

This is a mandatory step if you are going to follow my series.

Click here to download the associated Power Point slides.

The VASM Build file contains the following commands:

C:\Development\ToolChain\vasm.exe -m68020 -kick1hunks -Fhunkexe -o C:\Development\ToolChain\test.exe C:\Development\AmigaGameDev\main.asm

cmd /c copy c:\Development\ToolChain\test.exe C:\Development\Machines\A1200Test\DH1\test.exe

cmd /c copy c:\Development\ToolChain\test.exe C:\Development\Machines\A1200Debug\DH1\test.exe

Download Links

WinUAEDownload Here

Notepad++Download Here

VASMDownload Here

M68K.xmlDownload Here

MonAm.zip – Download Here

ProPack.zip – Download Here