-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathxdev.s
More file actions
167 lines (129 loc) · 3.27 KB
/
Copy pathxdev.s
File metadata and controls
167 lines (129 loc) · 3.27 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
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
;
; Merlin32 Cross Dev Stub for the Jr Micro Kernel
;
; To Assemble "merlin32 -v xdev.s"
;
; Most of the time this does nothing, it checks to see if it needs to do
; something for the FoenixMgr, if not, it just runs the next kernel firmware
; program
;
; Current Functions:
; Launch Program that is loaded into memory, via runpgx, or runpgz
; Copy a file to the SDCARD if FoenixMgr has placed one in memory (pcopy)
;
mx %11
; some Kernel Stuff
put kernel_api.s
; Kernel uses MMU configurations 0 and 1
; User programs default to # 3
; I'm going to need 2 & 3, so that I can launch the PGX/PGZ with config #3
;
; and 0-BFFF mapped into 1:1
;
; Some Global Direct page stuff
; MMU modules needs 0-1F
dum $20
temp0 ds 4
temp1 ds 4
temp2 ds 4
temp3 ds 4
dend
; Event Buffer at $30
event_type = $30
event_buf = $31
event_ext = $32
event_file_data_read = event_type+kernel_event_event_t_file_data_read
event_file_data_wrote = event_type+kernel_event_event_t_file_wrote_wrote
; arguments
args_buf = $40
args_buflen = $42
old_sp = $A0
mmu_lock_springboard = $60 ; about 17 bytes
crossdev_signature = $80
crossdev_pc = $88 ; jump to here
; File uses $B0-$BF
; Term uses $C0-$CF
; Kernel uses $F0-FF
; 8k Kernel Program, so it can live anywhere
org $A000
dsk xdev.bin
sig db $f2,$56 ; signature
db 1 ; 1 8k block
db 5 ; mount at $a000
da start ; start here
db 1 ; version
db 0 ; reserved
db 0 ; reserved
db 0 ; reserved
asc 'xdev' ; This will require some discussion with Gadget
db 0
;asc '<file>' ; argument list
db 0
asc 'CrossDev - FoenixMgr[runpgx,runpgz,pcopy].' ; description
db 0
start
; check for springboard
ldx #7
]lp
lda |txt_crossdev,x
cmp <crossdev_signature,x
bne :no_crossdev
dex
bpl ]lp
; break the signature, so the next reset will work
stz <crossdev_signature
; we need to unmap ourselves so slot 5 is mapped to slot 5
jsr mmu_unlock
lda #5
sta old_mmu0+5 ; when lock is called it will map $A000 to physcial $A000
; need to place a copy of mmu_lock, where it won't be unmapped
ldx #mmu_lock_end-mmu_lock
]lp lda mmu_lock,x
sta mmu_lock_springboard,x
dex
bpl ]lp
; construct more stub code
lda #$20 ; jsr mmu_lock_springboard
sta temp0
lda #<mmu_lock_springboard
sta temp0+1
lda #>mmu_lock_springboard
sta temp0+2
lda #$6C ; jmp (|abs)
sta temp0+3
lda #<crossdev_pc
sta <temp0+4
lda #>crossdev_pc
sta <temp0+5
jmp temp0
:no_crossdev
; check for pcopy, file copy request
ldx #7
]lp
lda |txt_copyfile,x
cmp <crossdev_signature,x
bne :no_pcopy
dex
bpl ]lp
; break the signature, so the next reset will work
stz <crossdev_signature
jsr pcopy
:no_pcopy
; just boot the machine, into the next program
lda #$42 ; assuming we are block $41, maybe there's a way to sniff this?
sta kernel_args_run_block_id
jmp kernel_RunBlock
;------------------------------------------------------------------------------
txt_crossdev asc 'CROSSDEV'
txt_copyfile asc 'COPYFILE'
;------------------------------------------------------------------------------
; Strings and other includes
put mmu.s
put term.s
put file.s
put crc32.s
put pcopy.s
; pad to the end
ds $C000-*,$EA
; really pad to end, because merlin is buggy
ds \