/
eload_write_sector_nodma.s
76 lines (60 loc) · 1.75 KB
/
eload_write_sector_nodma.s
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
.include "eload_macros.s"
.importzp sp, sreg, regsave
.importzp ptr1, ptr2, ptr3, ptr4
.importzp tmp1, tmp2, tmp3, tmp4
.import popax
.import eload_send_nodma
.import eload_send_job_nodma
.import eload_upload_drive_overlay
gcr_overflow_size = 69
; =============================================================================
;
; void __fastcall__ eload_write_sector(unsigned ts, uint8_t* block);
;
; This function saves the IRQ flag, uses SEI, and restores the IRQ flag.
;
; =============================================================================
.export _eload_write_sector_nodma
_eload_write_sector_nodma:
sta block_tmp
stx block_tmp + 1 ; Save buffer
jsr popax
stx n_track
sta n_sector
php ; to backup the interrupt flag
sei
lda #ELOAD_OVERLAY_WRITE
jsr eload_upload_drive_overlay
lda #1 ; command: write sector
sta job
lda #<job
ldx #>job
jsr eload_send_job_nodma
; this will go to the GCR overflow buffer $1bb
lda block_tmp
ldx block_tmp + 1
ldy #gcr_overflow_size
jsr eload_send_nodma
; this will go to the main buffer
ldx block_tmp + 1
clc
lda block_tmp
adc #gcr_overflow_size
bcc :+
inx
:
iny ; Y = 0xff => 0 = 256 bytes
jsr eload_send_nodma
plp ; to restore the interrupt flag
rts
.data
; keep the order of these bytes
job:
.byte 2 ; command: write sector
n_track:
.byte 1 ; track
n_sector:
.byte 0 ; sector
.bss
block_tmp:
.res 2