home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 6 / AACD06.ISO / AACD / Emulation / VIC / SAVETHEG.TXT < prev    next >
Text File  |  1995-01-07  |  13KB  |  364 lines

  1. **** CBM BASIC V2 ****
  2.  
  3. 3583 BYTES FREE
  4.  
  5. READY.
  6.  
  7.  
  8. Hi there, VIC-20 freaks !
  9.  
  10. Some months ago, the first VIC-20 ftp archive opened. The name of the 
  11. server is ftp.hrz.uni-kassel.de and there are a lot of ROM modules
  12. in the directory /pub/machines/vic-20/rom.
  13.  
  14. This document contains sections about how to copy rom modules to files,
  15. burn them into EPROMs or load them from disk back into the VIC.
  16.  
  17. -----------------------------------------------------------------------
  18.  
  19. 1.  How to rip VIC-20 programs
  20.  
  21. Original Programs for the VIC came on several media, mostly ROM
  22. modules and cassette. The "cracked" ROM modules were mainly spread
  23. on cassette, saved with some sort of "Turbo-Tape" which loads an 8K
  24. module in a few seconds. There were also 16K modules, they were saved
  25. to two files, the first was a dump from Block 5, the second was a dump
  26. from Block 1,2 or 3. We're describing here a way to copy ROM modules
  27. or files to a host computer.
  28.  
  29. 1.1 Loading ROM modules from cassette
  30.  
  31. This one is easy. The modules which can be loaded from tape are coming
  32. most often in a fast tape format, which consists of the fastloader,
  33. loadable with LOAD and the module itself, which if located after the
  34. fastloader, to be loaded with it. So the modules can be loaded with
  35. the following steps:
  36.  
  37.     1. Make sure that your RAM-Expansion is located were the
  38.        module is loaded.
  39.     2. Load the fastloader with LOAD
  40.     3. The tape will stop. Now type SYS4612 to start the
  41.        fastloader.
  42.     4. After about 10 seconds the module is loaded. Most modules
  43.        can be started with a reset, which means connecting
  44.        Pin 1 and 3 of the Userport for a short time or typing
  45.        SYS64802
  46.  
  47. 1.2 ROM Modules
  48.  
  49. ROM modules are started by switching on the VIC-20. This is a problem,
  50. because when the program has started, you can't transfer it anymore.
  51. So to prevent autostarting, you have to move the location of the
  52. module in memory to another address. Autostart modules are always
  53. located at $A000, so just open your module, find the the solder pads
  54. labeled '5' and cut them. After that connect either pad '1', '2' or
  55. '3'. This operation moved the modules base address to $2000, $4000 or
  56. $6000, respectively.
  57.  
  58. 2.  Transferring programs to an Amiga 
  59.  
  60. Now the module is in the memory, either in RAM or in a non-autostart
  61. location. We have to transfer it to the host computer. We are
  62. describing now how to build the cable and transfer the module.
  63.  
  64. 2.1 Building the Cable
  65.  
  66. In order to make a connection between the VIC-20 and a host computer
  67. which can write disks and burn EPROMs, we have to build a cable.  For
  68. reasons of speed and programming convenience, we choose a parallel
  69. data transfer using the VIC-20 VIAs, which already have the capability
  70. of hardware handshaking.
  71.  
  72. As an example of a host system, we used an Amiga 1000, connected via a
  73. parallel cable to the VIC-20. The parallel cable has the following
  74. connections:
  75.  
  76.     VIC-20         Amiga 1000
  77.     Userport    Printerport
  78.  
  79.     A    GND    17    GND
  80.     B    CB1    1    /STR
  81.     C    PB0    2    D0
  82.     D    PB1    3    D1
  83.     E    PB2    4    D2
  84.     F    PB3    5    D3
  85.     H    PB4    6    D4
  86.     J    PB5    7    D5
  87.     K    PB6    8    D6
  88.     L    PB7    9    D7
  89.     M    CB2    11    BUSY
  90.  
  91.  
  92. 2.2 The transfer program for the VIC-20
  93.  
  94. The transfer program is an assembler program:
  95.  
  96. START    LDA #$FF    A9 00        ; set all lines to output
  97.     STA $9112    8D 12 91    ; ->DDRB
  98.     LDA #$42    A9 42        ; 
  99.     STA $911B    8D 1B 91    ; ->ACR
  100.     LDA #$9E    A9 9E        ;
  101.     STA $911C    8D 1C 91    ; ->PCR
  102.     LDA #$7F    A9 7F        ;
  103.     STA $911D    8D 1D 91    ; ->IER
  104.     LDA #$88    A9 88        ;
  105.     STA $911E    8D 1E 91    ; ->ICR
  106.     LDA #$00    A9 00        ; low byte of address counter
  107.     STA $A7        85 A7        ;
  108.     LDA #$A0    A9 A0        ; high byte of address counter
  109.     STA $A8        85 A8        ; = A000
  110.     LDX #$20    A2 20        ; number of pages (32*256=8K)
  111.     LDY #$0        A0 00        ; address index register
  112. WAIT    LDA $911D    8D 1D 91    ; test acknowledge bit
  113.     AND #$10    29 10        ; mask bit 4
  114.     BEQ WAIT    F0 F9        ; wait until set
  115.     LDA ($A7),Y    B1 A7        ; get next byte
  116.     STA $9110    8D 10 91    ; write it to the Userport
  117.     INY        C8        ; increment index register
  118.     BNE WAIT    D0 F1        ; until end of page
  119.     INC $A8        E6 A8        ; increment high byte of address
  120.     DEX        CA        ; decrement page counter
  121.     BNE WAIT    D0 EC        ; until last page
  122.     RTS        60        ; return to BASIC
  123.  
  124. There are no absolute JMP's or TABLES in the program and therefor it
  125. is relocatable. This program dumps 32 pages of 256 Byte (=8KByte) to
  126. the Userport, doing the hardware handshaking with the host computer.
  127.  
  128. To change the default startaddress and size of the transferred memory
  129. block, you have to modify the following adresses:
  130.  
  131.     START+$1A    Low byte of block start
  132.     START+$1E    High byte of block start
  133.     START+$22    Number of Pages (256 Byte)
  134.  
  135. In this version of the program you can only transfer an integer number
  136. of pages, so simply rounded up the number of bytes/256 and cut the
  137. file to the right length on the host computer (if necessary).
  138.  
  139.  
  140. 2.3 The transfer Program for the Amiga
  141.  
  142. The receiving programm for the Amiga is written in C and called
  143. "VICGET". It reads a certain number of bytes from the parallel port
  144. and writes them to a file. The command line for starting the
  145. program is:
  146.  
  147.     vicget bytes filename
  148.  
  149. To control the proceeding of the transfer it writes hash marks ("#")
  150. to it's standard output, much like FTP ;)
  151.  
  152. The program is started AFTER the transfer program on the VIC, because
  153. vicget initiates the transfer.
  154.  
  155. Ok, here is the sourcecode:
  156.  
  157. ---------------------cut-----------------------cut------------------
  158. #include <stdio.h>
  159. #include <strings.h>
  160. #include <limits.h>
  161.  
  162. int main(int argc,char *argv[])
  163. {
  164.   unsigned char *base=(unsigned char *)0xbfe001;
  165.   unsigned char *baseb=(unsigned char *)0xbfd000;
  166.   const int  u=256;
  167.   FILE *fp;
  168.   char *name;
  169.   char c,b;
  170.   int length;
  171.   int i;
  172.  
  173.   puts("VC20 -> Amiga");
  174.   if(argc==3) {
  175.     length=atoi(argv[2]);
  176.  
  177.     if((fp=fopen(argv[1],"w"))!=NULL)
  178.       {
  179.     *(base+0x3*u)=0;
  180.     *(baseb+0x2*u)&= 0xfe;
  181.  
  182.         b=*(base+0x1*u);
  183.     for(i=0;i<length;i++)
  184.       {
  185.         while(((c=*(baseb+0x0*u)) & (1<<0))!=0) /* printf("c:%x\n",c) */;
  186.         putc(b=*(base+0x1*u),fp);
  187.         if(i%256==0) { putchar('#'); fflush(stdout); }
  188.       }
  189.     fclose(fp);
  190.       }
  191.     else perror("vcget: ");
  192.   }
  193.  
  194. }
  195. ---------------------cut-----------------------cut------------------
  196.  
  197. It should compile under gcc, but for those people who don't have it,
  198. here is the executable as uuencoded binary:
  199.  
  200. ---------------------cut-----------------------cut------------------
  201. begin 777 vcget
  202. M   #\P         #          (   &     !@   $X   /I   !@$[Z .  X
  203. M 0$'   &     !@   $X         "0          "\")"\ #"(O ! @+P 4X
  204. M(^\ "    21(>0   ?A(>0   3 O "\!+P).N0  !2#>_  4)!].=6EX96UUX
  205. M;"YL:6)R87)Y $-O;G1I;G5E &EX96UU;"YL:6)R87)Y('=A<FYI;F<Z(&YEX
  206. M961E9"!R979I<VEO;B R.2P@8W5R<F5N="!R979I<VEO;B  06)O<G0 3F5EX
  207. M9"!A="!L96%S="!V97)S:6]N(#,Y(&]F(&EX96UU;"YL:6)R87)Y+@!(YR BX
  208. M)$@D "QX  1#^0   %IP)TZN_=@@0"/(   !)&<  *0,:  G !1F8 QH !P X
  209. M%F)82'D   !I0H$R*  60_D    &0?D   !R$!@2P&;Z4TE!^0    5"$$I!X
  210. M9Q@P 4C @?P "DA !@  ,!$ 2,&#_  *9N@0&!+ 9OI(>0    9.N0  !$90X
  211. M3TAY   !,$AY   !^"\Y    !"\Y     "\"+PI.N0  !3@D -[\ !@L>  $X
  212. M(GD   $D3J[^8B "8$H@>  $)&@!%$AY    L$AY    MDZY   $1E!/2JH X
  213. MK&8F+'@ !$ZN_WQT7-2*($).KOZ +'@ !"!"3J[^C"QX  0B0$ZN_H9P%$S?X
  214. M1 1.=4CG.  H+P 0)B\ %"0O !A(>0    A(>0   2Q(>0   2!(>0   1A(X
  215. M>0   1Q(>0   2A(>  &3KD   4L(\(    (+P(O R\$3KD   )LWOP *$S?X
  216. M !Q.=4YU5D,R," M/B!!;6EG80!W '9C9V5T.B  3E7_X"\#+P).N0  !=HKX
  217. M? "_X '__"M\ +_0 /_X*WP   $ __1(>0   E1.N0  !5!83W8#MJT "&8 X
  218. M 2 @;0 ,4$@O$$ZY   $\%A/*T#_YDAY   "8B!M  Q82"\03KD   444$\BX
  219. M "M!__!*@6<  -PB+?_T( '0@-"!(&W__$(P"  B+?_T( '0@"!M__@B+?_TX
  220. M) '4@B)M__@6,2@  @, _A&#"  @;?_\T>W_]!M0_^I"K?_B)BW_XK:M_^9LX
  221. M?"!M__@0$!M _^L"   !2@!G F#L+RW_\"!M__S1[?_T$! ;0/_J2( P0"\(X
  222. M87Q03R M_^(B+?_B2H!L!@:     _^" ) #A@B !D()*@&8D('D   $L6$@OX
  223. M$$AX "-A2E!/('D   $L6$@O$$ZY   %"%A/4JW_XF  _WPO+?_P3KD   3\X
  224. M6$]@#DAY   "9$ZY   %1%A/< !@   ")"W_V"8M_]Q.74YU3E4  "\*+P(DX
  225. M+0 ()&T #%.J  A*J@ (;!(B:@ (L^H &&T:# ( "F8"8!(@4A "$( 2 '  X
  226. M$ %2DF 28! O"B\"3KD   3D4$]@   ")"W_^"1M__Q.74YU:6YT=6ET:6]NX
  227. M+FQI8G)A<GD WOS_U$CG.#(L>  $0_D   0T< !.KOW8* !F!'#_8'1"+P LX
  228. M'WP  0 M'WP  0 N0J\ -$*O #QT+-2/1^\ &"!"(DMP%$ZN_9 _?  & !P_X
  229. M?  # !X_?  / # _?  % #(O;P!( #@O;P!, "0L1)'((D*5RG  <@ D/   X
  230. M 4!V2$ZN_J0D "QX  0B1$ZN_F(@ DS?3!S>_  L3G4@>0   230_/8B3M @X
  231. M>0   21!Z/^^3M @>0   230_/@R3M @>0   230_/@:3M @>0   230_/?PX
  232. M3M @>0   230_/B83M @>0   230_/B23M @>0   230_/W83M @>0   230X
  233. M_/U.3M @>0   230_/=X3M!.50  2.<P("(Y   !"';_MH%F''( 2KD   $,X
  234. M9Q)!^0   0Q2@2 !Y8!*L @ 9O0D 6<41?D   $(( +E@"!R" !.D%."9O),X
  235. M[00,__1.74YU3E4  "\*1?D   $42I)G""!:3I!*DF;X2'D   5<3KD   7TX
  236. M)&W__$Y=3G5.50  2KD    09@IP 2/     $&&^3EU.=2!Y   !)$'H_\I.X
  237. MT    ^P    <         !@    \    3@   /    $8   !*@   6@   %VX
  238. M   !C    ;(   &X   !O@   C(   )$   "=@   I0   *:   "M    L  X
  239. M  +.   #G@   [(   .\   #P@  !!X   14   %R   !<X    &     0  X
  240. M 7P   &"   ""@   C@   7@   %Z@   !\    "    -@   $(   #^   !X
  241. M)    3@   %B   !<    9P   (0   "%@   AP   (B   "*    X(   .4X
  242. M   $Y@  !/(   3^   %"@  !18   4B   %+@  !3H   5&   %4@  !68 X
  243. M  5T   %?   !9(   6V   %]@        /P     65X96,    $     U]EX
  244. M>&5C7V5N=')Y     "0    "7T5.5%)9      #B     U]S=&%R=%]S=&1IX
  245. M;P   ?@    #7VUO;F-O;G1R;VP    "4@    )M8V]U;G0      E(    "X
  246. M7VUA:6X       )L     E]?7W-P=71C   #V@    1?7U]R97%U97-T7VUSX
  247. M9P     $1@    )?7U]S=V)U9@  !.0    "7V%T;VD       3P     E]FX
  248. M8VQO<V4    $_     )?9F9L=7-H    !0@    "7V9O<&5N      44    X
  249. M!%]I>%]E>&5C7V5N=')Y      4@    !%]I>%]G971?=F%R<S(       4LX
  250. M     U]I>%]S=&%R='5P    !3@    "7W!E<G)O<@    5$     E]P=71SX
  251. M       %4     5?7U]D;U]G;&]B86Q?9'1O<G,     !5P    %7U]?9&]?X
  252. M9VQO8F%L7V-T;W)S      6N     E]?7VUA:6X    %V@    )?871E>&ETX
  253. M    !?0    "7V5T97AT      8      E]?971E>'0    &          /RX
  254. M   #Z@    8    !               4              /L     0    $ X
  255. M   ,         _     $7V5X<&%N9%]C;61?;&EN90         "7U]S9&%TX
  256. M80          !5]D969A=6QT7W=B7W=I;F1O=P      !     )?96YV:7)OX
  257. M;@    @    $7U]E>&ET7V1U;6UY7W)E9@    P    $7VEN:71I86QI>F5DX
  258. M+C8      !     %7U]E>&ET7V1U;6UY7V1E8VP        4     E]?961AX
  259. M=&$     &     )?961A=&$      !@        #\@   ^L   !.   #\   X
  260. M  )?8G5F+C             "7V)U9BXQ       &    !%]?7T143U)?3$E3X
  261. M5%]?      $(    !%]?7T-43U)?3$E35%]?      $0     E]3>7-"87-EX
  262. M   !&     -?<WES7VYE<G(       $<     E]$3U-"87-E   !(     -?X
  263. M:7AE;75L8F%S90    $D     E]?8W1Y<&5?   !*     )?7U]S1@      X
  264. M 2P    "7V5R<FYO      $P     E]?96YD       !4     %?96YD   !X
  265. )4         /RX
  266.  X
  267. end
  268. ---------------------cut-----------------------cut------------------
  269.  
  270. 2.4 Starting the Transfer
  271.  
  272. In the following a collection of modifications to the transfer program
  273. on the VIC side is given:
  274.  
  275. 2.4.1 8K Autostart module
  276.  
  277.   no modification needed
  278.  
  279. 2.4.2 16K Autostart module
  280.  
  281.   Transfer the A000 block without modification
  282.  
  283.   Find out where the second 8K block is located in memory, the
  284.   following addresses are possible:
  285.  
  286.   $2000    (/CS wired with /BLK1) -> POKE START+30,32
  287.   $4000 (/CS wired with /BLK2) -> POKE START+30,64
  288.   $6000 (/CS wired with /BLK3) -> POKE START+30,96
  289.  
  290.   Transfer second block
  291.  
  292. 2.4.3 normal LOADable program
  293.  
  294.   POKE START+26,PEEK(43)
  295.   POKE START+30,PEEK(44)
  296.   POKE START+34,PEEK(46)-PEEK(44)+1  (should be enough)
  297.  
  298.   Transfer program
  299.  
  300.   Cut down the program on your host computer to the right length:
  301.  
  302.   (PEEK(46)-PEEK(44))*256+PEEK(45)-PEEK(43)
  303.  
  304.   this can be done, for example, with the command 'head -c length'.
  305.   
  306.  
  307. 3.  Burning ROM modules into EPROMS
  308.  
  309. This can be done with a normal EPROM programmer, all sorts of EPROMs
  310. should be fast enough for the VIC. You can burn several Modules into
  311. one EPROM and switch between them with the upper address lines.
  312.  
  313. 4.  Starting EPROM modules
  314.  
  315. EPROM modules are autostart modules which means that they should start
  316. immediately after turning on your VIC. But there are some modules
  317. which don't have the neccessary autostart id at the beginning.  These
  318. modules must be started with a SYS call.
  319.  
  320. 5. Modifying the 3K Super Expander for use with EPROMS
  321.  
  322. [text is not yet completed]
  323.  
  324. 6. Loading Rom Modules from Disk
  325.  
  326. To load the modules from disk you have to do some modification to the
  327. file.  The command LOAD"file",8,1 loads the file to an absolute
  328. location, but the information where the file is located is missing in
  329. the files from the ftp server. The load address simply consists of two
  330. bytes at the beginning of the file, in LOW-HIGH order. To load a file
  331. to the address $A000, you have to prepend the bytes $00 $A0 to the
  332. file.In UNIX this is done with the lines:
  333.  
  334.     printf '\x0\xA0' >file.out    # LoadAdr: L/H
  335.     cat file.in >>file.out        # append file
  336.  
  337. If you want to add the address with the VIC, you can use this BASIC
  338. program:
  339.  
  340.     5  S=8192                : REM length: 8K
  341.     10 OPEN 1,8,0,"INFILE" 
  342.     20 FOR I=0 TO S-1
  343.     30 GET #1,A$
  344.     40 POKE 40960+i,ASC(A$)  : REM  use $A000 as temporary RAM
  345.     50 NEXT
  346.     60 CLOSE 1
  347.     70 OPEN 1,8,1,"OUTFILE"
  348.     80 PRINT #1,CHR$(0)
  349.     90 PRINT #1,CHR$(160)
  350.     100 FOR I=0 TO S-1
  351.     110 PRINT #1,CHR$(PEEK(I+40960))
  352.     120 NEXT
  353.     130 CLOSE 1
  354.  
  355. 7. [...]
  356.  
  357. Please report spelling and programming bugs.
  358. More info and new programs welcome...
  359.  
  360. Have fun,
  361.  
  362.    Andreas Heitmann  (heitmann@crunch.ikp.physik.th-darmstadt.de)
  363.  
  364.