;
; File generated by cc65 v 2.13.1
;
	.fopt		compiler,"cc65 v 2.13.1"
	.setcpu		"6502"
	.smart		on
	.autoimport	on
	.case		on
	.debuginfo	on
	.importzp	sp, sreg, regsave, regbank, tmp1, ptr1, ptr2
	.macpack	longbranch
	.dbg		file, "../../../io/src/diskio.c", 4929, 1267200496
	.dbg		file, "../inc/manifest.h", 151, 1267200480
	.dbg		file, "C:\Programme\cc65\include/stdio.h", 5964, 1262467470
	.dbg		file, "C:\Programme\cc65\include/stddef.h", 2972, 1262467470
	.dbg		file, "C:\Programme\cc65\include/stdarg.h", 2817, 1262467470
	.dbg		file, "../../../io/inc/diskio.h", 2164, 1267200496
	.dbg		file, "../../../data/inc/types.h", 1544, 1267200498
	.dbg		file, "../../../io/inc/sd.h", 1808, 1267200496
	.dbg		file, "../../../io/inc/spi.h", 1305, 1267200496
	.import		_printf
	.export		_disk_initialize
	.export		_disk_shutdown
	.export		_disk_status
	.export		_disk_read
	.export		_disk_write
	.export		_disk_ioctl
	.export		_disk_timerproc
	.export		_get_fattime
	.import		_sd_Init
	.import		_sd_readSector
	.import		_sd_writeSector
	.import		_spi_Init

.segment	"RODATA"

L0001:
	.byte	$44,$69,$73,$6B,$20,$72,$65,$61,$64,$20,$65,$72,$72,$6F,$72,$2E
	.byte	$0A,$00,$56,$65,$72,$69,$66,$79,$20,$45,$52,$52,$4F,$52,$2E,$0A
	.byte	$00

.segment	"BSS"

_status:
	.res	1,$00

; ---------------------------------------------------------------
; unsigned char __near__ disk_initialize (void)
; ---------------------------------------------------------------

.segment	"FILESYS"

.proc	_disk_initialize: near

.segment	"FILESYS"

;
; spi_Init();
;
	.dbg	line, "../../../io/src/diskio.c", 60
	jsr     decsp1
	jsr     _spi_Init
;
; res = sd_Init();
;
	.dbg	line, "../../../io/src/diskio.c", 61
	jsr     _sd_Init
	ldy     #$00
	sta     (sp),y
;
; status = 0;
;
	.dbg	line, "../../../io/src/diskio.c", 84
	sty     _status
;
; if(res < 0) {
;
	.dbg	line, "../../../io/src/diskio.c", 85
	lda     (sp),y
	asl     a
	bcc     L0008
;
; status = STA_NOINIT;
;
	.dbg	line, "../../../io/src/diskio.c", 86
	lda     #$01
	sta     _status
;
; return status;
;
	.dbg	line, "../../../io/src/diskio.c", 88
L0008:	ldx     #$00
	lda     _status
;
; }
;
	.dbg	line, "../../../io/src/diskio.c", 89
	jmp     incsp1
	.dbg	line

.endproc

; ---------------------------------------------------------------
; unsigned char __near__ disk_shutdown (void)
; ---------------------------------------------------------------

.segment	"FILESYS"

.proc	_disk_shutdown: near

.segment	"FILESYS"

;
; return 0;
;
	.dbg	line, "../../../io/src/diskio.c", 181
	ldx     #$00
	txa
;
; }
;
	.dbg	line, "../../../io/src/diskio.c", 182
	rts
	.dbg	line

.endproc

; ---------------------------------------------------------------
; unsigned char __near__ disk_status (void)
; ---------------------------------------------------------------

.segment	"FILESYS"

.proc	_disk_status: near

.segment	"FILESYS"

;
; return status;
;
	.dbg	line, "../../../io/src/diskio.c", 187
	ldx     #$00
	lda     _status
;
; }
;
	.dbg	line, "../../../io/src/diskio.c", 188
	rts
	.dbg	line

.endproc

; ---------------------------------------------------------------
; unsigned char __near__ disk_read (__near__ unsigned char*, unsigned long, unsigned char)
; ---------------------------------------------------------------

.segment	"FILESYS"

.proc	_disk_read: near

.segment	"FILESYS"

;
; for(s=0;s<numsect;s++) {
;
	.dbg	line, "../../../io/src/diskio.c", 114
	jsr     decsp1
	lda     #$00
	tay
L0040:	sta     (sp),y
	ldx     #$00
	lda     (sp),y
	iny
	cmp     (sp),y
	bcs     L0010
;
; if(sd_readSector(sector, buffer, 512)) {
;
	.dbg	line, "../../../io/src/diskio.c", 115
	jsr     decsp8
	ldy     #$0D
	jsr     ldeaxysp
	ldy     #$04
	jsr     steaxysp
	ldy     #$0F
	lda     (sp),y
	tax
	dey
	lda     (sp),y
	ldy     #$02
	sta     (sp),y
	iny
	txa
	sta     (sp),y
	lda     #$00
	tay
	sta     (sp),y
	iny
	lda     #$02
	sta     (sp),y
	jsr     _sd_readSector
	tax
	beq     L0017
;
; printf("Disk read error.\n");
;
	.dbg	line, "../../../io/src/diskio.c", 116
	lda     #<(L0001)
	ldx     #>(L0001)
	jsr     pushax
	ldy     #$02
	jsr     _printf
;
; return RES_ERROR;
;
	.dbg	line, "../../../io/src/diskio.c", 117
	ldx     #$00
	lda     #$01
	jmp     incsp8
;
; buffer += 512;
;
	.dbg	line, "../../../io/src/diskio.c", 119
L0017:	ldy     #$06
	ldx     #$02
	jsr     addeqysp
;
; ++sector;
;
	.dbg	line, "../../../io/src/diskio.c", 120
	ldx     #$00
	stx     sreg
	stx     sreg+1
	lda     #$01
	ldy     #$02
	jsr     laddeqysp
;
; for(s=0;s<numsect;s++) {
;
	.dbg	line, "../../../io/src/diskio.c", 114
	ldy     #$00
	lda     (sp),y
	clc
	adc     #$01
	jmp     L0040
;
; return RES_OK;
;
	.dbg	line, "../../../io/src/diskio.c", 122
L0010:	txa
;
; }
;
	.dbg	line, "../../../io/src/diskio.c", 123
	jmp     incsp8
	.dbg	line

.endproc

; ---------------------------------------------------------------
; unsigned char __near__ disk_write (__near__ const unsigned char*, unsigned long, unsigned char)
; ---------------------------------------------------------------

.segment	"FILESYS"

.proc	_disk_write: near

.segment	"FILESYS"

;
; for(s=0;s<numsect;s++) {
;
	.dbg	line, "../../../io/src/diskio.c", 148
	jsr     decsp1
	lda     #$00
	tay
L0041:	sta     (sp),y
	ldx     #$00
	lda     (sp),y
	iny
	cmp     (sp),y
	bcs     L0025
;
; if(sd_writeSector(sector, (euint8*)buffer)) {
;
	.dbg	line, "../../../io/src/diskio.c", 149
	jsr     decsp6
	ldy     #$0B
	jsr     ldeaxysp
	ldy     #$02
	jsr     steaxysp
	ldy     #$0D
	lda     (sp),y
	tax
	dey
	lda     (sp),y
	ldy     #$00
	sta     (sp),y
	iny
	txa
	sta     (sp),y
	jsr     _sd_writeSector
	tax
	beq     L002C
;
; printf("Verify ERROR.\n");
;
	.dbg	line, "../../../io/src/diskio.c", 150
	lda     #<(L0001+18)
	ldx     #>(L0001+18)
	jsr     pushax
	ldy     #$02
	jsr     _printf
;
; return RES_ERROR;
;
	.dbg	line, "../../../io/src/diskio.c", 151
	ldx     #$00
	lda     #$01
	jmp     incsp8
;
; buffer += 512;
;
	.dbg	line, "../../../io/src/diskio.c", 153
L002C:	ldy     #$06
	ldx     #$02
	jsr     addeqysp
;
; ++sector;
;
	.dbg	line, "../../../io/src/diskio.c", 154
	ldx     #$00
	stx     sreg
	stx     sreg+1
	lda     #$01
	ldy     #$02
	jsr     laddeqysp
;
; for(s=0;s<numsect;s++) {
;
	.dbg	line, "../../../io/src/diskio.c", 148
	ldy     #$00
	lda     (sp),y
	clc
	adc     #$01
	jmp     L0041
;
; return RES_OK;
;
	.dbg	line, "../../../io/src/diskio.c", 157
L0025:	txa
;
; }
;
	.dbg	line, "../../../io/src/diskio.c", 158
	jmp     incsp8
	.dbg	line

.endproc

; ---------------------------------------------------------------
; unsigned char __near__ disk_ioctl (unsigned char, __near__ void*)
; ---------------------------------------------------------------

.segment	"FILESYS"

.proc	_disk_ioctl: near

.segment	"FILESYS"

;
; return RES_OK;
;
	.dbg	line, "../../../io/src/diskio.c", 193
	ldx     #$00
	txa
;
; }
;
	.dbg	line, "../../../io/src/diskio.c", 194
	jmp     incsp3
	.dbg	line

.endproc

; ---------------------------------------------------------------
; void __near__ disk_timerproc (void)
; ---------------------------------------------------------------

.segment	"FILESYS"

.proc	_disk_timerproc: near

.segment	"FILESYS"

;
; }
;
	.dbg	line, "../../../io/src/diskio.c", 198
	rts
	.dbg	line

.endproc

; ---------------------------------------------------------------
; unsigned long __near__ get_fattime (void)
; ---------------------------------------------------------------

.segment	"FILESYS"

.proc	_get_fattime: near

.segment	"FILESYS"

;
; return 0x359994A0;
;
	.dbg	line, "../../../io/src/diskio.c", 219
	ldx     #$94
	lda     #$99
	sta     sreg
	lda     #$35
	sta     sreg+1
	lda     #$A0
;
; }
;
	.dbg	line, "../../../io/src/diskio.c", 220
	rts
	.dbg	line

.endproc

