File: loader.txt

package info (click to toggle)
cbmlink 0.9.6-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 856 kB
  • ctags: 1,304
  • sloc: ansic: 5,849; asm: 2,904; makefile: 188; sh: 60
file content (113 lines) | stat: -rw-r--r-- 3,323 bytes parent folder | download | duplicates (2)
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
This basic loader implements part of the prlink protocol, and it can
be used to transfer the prlink server to your computer if you do not
have any means for data transfer.

The following listing contains a bootstrap program for the PET and the
4/8 bit version of the prlink cable.  Modifications for other hosts
(VIC-20 and C64/C128) and cables follow this main listing.

 99 hs=201:rem system type
 100 av=32:ack=59468: rem ack (out) is cb2
 110 dat=59471: rem port a
 120 ddr=59459
 130 sv=2:srobe=59469: rem strobe (in) is ca1
 199 rem *** init handshaking lines
 200 poke ack, (peek(ack) and 254) or (128+64+32)
 300 print "waiting for command":gosub990
 310 printby
 320 if by then 330
 322 by=hs:gosub 1190
 324 by=0:gosub 1200:gosub 1200:gosub 1200:gosub 1200
 326 goto 300
 330 if by=1 then gosub2000:goto300
 340 print"(unknown function)":goto 300
 989 rem *** switch from send to receive, then receive a byte
 990 poke ddr,0
 999 rem *** receive a byte
 1000 if (peek(sr) and sv) = 0 then 1000
 1010 poke sr,sv
 1020 by = peek(dat)
 1030 i= peek(ack): i = (i or av) - (i and av) : poke ack,i
 1040 return
 1189 rem *** switch from receive to send, then send a byte
 1190 rem
 1199 rem *** send a byte
 1200 if (peek(sr) and sv) = 0 then 1200
 1210 poke sr,sv
 1220 poke ddr,15:poke dat,by
 1230 i= peek(ack): i = (i or av) - (i and av) : poke ack,i
 1240 if (peek(sr) and sv) = 0 then 1240
 1250 poke sr,sv
 1260 poke dat,by/16
 1270 i= peek(ack): i = (i or av) - (i and av) : poke ack,i
 1280 return
 1999 rem *** load
 2000 gosub1000:print"bank"by
 2010 by=0:gosub1190
 2020 gosub990:f=by:gosub1000:f=f+256*by:print"from"f
 2030 gosub1000:t=by:gosub1000:t=t+256*by:print"to  "t
 2040 for a=f to t-1
 2050 gosub1000:printa,by
 2060 next
 2070 return

Modifications
-------------
To really do the load function (after everything seems to work),
change the print in line 2050 to poke.

Here are the modifications for the VIC-20 and C64, using the
4-bit/8-bit cable:

VIC-20:
 99 hs=20:rem system type
 100 av=32:ack=37148: rem ack (out) is cb2
 110 dat=37136: rem port b
 120 ddr=37138
 130 sv=16:srobe=37149: rem strobe (in) is cb1
 200

C64 and C128:
 99 hs=64:rem or 128
 100 av=4:ack=56576: rem ack (out) is pa2 
 110 dat=56577: rem port b
 120 ddr=56579
 130 sv=16:srobe=56589: rem strobe (in) is -flag
 200 pokeack+2,peek(ack+2)orav:pokeack,peek(ack)orav

If you want to use the PC64 cable instead, apply these (additional)
patches:

 990 poke ddr,15
 1030 poke ack,peek(ack) and (255-av)
 1040 if (peek(sr) and sv) = 0 then 1040
 1050 poke sr,sv
 1060 by = peek(dat) and 240 or (by/16)
 1070 poke ack,peek(ack) or av
 1080 return
 1230 poke ack,peek(ack) and (255-av)
 1270 poke ack,peek(ack) or av

If you want to use the Kontros interface on the C64, C128 or VIC-20,
you will need to make these changes instead of the PC64 patch.  You
will also need to make the modifications for VIC-20 or C64, as shown
earlier.

 200 poke ack+2, peek(ack+2) and (255-av)
 990 pokeddr,0:pokedat,0
 1030
 1190 if(peek(sr)andsv)=0then1190
 1195 pokesr,sv:poke ddr,255
 1200 poke dat,by
 1210 if (peek(sr) and sv) = 0 then 1210
 1220 poke sr,sv
 1230 return
 1240
 1250
 1260
 1270
 1280

For the VIC-20 (using the Kontros cable), make this additional change:
 200 poke ack, (peek(ack) and 14) or (128+32)
 1030 poke dat,by