-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcompile.inc
180 lines (156 loc) · 4.38 KB
/
compile.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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
;*******************************************************************************
;Copyright 2022-2024, Stefan Jakobsson
;
;Redistribution and use in source and binary forms, with or without modification,
;are permitted provided that the following conditions are met:
;
;1. Redistributions of source code must retain the above copyright notice, this
; list of conditions and the following disclaimer.
;
;2. Redistributions in binary form must reproduce the above copyright notice,
; this list of conditions and the following disclaimer in the documentation
; and/or other materials provided with the distribution.
;
;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS”
;AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
;IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
;DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
;FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
;DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
;SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
;CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
;OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
;OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
;*******************************************************************************
;******************************************************************************
;Function name.......: compile_prompt
;Purpose.............: Show context menu for compile function; only available
; in ROM version
;Input...............: Nothing
;Returns.............: Nothing
;Error returns.......: None
.proc compile_prompt
.if (::target_mem=target_ram)
rts
.endif
lda #22
sta APP_MOD
jsr cursor_disable
ldx #<msg
ldy #>msg
jsr screen_print_status
jmp screen_print_compile_ctx_footer
msg:
.byt "select tool",0
.endproc
;******************************************************************************
;Function name.......: compile_basload
;Purpose.............: Compiles and loads the current file with BASLOAD
;Input...............: Nothing
;Returns.............: Nothing
;Error returns.......: None
;In ROM bank.........: 2nd
.segment "CODE2"
.proc compile_basload
;Clear status message
call_firstbank screen_clear_status
;Check file name existence
ldx file_cur_filename_len
bne :+
lda #2
sta APP_MOD
call_firstbank screen_print_default_footer
ldx #<msg_nofile
ldy #>msg_nofile
call_firstbank screen_print_status
call_firstbank cursor_activate
rts
;Find BASLOAD
: bridge_setaddr KERNAL_FETCH
ldx #0
lda #<$fff0
sta TMP1_ADR
lda #>$fff0
sta TMP1_ADR+1
loop:
ldy #0
loop2:
lda #TMP1_ADR
phx
bridge_call KERNAL_FETCH
plx
cmp signature,y
bne next
iny
cpy #signature_end-signature
bcc loop2
bra found
next:
inx
bne loop
lda #2
sta APP_MOD
call_firstbank screen_print_default_footer
ldx #<msg_nobasload
ldy #>msg_nobasload
call_firstbank screen_print_status
call_firstbank cursor_activate
rts
found:
;Print loading message
ldx #<msg_loading
ldy #>msg_loading
call_firstbank screen_print_status
;Copy file name
stz BNK_SEL
: lda file_cur_filename-1,x
sta $bf00-1,x
dex
bne :-
;Set file len and device params
lda file_cur_filename_len
sta r0
lda file_cur_device
sta r0+1
;Run BASLOAD
sei
lda #15
sta jsrfar_bank
stz jsrfar_addr
lda #$c0
sta jsrfar_addr+1
jsr jsrfar2
cli
;Restore footer
call_firstbank screen_print_default_footer
;Show response message
call_firstbank screen_clear_status
stz BNK_SEL
ldx #$00
ldy #$bf
call_firstbank screen_print_status
;On error or warning, goto line
lda r1
beq :+
ldx r1+1
ldy r2
lda r2+1
call_firstbank cmd_goto_line
call_firstbank screen_refresh
;Clean up
: lda #2
sta APP_MOD
call_firstbank cursor_activate
rts
basload_bank = tempvars
signature:
.byt "basload"
signature_end:
.CODE
msg_loading:
.byt "loading...",0
msg_nofile:
.byt "file not saved",0
msg_nobasload:
.byt "basload not found",0
.endproc