-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgethardcodedpointers.asm
More file actions
71 lines (57 loc) · 2.21 KB
/
gethardcodedpointers.asm
File metadata and controls
71 lines (57 loc) · 2.21 KB
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
; FreeDiskSysROM
; Copyright (c) 2018 James Athey
;
; This program is free software: you can redistribute it and/or modify it under
; the terms of the GNU Lesser General Public License version 3 as published by
; the Free Software Foundation.
;
; This program is distributed in the hope that it will be useful, but WITHOUT
; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
; FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
; details.
;
; You should have received a copy of the GNU Lesser General Public License
; along with this program. If not, see <https://www.gnu.org/licenses/>.
; This routine does 3 things. First, it fetches 1 or 2 hardcoded 16-bit
; pointers that follow the second return address. Second, it checks the
; disk set or even write-protect status of the disk, and if the checks fail,
; the first return address on the stack is discarded, and program control is
; returned to the second return address. Finally, it saves the position of
; the stack so that when an error occurs, program control will be returned to
; the same place.
; Parameters: A == -1 means there are two 16-bit pointer parameters, otherwise just 1.
; Returns: A == OK (0) if no error, or DISK_NOT_SET (1) if the disk is not set. ($00) contains where results were loaded
; Affects:
;params
;------
;2nd call addr 1 or 2 16-bit pointers
;A -1 2 16-bit pointers are present
; other values 1 16-bit pointer present
;rtns (no error)
;---------------
;PC original call address
;A 00
;[$00] where parameters were loaded (A is placed in [$02] if not -1)
;(error)
;-------
;PC second call address
;Y byte stored in [$0E]
;A 01 if disk wasn't set
; 03 if disk is write-protected
API_ENTRYPOINT $e3e7
GetHardCodedPointers:
CLC
BCC GetHardCodedPointersImpl
; Same as GetHardCodedPointers, except that
; Returns: A == OK (0) if no error, DISK_NOT_SET (1) if disk is not set, and WRITE_PROTECTED (3) if the disk is write-protected.
API_ENTRYPOINT $e3ea
GetHardCodedPointersWriteProtected:
SEC
GetHardCodedPointersImpl:
BCC @end ; skip write-protect check if C is false
LDA DRIVESTATUS
AND #%00000100 ; bit 2 contains the write-protect status
BEQ @end
; error handling
@end:
RTS