-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjddos.p8
128 lines (120 loc) · 3.45 KB
/
jddos.p8
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
%import syslib
%import textio
%import diskio
%import string
%import jdbasic
%import jdapu
%import jderr
%encoding iso
rundos {
sub do_load() -> ubyte{
ubyte r = 0
ubyte fname_len = 0
ubyte end_bank = 0
uword end_address = 0
ubyte sbank = 0
bool flag
r = main.next()
if r == tokens.STRING {
main.get_string(main.filename)
}
fname_len = string.length (main.filename)
if (fname_len>0) {
cbm.SETLFS(1, 8, 2)
cbm.SETNAM(fname_len, main.filename)
sbank = cx16.getrambank()
cx16.rambank(2)
flag, end_bank, end_address = cbm.LOAD(0,$A000)
if flag {
error.set(3)
} else {
@(end_address) = tokens.NOCMD
@(end_address+1) = 0
txt.print("loaded to: ")
txt.print_uwhex(end_address, true)
txt.print(" bank ")
txt.print_ub(end_bank+cx16.getrambank())
txt.nl()
}
cx16.rambank(sbank)
return 0
} else {
return 1
}
}
sub do_list() -> ubyte {
ubyte sbank = 0
bool lende = false
sbank = cx16.getrambank()
cx16.rambank(2)
uword lptr = $A000
do {
if (@(lptr)==$0A) { txt.nl() } else { txt.chrout(@(lptr)) }
lptr++
if @(lptr) == tokens.NOCMD and @(lptr+1) == 0 lende = true
} until lende == true
cx16.rambank(sbank)
txt.nl()
return 0
}
sub do_dir() -> bool {
ubyte num_files = 0
ubyte r = 0
r = main.next()
if r == tokens.STRING {
main.get_string(main.buffer)
} else {
main.buffer = "*"
}
if diskio.lf_start_list(main.buffer) {
txt.print(" Blocks Filename\r")
while diskio.lf_next_entry() {
num_files++
txt.spc()
txt.spc()
if diskio.list_filetype == petscii:"dir"
txt.print("[dir]")
else
txt.print_uw(diskio.list_blocks)
txt.column(9)
txt.print(diskio.list_filename)
txt.nl()
void cbm.STOP()
if_z {
txt.print("Break\r")
break
}
}
diskio.lf_end_list()
if num_files == 0 {
txt.print("No files\r")
}
return true
}
return false
}
sub do_edit() -> ubyte {
ubyte r = 0
ubyte fname_len = 0
r = main.next()
if r == tokens.STRING {
main.get_string(main.filename)
fname_len = string.length (main.filename)
} else {
fname_len = string.length (main.filename)
}
; activate rom based x16edit, see https://github.com/stefan-b-jakobsson/x16-edit/tree/master/docs
ubyte x16edit_bank = cx16.search_x16edit()
if x16edit_bank<255 {
ubyte sbank = cx16.getrombank()
cx16.rombank(x16edit_bank)
cx16.x16edit_loadfile(2, $FE, main.filename, fname_len)
cx16.rombank(sbank)
;main.init_screen()
return true
} else {
txt.print("No x16edit found.")
return false
}
}
}