[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Translation of Cracking Lesson 19, was Re: Toy Shop for Apple II available and a long story



Here are sections 4 and 5. I will probably finish the rest of the document
later, and I will put it on Mac GUI Vault as well as Asimov as a plain text
file.


===============================================================================
4. Booting (EXAMPLE : AIRHEART) and the 18-sector reading/writing routines
===============================================================================

Let's follow the booting of Airheart, booting as I will show in an example
here, but anything could change, anything will change, and - one more time -
this is only one more thing to this lesson, and will not be very important,
because at the end of this lesson, you will get a copier for the 18 data
sector protection of the original disk.

Here we are, then, the example of how Airheart boots.
The program successively loaded 3 reading/writing routines:

- The first at $D000, is a read routine that is used by boot 2 (load only)
- The second is part of Gustafsson's Disk Operating System ($0400-09FF), and
is addressed by a vector at $040F.
- The third, which is this time a suitable reading/writing routine, is
loaded into $4E00 (Airheart) at the moment of reading the records.

On Wings of Fury, this rwts was included at another address, but it was the
same as we shall see, at least close enough, the same routine.
It is saved in the disk catalog under the name "RWTS18". Also included on
the disk is the routine taken from Airheart, named "RWTS AIRHEART".

After this little discussion about booting, here is the main subject:

_____________________________________________________________________________
!                                                                           
!
! THE LIST OF RWTS18 COMMANDS                                               
!
! -----------------------------------                                       
!
!                                                                           
!
! The disk access routine is found in $4E00. I named it RdDisk, because this
!
! address can change according to the program. This I will see later.       
!
!                                                                           
!
! The programming syntax follows : JSR RdDisk, followed by a command byte   
!
! and  0 to 18 bytes having parameters for that command, these paremeters   
!
! will be listed.                                                           
!
!                                                                           
!
! 3 zero-page addresses are modified on each disk access, also, if they     
!
! are important in your program, you should copy them into three other      
!
! locations before accessing the disk. They are :                           
!
!                                                                           
!
! $FD Drive slot number * $10. (usually $60 for slot 6)                     
!
! $FE Track number where the drive head must go.                            
!
! $FF Physical track number times 2, where the drive head is located        
!
!                                                                           
!
! Here now is the list of disk commands, followed by the number of          
!
! necessary parameters, and all relevant details concerning the command and 
!
! its parameters.                                                           
!
!                                                                           
!
! Command 00 (2 parameters)                                                 
!
! -----------                                                               
!
! Start the motor.                                                          
!
! Parameter P1 : Drive (always 01)                                          
!
! Parameter P2 : Delay (often 0A)                                           
!
!                                                                           
!
! Command 01 (No parameter needed)                                          
!
! -----------                                                               
!
! Stop the motor                                                            
!
!                                                                           
!
! Command 02 (2 parameters)                                                 
!
! -----------                                                               
!
! Read head movement (seekabs).                                             
!
! Parameter P1 : 00 _ No control of the actual track. The movement assumes  
!
!                     you are on the track whose number                     
!
!		      is stored in $FF. (multiplied by 2)                     !
!                FF _ Read a field address on the actualy track to find
where !
!                     the disk head is, and to confirm that the head is     
!
!                     actually on the desired track.                        
!
! Parameter P2 : Track number to reach.                                     
!
!                                                                           
!
! Command 03 (1 parameter)                                                  
!
! -----------                                                               
!
! Sequential read of a track.                                               
!
! Parameter P1 : Memory page number at which to begin loading               
!
! ($20 will commence loading at $2000).                                     
!
!                                                                           
!
! Command 04 (18 parameters)                                                
!
! -----------                                                               
!
! Read only selected sectors from a track.                                  
!
! Parameters P1 to P18 : Numbers of memory pages to store.                  
!
! The 00 values are changed to $CF, that is to say that the loading happens 
!
! in ROM : nothing happens!. (It is not possible to load directly in to     
!
! page 0, because it contains all the parameters for actual/destination     
!
! track..). If you would like to load data into page 0, you must load       
!
! and then move the data (cf lesson 12) in $00,X.                           
!
!                                                                           
!
! Command 05 (1 parameter)                                                  
!
! -----------                                                               
!
! Read (analogous to command 03)                                            
!
!                                                                           
!
! Command 06 (18 parameters)                                                
!
! -----------                                                               
!
! Read (analogous to command 04)                                            
!
!                                                                           
!
! The options                                                               
!
! -----------                                                               
!
! For commands 03 to 06, bits 6 and 7 of the command byte are               
!
! significant. If bit 6 is set, $FE will be incremented to the end of the   
!
! read. The next read will automatically be on the following track.         
!
! If bit 7 is set, the read will be repeated until an error is              
!
! detected during the disk access. (with a lovely loud beep to say "I shall 
!
! try again").                                                              
!
!                                                                           
!
! Exemple : JSR RdDisk                                                      
!
!           HEX C3                                                          
!
!           HEX 20                                                          
!
!                                                                           
!
! This routine reads the track whose number is in $FE, by moving the read   
!
! head to this track if it is not already on the track,                     
!
! and load the data from this track to $2000. The operation is repeated
until !
! there is a disk access error, and $FE, the track number, is               
!
! incremented at the end of reading. At this time, the rest of the program  
!
! below the JSR continues execution, just after the parameters.             
!
!_____________________________________________________________________________!


PROGRAM TO READ A TRACK

HERE IS A PROGRAM WHICH ALLOWS ONE TO READ ANY TRACK FROM THE AIRHEART
DISKETTE (EXCEPT FOR TRACKS 00 AND 1C) TO ADDRESSES 2000.31FF. ONE CAN THEN
(AND I HAVE DONE SO) COPY THE ENTIRE DISKETTE IN THE FORM OF BINARY FILES.
THE REST IS NOT MUCH MORE THAN A QUESTION OF PATIENCE!

0300-   A2 00                   LDX #$00
0302-   B5 00           LOOP1 LDA $00,X       ;SAVE PAGE 0
0304-   9D 00 1F                STA $1F00,X     ;IN PAGE $1F
0307-   E8                      INX
0308-   D0 F8                   BNE LOOP1
030A-   A9 60                   LDA #$60
030C-   85 FD                   STA $FD
030E-   20 00 4E                JSR RdDisk      ;START MOTOR
0311-   00                      BYT $00
0312-   01                      BYT $01         ;DRIVE 1
0313-   00                      BYT $00
0314-   A9 A0                   LDA #$A0        ;RECALIBRATE THE HEAD
0316-   85 FF                   STA $FF         ;TO TRACK 0
0318-   A9 00                   LDA #$00
031A-   20 E3 50                JSR $50E3
031D-   A9 00                   LDA #$00
031F-   85 FF                   STA $FF
0321-   20 00 4E                JSR RdDisk      ;MOVE THE HEAD
0324-   02                      BYT $02         ;TO PISTE 1
0325-   00                      BYT $00
0326-   01                      BYT $01
0327-   AD 80 03                LDA $0380       ;NUM. OF TRACK IN $0380
032A-   8D 3C 03                STA TRACK
032D-   C9 15                   CMP #$15
032F-   90 06                   BCC INF15
0331-   20 00 4E                JSR RdDisk      ;IF TRACK TO READ >= $15
0334-   02                      BYT $02         ;THEN MOVE THE HEAD
0335-   FF                      BYT $FF         ;TO TRACK $19
0336-   19                      BYT $19
0337-   20 00 4E        INF15   JSR RdDisk      ;POSITION THE HEAD
033A-   02                      BYT $02
033B-   FF                      BYT $FF
033C-   01              TRACK   BYT $01
033D-   20 00 4E                JSR RdDisk      ;READING
0340-   C3                      BYT $C3         ;OF A TRACK
0341-   20                      BYT $20         ;FROM ADDRESSES $2000.31FF
0342-   20 00 4E                JSR RdDisk      ;STOP MOTOR
0345-   01                      BYT $01
0346-   A2 00                   LDX #$00        ;RESTORE PAGE 0
0348-   BD 00 1F        LOOP2 LDA $1F00,X
034B-   95 00                   STA $00,X
034D-   E8                      INX
034E-   DO F8                   BNE LOOP2
0350-   60                      RTS

To start this program, it is sufficient to do :

]BLOAD RWTS AIRHEART,A$4E00                     ; load rwts
]BLOAD LECTURE PISTE AIRHEART,A$300             ; and bload track
]POKE 896,<NUMERO DE PISTE>                     ; and place Airheart in
drive 1
]CALL 768                                       ; the track loads..

===============================================================================
5. PROGRAMS TO COPY 18 SECTORS PER TRACK          By numero6, Mr.DD, Gog's,
Gdf
===============================================================================

Many disk copy programs are developed from the rwts routine from Gustaffson.
For now, there are only two programs included in this lesson. But really,
they are nearly redundant.

The first one I know of is made by Numéro 6 for Toy Shop, which was adapted
a bit later after Where in the world is Carmen SanDiego?. The second came
about in mid-April by the acs and myself, for Wings of Fury.

I am not going to tell too much in this section of the text, because these
programs are already made - and the source code is on the same disk! - and
the rwts18 commands used by these two copiers was just recently reviewed. It
will be sufficient for your know-how merely to boot Merlin, then load the
file "GOGSMITH".

We will later look at the problems that can give us some more information
about this protection scheme, and also the "how to adapt this gogsmith to
other Br0derbund programs".

-- 
]DF$
Mac GUI Vault - A source for retro Apple II and
Macintosh computing.
http://macgui.com/vault/