;==========================================================================================
;
;   UNOFFICIAL SNES POWERPAK FIRMWARE V2.01 (CODENAME: "SIMBA")
;   (c) 2012/2013 by ManuLöwe (http://www.manuloewe.de/)
;
;	*** FUNCTIONS: WRITE LASTSNES.TXT ***
;	Code in this file based on v1.0X code written by:
;	- bunnyboy (SNES PowerPak creator), (c) 2009
;
;==========================================================================================



; *************************** Save last game ***************************

SaveLastGame:
	FindFile "LASTSNES.TXT"

	ldx #$0000
	ldy #$0000

SaveLastGameLoop:				; game name and cluster
	lda gameName, x
	sta sectorBuffer1, y
	iny
	inx
	cpx #$0080				; 128 bytes
	bne SaveLastGameLoop

	ldx #$0000

SaveLastSaveLoop:				; save name and cluster
	lda saveName, x
	sta sectorBuffer1, y
	iny
	inx
	cpx #$0080				; 128 bytes
	bne SaveLastSaveLoop

	ldx #$0000

SaveLastGameGenieLoop:				; GameGenie chars 5x8 = 40
	lda gameGenie, x
	sta sectorBuffer1, y
	iny
	inx
	cpx #$0028
	bne SaveLastGameGenieLoop

	lda #<sectorBuffer1
	sta sourceLo
	lda #>sectorBuffer1
	sta sourceHi

	lda #kSourceWRAM
	sta sourceType

	jump jCardWriteFile
rts

; **********************************************************************
