-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommon.inc
163 lines (137 loc) · 4.44 KB
/
common.inc
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
;;; ------------------------------------------------------------
;;; ASCII
BELL := $07
BS := $08
CR := $0D
;;; ------------------------------------------------------------
;;; Constants
MAX_DW := $FFFF
;;; ------------------------------------------------------------
;;; Softswitches
CLR80VID := $C00C ; 40 Columns
SPKR := $C030 ; Toggle speaker
ROMIN2 := $C082 ; Read ROM; no write
RWRAM1 := $C08B ; Read/write RAM bank 1
;;; ------------------------------------------------------------
;;; ProDOS
PRODOS := $BF00
DATETIME := $BF06
DEVNUM := $BF30
DEVCNT := $BF31
DEVLST := $BF32
BITMAP := $BF58
BITMAP_SIZE := 24 ; 24 bytes in system bit map
DATELO := $BF90
TIMELO := $BF92
MACHID := $BF98
IBAKVER := $BFFC
IVERSION := $BFFD
SYS_ADDR := $2000 ; Load address for SYSTEM files
PATHNAME := $0280 ; Pathname of loaded system file
;;; MLI commands
MLI_QUIT := $65
MLI_READ_BLOCK := $80
MLI_GET_TIME := $82
MLI_SET_FILE_INFO := $C3
MLI_GET_FILE_INFO := $C4
MLI_ON_LINE := $C5
MLI_SET_PREFIX := $C6
MLI_OPEN := $C8
MLI_READ := $CA
MLI_CLOSE := $CC
.macro PRODOS_CALL call, params
jsr PRODOS
.byte call
.addr params
.endmacro
;;; Volume Directory Block Header structure
.scope VolumeDirectoryBlockHeader
prev_block = $00
next_block = $02
entry_length = $23
entries_per_block = $24
header_length = $2B
.endscope
;; File Entry structure
.struct FileEntry
storage_type_name_length .byte
file_name .res 15
file_type .byte
key_pointer .word
blocks_used .word
EOF .faraddr
creation .dword
version .byte
min_version .byte
access .byte
aux_type .word
last_mod .dword
header_pointer .word
.endstruct
.struct GET_FILE_INFO_PARAMS
param_count .byte
pathname .word
access .byte
file_type .byte
aux_type .word
storage_type .byte
blocks_used .word
mod_date .word
mod_time .word
create_date .word
create_time .word
.endstruct
.enum FileType
kSYS = $FF
.endenum
;;; ------------------------------------------------------------
;;; Monitor
INIT := $FB2F
MON_HOME := $FC58
WAIT := $FCA8
RDKEY := $FD0C
GETLN := $FD6A ; with prompt character
GETLN2 := $FD6F ; no prompt character
CROUT := $FD8E
PRBYTE := $FDDA
COUT := $FDED
SETNORM := $FE84
SETKBD := $FE89
SETVID := $FE93
INPUT_BUFFER := $200
;;; ------------------------------------------------------------
;;; I/O Registers (for Slot 2)
TDREG := $C088 + $20 ; ACIA Transmit Register (write)
RDREG := $C088 + $20 ; ACIA Receive Register (read)
STATUS := $C089 + $20 ; ACIA Status/Reset Register
COMMAND := $C08A + $20 ; ACIA Command Register (read/write)
CONTROL := $C08B + $20 ; ACIA Control Register (read/write)
;;; ------------------------------------------------------------
;;; Length-prefixed string
.macro PASCAL_STRING arg
.byte .strlen(arg)
.byte arg
.endmacro
;;; ------------------------------------------------------------
;;; Define a string with high bits set
;;; e.g. HIASCII "Ding ding", $7, $7
.macro HIASCII arg, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9
.if .blank(arg)
.exitmacro
.endif
.if .match ({arg}, "") ; string?
.repeat .strlen(arg), i
.byte .strat(arg, i) | $80
.endrep
.else ; otherwise assume number/char/identifier
.byte (arg | $80)
.endif
HIASCII arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9
.endmacro
;;; Like HIASCII, but null-terminated
.macro HIASCIIZ arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9
HIASCII arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9
.byte 0
.endmacro
;;; Set the high bit on the passed byte
.define HI(c) ((c)|$80)