[comp.sys.apple] ProDOS patch

patth@dasys1.UUCP (Patt Haring) (07/29/87)

NEW
CLEAR
HOME
10 REM Stop ProDOS track 0 trashing
20 REM  patches by Stephen Thomas
30 REM       MacLagan Wright & Associates
40 REM       West Heidelberg, VIC Australia

100 TEXT : HOME: D$=CHR$(4):E=0
110 VTAB 12:? "Now patching ProDOS."
120 ONERR GOTO 500
130 IF PEEK (116)<96 THEN E=1:GOTO 500: REM Make sure there's room
140 PRINT D$;"UNLOCK PRODOS"
150 PRINT D$;"BLOAD PRODOS,A$2000,TSYS"

200 FOR ADR=22211 TO 22220 STEP 3 : REM Change four STAs to LDAs
210 :IF PEEK(ADR)=189 THEN E=2:GOTO 500
220 :IF PEEK(ADR)<>157 THEN E=3:GOTO 500
230 :POKE ADR,189
240 NEXT

300 ADR=20484:V(0)=189:V(1)=142:V(2)=192:REM Chg NOPs to LDA $C08E,X
310 FOR I=0 TO 2
320 :IF PEEK(ADR+I)<>234 THEN E=3:GOTO 500
330 :POKE ADR+I,V(I)
340 NEXT

400 PRINT D$;"BSAVE PRODOS,A$2000,TSYS"
410 PRINT:PRINT"Patches completed."
420 END

500 PRINT CHR$(7);"ERROR!! No patches were made."
510 ON E GOTO 530,540,550
520 ?"ProDOS file not found.":END
530 ?"File has already been patched.":END
540 ?"This version of ProDOS is not 1.1.1."
SAVE PATCHER.MCT
HOME
?"All done, the file has been"
?"EXECed and saved as 'PATCHER.MCT'."
?"The machine is now yours to"
?"do with as you please"
---------------------- cut here -----------------------

-- 
Patt Haring                       UUCP:    ..cmcl2!phri!dasys1!patth
Big Electric Cat                  Compu$erve: 76566,2510
New York, NY, USA                 MCI Mail: 306-1255;  GEnie:  PATTH

kamath@reed.UUCP (Sean Kamath) (08/06/87)

Here's the BASIC program to patch ProDOS v1.1.1-1.4  I only tested it on
v 1.1.1 and 1.2, and it worked. (otherwise I wouldn't have posted it!)

BTW.  If you want, you can put a 'P' to indicate this version of Prodos
has been patched.  Just look for "PRODOS" in the file and after the
version number change a space to a P.  For v1.1.1 

poke 9463,208

(assuming a load at $2000)

This was packed with EXECUTIONER.  It is shorter this way than 6 bit
packing.

-----cut here----cute here---cut here----cute here---cut here----

NEW
10REM ProDOS patch program.
20REM patches vers. 1.1.1 to 1.4
30REM from Apple Assembly Line, May, 1987
40REM V7,#8
100TEXT:HOME:E=0:?"PRODOS PATCH PROGRAM"
110IFPEEK(116)<128THENE=1:GOTO900:REM enuf mem?
120ONERRGOTO900
130REM ----Read ProDOS file----
140?CHR$(4)"UNLOCK PRODOS"
150?CHR$(4)"BLOAD PRODOS,TSYS,A$2000"
200REM ----Search $4000-$60FF for pattern----
210V=1:FORB=64TO96:A=B*256
220IFPEEK(A+4)<>189THEN250
230IFPEEK(A+5)<>156THEN290
240IFPEEK(A+6)=192THENV=3:B=96:GOTO290:REM  Version 1.4
250IFPEEK(A+4)<>234THEN290
260IFPEEK(A+5)<>234ORPEEK(A+6)<>234THEN290
270IFPEEK(A+7)<>234ORPEEK(A+8)<>234THEN290
280V=2:B=96:REM Version before 1.4
290NEXTB:E=2:ONVGOTO900,300,700
300REM ----Found version before 1.4----
310POKEA+4,189:POKEA+5,142:POKEA+6,192:REM "LDA $C08E,X"
400REM ----Look for other patch area----
410A=PEEK(A+2)+256*PEEK(A+3)-13*4096+A+5
420E=3:IFA<4*4096ORA>6*4096THEN900
430IFPEEK(A)<>157ORPEEK(A+3)<>157THEN500
440IFPEEK(A+6)<>157ORPEEK(A+9)<>157THEN500
450REM ----Found version 1.1.1 or 1.2, so change "STA" to "LDA"----
460FORI=0TO9STEP3:POKEA+I,189:NEXTI
470V$="1.1.1":GOTO800
500REM ----Version 1.3----
510FORI=0TO12:READB:IFPEEK(A+I)<>BTHENGOTO900
520NEXTI:DATA 160,8,189,128,192,232,232,136,208,248,234,234,96
530FORI=0TO11:READB:POKEA+I,B:NEXTI
540DATA 189,128,192,189,130,192,189,132,192,189,134,192
550A=4*4096+12*256+12*16+13:REM Address = $4CCD
560FORI=0TO3:READB:IFPEEK(A+I)<>BTHEN900
570NEXTI:POKEA,240:REM Change "BRA" to "BEQ"
580V$="1.3":GOTO800
590DATA 128,6,190,0
700REM ----Version 1.4----
710POKEA+5,142:REM "LDA $C09C,X" to "LDA $C08E,X"
720V$="1.4"
800REM ----Write patched version on disk----
810?CHR$(4)"BSAVE PRODOS,TSYS,A$2000"
820?CHR$(4)"LOCK PRODOS"
830?"Patches completed to Version "V$:END
900REM ----Error handler----
910?CHR$(7)"Error! No patches were made."
915ONEGOTO930,940,950
920?"ProDOS File Not Found.":END
930?"Not enough room to load ProDOS.":END
940?"Patch location not found.":END
950?"ProDOS file may have been patched"
960?"already, or is not a compatible version."
970END
SAVE PPATCHER

-----cut here----cute here---cut here----cute here---cut here----

sean kamath

PS.  Do you folks really think this isn't a serious discussion group?
And Excell groups are?  Or people trading the latest DA that does screen
save?

People in this group at least ask questions because they are trying to
do something.  A major problem is that Apple, being a corp, has to
respect a machine that has $300 programs as an almost absolute must have
for it to be worthwhile.  At this point, most really good programs are
those you can modify for your own needs.  I like DCOM as much because it
is cheap and works well, as well as because I could easily write my own
driver for it.  Without contact from several people it would have been a
pain the the *ss.  *I* take this group seriously.  And if you don't, why
are you reading it?  For sh*ts and giggles?  I am a member of APDA.
They asked my why I hadn't bought anything from them.  I told them I
would as soon as something worthwhile came out from them.  I didn't join
APDA to get good rates on Ampersand Routines. . .  And with them there
is almost no interaction.  Not like there is here.

These are my long winded opinions, and I bet you couldn't hold your
breath long enough to mutter them yourself, so they are mine and only
mine. And I am not associated with anything but my cats. Well, Robin
too.

-- 
UUCP:  {decvax allegra ucbcad ucbvax hplabs ihnp4}!tektronix!reed!kamath
CSNET: reed!kamath@Tektronix.CSNET  ||  BITNET:  reed!kamath@Berkeley.BITNET
ARPA:  tektronix!reed!kamath@Berkeley <or> reed!kamath@hplabs
US Snail: 3934 SE Boise, Portland, OR  97202 (I hate 4 line .sigs!)

mat6013@DMZRZU71.BITNET (08/25/87)

This  weekend  I  took  a  detailed  look at the ProDOS patcher program posted
5/8/87  to find out the changes applied to the "PRODOS" system file (I'm using
version  1.2).  Adding the "LDA $C08C,X" makes sense to me, but *why* was "STA
$C08n,X" changed to "LDA $C08n,X" (n= 0, 2, 4, 6) ?  These are for turning off
the  four  windings  of  the  stepper  motor which is responsible for the head
seeking.  So what's the difference between a read and a write operation here ?
The best documentation I have about the softswitches of the disk ][ controller
is "Beneath Apple DOS"; it tells nothing about that.

                                        Matthias Kapffer
                                        <MAT6013@DMZRZU71.BITNET>

denbeste@bgsuvax.UUCP (William C. DenBesten) (08/26/87)

in article <8708241100.aa03291@SMOKE.BRL.ARPA>, mat6013@DMZRZU71.BITNET says:
>
> This weekend I took a detailed look at the ProDOS patcher program
> posted 5/8/87 to find out the changes applied to the "PRODOS" system
> file (I'm using version 1.2). Adding the "LDA $C08C,X" makes sense to
> me, but *why* was "STA $C08n,X" changed to "LDA $C08n,X" (n= 0, 2, 4,
> 6) ? These are for turning off the four windings of the stepper motor
> which is responsible for the head seeking. So what's the difference
> between a read and a write operation here ?

This is because of a imperfection in the way that a STA works on the
6502s.  When the STA is executed, the effective address is put on the
address bus TWICE.  The first time, the location is read.  The second
time, the location is written.

This is most noticable when accessing the speaker.  The flip-flop the
drives the speaker toggles twice, and the speaker cone doesn't move,
so no sound is generated.

In terms of a stepper motor, I don't see that it makes any difference,
but better safe than sorry.

The end result is that it is better to access soft switches with a LDA
rather than a STA.

kamath@reed.UUCP (Sean Kamath) (08/27/87)

In article <8708241100.aa03291@SMOKE.BRL.ARPA> mat6013@DMZRZU71.BITNET writes:
>version  1.2).  Adding the "LDA $C08C,X" makes sense to me, but *why* was "STA
>$C08n,X" changed to "LDA $C08n,X" (n= 0, 2, 4, 6) ?  These are for turning off
>the  four  windings  of  the  stepper  motor which is responsible for the head
>seeking.  So what's the difference between a read and a write operation here ?
>                                        Matthias Kapffer

Generally speakeing, when doing things with the drive, it is safer to do
LDA's than STA's.  I con't remember exactly why they put in the LDA's on the
steppers, but it seams to me that _that_ is what really does the crashing on
5.25 disks.  I'll post a more detailed explanaition soon.

Sean

-- 
UUCP:  {decvax allegra ucbcad ucbvax hplabs ihnp4}!tektronix!reed!kamath
CSNET: reed!kamath@Tektronix.CSNET  ||  BITNET:  reed!kamath@Berkeley.BITNET
ARPA:  tektronix!reed!kamath@Berkeley <or> reed!kamath@hplabs
US Snail: 3934 SE Boise, Portland, OR  97202 (I hate 4 line .sigs!)

hayes@thor.ucsd.edu (James Hayes) (08/27/87)

mat6013@DMZRZU71.BITNET writes in article <8708241100.aa03291@SMOKE.BRL.ARPA>:

>This  weekend  I  took  a  detailed  look at the ProDOS patcher program posted
>5/8/87  to find out the changes applied to the "PRODOS" system file (I'm using
>version  1.2).  Adding the "LDA $C08C,X" makes sense to me, but *why* was "STA
>$C08n,X" changed to "LDA $C08n,X" (n= 0, 2, 4, 6) ?  These are for turning off
>the  four  windings  of  the  stepper  motor which is responsible for the head
>seeking.  So what's the difference between a read and a write operation here ?
>The best documentation I have about the softswitches of the disk ][ controller
>is "Beneath Apple DOS"; it tells nothing about that.
>
>                                        Matthias Kapffer
>                                        <MAT6013@DMZRZU71.BITNET>

I don't know about the 6502's offspring, but a memory "write" reads the location
before it writes the new value.  If you have memory mapped I/O this can raise
hell with it.
                                                    _
If the harware decodes just the address and not the R/W line, it will see two
references when the 6502 does a write, and one when it does a read.  The
external strobe on the game port demonstrates this problem.  Write to it and
you get two pulses about a uSec apart.  Read from it and you get one pulse.

Anybody know if this has been fixed?


Jim Hayes, University of California at San Diego.

BITNET: hayes%sdcsvax@WISCVM.BITNET
ARPA:	hayes@sdcsvax.ucsd.edu
UUCP:   {pick one close to berkeley}!sdcsvax!hayes