**** CBM BASIC V2 **** 3583 BYTES FREE READY. Hi there, VIC-20 freaks ! Some months ago, the first VIC-20 ftp archive opened. The name of the server is ftp.hrz.uni-kassel.de and there are a lot of ROM modules in the directory /pub/machines/vic-20/rom. This document contains sections about how to copy rom modules to files, burn them into EPROMs or load them from disk back into the VIC. ----------------------------------------------------------------------- 1. How to rip VIC-20 programs Original Programs for the VIC came on several media, mostly ROM modules and cassette. The "cracked" ROM modules were mainly spread on cassette, saved with some sort of "Turbo-Tape" which loads an 8K module in a few seconds. There were also 16K modules, they were saved to two files, the first was a dump from Block 5, the second was a dump from Block 1,2 or 3. We're describing here a way to copy ROM modules or files to a host computer. 1.1 Loading ROM modules from cassette This one is easy. The modules which can be loaded from tape are coming most often in a fast tape format, which consists of the fastloader, loadable with LOAD and the module itself, which if located after the fastloader, to be loaded with it. So the modules can be loaded with the following steps: 1. Make sure that your RAM-Expansion is located were the module is loaded. 2. Load the fastloader with LOAD 3. The tape will stop. Now type SYS4612 to start the fastloader. 4. After about 10 seconds the module is loaded. Most modules can be started with a reset, which means connecting Pin 1 and 3 of the Userport for a short time or typing SYS64802 1.2 ROM Modules ROM modules are started by switching on the VIC-20. This is a problem, because when the program has started, you can't transfer it anymore. So to prevent autostarting, you have to move the location of the module in memory to another address. Autostart modules are always located at $A000, so just open your module, find the the solder pads labeled '5' and cut them. After that connect either pad '1', '2' or '3'. This operation moved the modules base address to $2000, $4000 or $6000, respectively. 2. Transferring programs to an Amiga Now the module is in the memory, either in RAM or in a non-autostart location. We have to transfer it to the host computer. We are describing now how to build the cable and transfer the module. 2.1 Building the Cable In order to make a connection between the VIC-20 and a host computer which can write disks and burn EPROMs, we have to build a cable. For reasons of speed and programming convenience, we choose a parallel data transfer using the VIC-20 VIAs, which already have the capability of hardware handshaking. As an example of a host system, we used an Amiga 1000, connected via a parallel cable to the VIC-20. The parallel cable has the following connections: VIC-20 Amiga 1000 Userport Printerport A GND 17 GND B CB1 1 /STR C PB0 2 D0 D PB1 3 D1 E PB2 4 D2 F PB3 5 D3 H PB4 6 D4 J PB5 7 D5 K PB6 8 D6 L PB7 9 D7 M CB2 11 BUSY 2.2 The transfer program for the VIC-20 The transfer program is an assembler program: START LDA #$FF A9 00 ; set all lines to output STA $9112 8D 12 91 ; ->DDRB LDA #$42 A9 42 ; STA $911B 8D 1B 91 ; ->ACR LDA #$9E A9 9E ; STA $911C 8D 1C 91 ; ->PCR LDA #$7F A9 7F ; STA $911D 8D 1D 91 ; ->IER LDA #$88 A9 88 ; STA $911E 8D 1E 91 ; ->ICR LDA #$00 A9 00 ; low byte of address counter STA $A7 85 A7 ; LDA #$A0 A9 A0 ; high byte of address counter STA $A8 85 A8 ; = A000 LDX #$20 A2 20 ; number of pages (32*256=8K) LDY #$0 A0 00 ; address index register WAIT LDA $911D 8D 1D 91 ; test acknowledge bit AND #$10 29 10 ; mask bit 4 BEQ WAIT F0 F9 ; wait until set LDA ($A7),Y B1 A7 ; get next byte STA $9110 8D 10 91 ; write it to the Userport INY C8 ; increment index register BNE WAIT D0 F1 ; until end of page INC $A8 E6 A8 ; increment high byte of address DEX CA ; decrement page counter BNE WAIT D0 EC ; until last page RTS 60 ; return to BASIC There are no absolute JMP's or TABLES in the program and therefor it is relocatable. This program dumps 32 pages of 256 Byte (=8KByte) to the Userport, doing the hardware handshaking with the host computer. To change the default startaddress and size of the transferred memory block, you have to modify the following adresses: START+$1A Low byte of block start START+$1E High byte of block start START+$22 Number of Pages (256 Byte) In this version of the program you can only transfer an integer number of pages, so simply rounded up the number of bytes/256 and cut the file to the right length on the host computer (if necessary). 2.3 The transfer Program for the Amiga The receiving programm for the Amiga is written in C and called "VICGET". It reads a certain number of bytes from the parallel port and writes them to a file. The command line for starting the program is: vicget bytes filename To control the proceeding of the transfer it writes hash marks ("#") to it's standard output, much like FTP ;) The program is started AFTER the transfer program on the VIC, because vicget initiates the transfer. Ok, here is the sourcecode: ---------------------cut-----------------------cut------------------ #include #include #include int main(int argc,char *argv[]) { unsigned char *base=(unsigned char *)0xbfe001; unsigned char *baseb=(unsigned char *)0xbfd000; const int u=256; FILE *fp; char *name; char c,b; int length; int i; puts("VC20 -> Amiga"); if(argc==3) { length=atoi(argv[2]); if((fp=fopen(argv[1],"w"))!=NULL) { *(base+0x3*u)=0; *(baseb+0x2*u)&= 0xfe; b=*(base+0x1*u); for(i=0;i0 ?A(>0 3 O "\!+P).N0 !2#>_ 4)!].=6EX96UUX M;"YL:6)R87)Y $-O;G1I;G5E &EX96UU;"YL:6)R87)Y('=A0 9.N0 !$90X M3TAY !,$AY !^"\Y !"\Y "\"+PI.N0 !3@D -[\ !@L> $X M(GD $D3J[^8B "8$H@> $)&@!%$AY L$AY MDZY $1E!/2JH X MK&8F+'@ !$ZN_WQT7-2*($).KOZ +'@ !"!"3J[^C"QX 0B0$ZN_H9P%$S?X M1 1.=4CG. H+P 0)B\ %"0O !A(>0 A(>0 2Q(>0 2!(>0 1A(X M>0 1Q(>0 2A(> &3KD 4L(\( (+P(O R\$3KD )LWOP *$S?X M !Q.=4YU5D,R," M/B!!;6EG80!W '9C9V5T.B 3E7_X"\#+P).N0 !=HKX M? "_X '__"M\ +_0 /_X*WP $ __1(>0 E1.N0 !5!83W8#MJT "&8 X M 2 @;0 ,4$@O$$ZY $\%A/*T#_YDAY "8B!M Q82"\03KD 444$\BX M "M!__!*@6< -PB+?_T( '0@-"!(&W__$(P" B+?_T( '0@"!M__@B+?_TX M) '4@B)M__@6,2@ @, _A&#" @;?_\T>W_]!M0_^I"K?_B)BW_XK:M_^9LX M?"!M__@0$!M _^L" !2@!G F#L+RW_\"!M__S1[?_T$! ;0/_J2( P0"\(X M87Q03R M_^(B+?_B2H!L!@: _^" ) #A@B !D()*@&8D('D $L6$@OX M$$AX "-A2E!/('D $L6$@O$$ZY %"%A/4JW_XF _WPO+?_P3KD 3\X M6$]@#DAY "9$ZY %1%A/< !@ ")"W_V"8M_]Q.74YU3E4 "\*+P(DX M+0 ()&T #%.J A*J@ (;!(B:@ (L^H &&T:# ( "F8"8!(@4A "$( 2 ' X M$ %2DF 28! O"B\"3KD 3D4$]@ ")"W_^"1M__Q.74YU:6YT=6ET:6]NX M+FQI8G)A $0_D 0T< !.KOW8* !F!'#_8'1"+P LX M'WP 0 M'WP 0 N0J\ -$*O #QT+-2/1^\ &"!"(DMP%$ZN_9 _? & !P_X M? # !X_? / # _? % #(O;P!( #@O;P!, "0L1)'((D*5RG <@ D/ X M 4!V2$ZN_J0D "QX 0B1$ZN_F(@ DS?3!S>_ L3G4@>0 230_/8B3M @X M>0 21!Z/^^3M @>0 230_/@R3M @>0 230_/@:3M @>0 230_/?PX M3M @>0 230_/B83M @>0 230_/B23M @>0 230_/W83M @>0 230X M_/U.3M @>0 230_/=X3M!.50 2.&5C7V5N=')Y "0 "7T5.5%)9 #B U]S=&%R=%]S=&1IX M;P ?@ #7VUO;F-O;G1R;VP "4@ )M8V]U;G0 E( "X M7VUA:6X )L E]?7W-P=71C #V@ 1?7U]R97%U97-T7VUSX M9P $1@ )?7U]S=V)U9@ !.0 "7V%T;VD 3P E]FX M8VQO%]E>&5C7V5N=')Y 4@ !%]I>%]G971?=F%R%]S=&%R='5P !3@ "7W!E&ETX M !?0 "7V5T97AT 8 E]?971E>'0 & /RX M #Z@ 8 ! 4 /L 0 $ X M , _ $7V5X<&%N9%]C;61?;&EN90 "7U]S9&%TX M80 !5]D969A=6QT7W=B7W=I;F1O=P ! )?96YV:7)OX M;@ @ $7U]E>&ET7V1U;6UY7W)E9@ P $7VEN:71I86QI>F5DX M+C8 ! %7U]E>&ET7V1U;6UY7V1E8VP 4 E]?961AX M=&$ & )?961A=&$ !@ #\@ ^L !. #\ X M )?8G5F+C "7V)U9BXQ & !%]?7T143U)?3$E3X M5%]? $( !%]?7T-43U)?3$E35%]? $0 E]3>7-"87-EX M !& -? POKE START+30,32 $4000 (/CS wired with /BLK2) -> POKE START+30,64 $6000 (/CS wired with /BLK3) -> POKE START+30,96 Transfer second block 2.4.3 normal LOADable program POKE START+26,PEEK(43) POKE START+30,PEEK(44) POKE START+34,PEEK(46)-PEEK(44)+1 (should be enough) Transfer program Cut down the program on your host computer to the right length: (PEEK(46)-PEEK(44))*256+PEEK(45)-PEEK(43) this can be done, for example, with the command 'head -c length'. 3. Burning ROM modules into EPROMS This can be done with a normal EPROM programmer, all sorts of EPROMs should be fast enough for the VIC. You can burn several Modules into one EPROM and switch between them with the upper address lines. 4. Starting EPROM modules EPROM modules are autostart modules which means that they should start immediately after turning on your VIC. But there are some modules which don't have the neccessary autostart id at the beginning. These modules must be started with a SYS call. 5. Modifying the 3K Super Expander for use with EPROMS [text is not yet completed] 6. Loading Rom Modules from Disk To load the modules from disk you have to do some modification to the file. The command LOAD"file",8,1 loads the file to an absolute location, but the information where the file is located is missing in the files from the ftp server. The load address simply consists of two bytes at the beginning of the file, in LOW-HIGH order. To load a file to the address $A000, you have to prepend the bytes $00 $A0 to the file.In UNIX this is done with the lines: printf '\x0\xA0' >file.out # LoadAdr: L/H cat file.in >>file.out # append file If you want to add the address with the VIC, you can use this BASIC program: 5 S=8192 : REM length: 8K 10 OPEN 1,8,0,"INFILE" 20 FOR I=0 TO S-1 30 GET #1,A$ 40 POKE 40960+i,ASC(A$) : REM use $A000 as temporary RAM 50 NEXT 60 CLOSE 1 70 OPEN 1,8,1,"OUTFILE" 80 PRINT #1,CHR$(0) 90 PRINT #1,CHR$(160) 100 FOR I=0 TO S-1 110 PRINT #1,CHR$(PEEK(I+40960)) 120 NEXT 130 CLOSE 1 7. [...] Please report spelling and programming bugs. More info and new programs welcome... Have fun, Andreas Heitmann (heitmann@crunch.ikp.physik.th-darmstadt.de)