[comp.sys.amiga] Playing around inside Kickstart

kim@amdahl.amdahl.com (Kim DeVaughn) (10/04/87)

[ ... go ahead, eat my bits ... ]

Attached is a shar of some interesting info for anyone who'd like to fool
around with Kickstart.  The "patching.kick" file came from the AmigaWest
BBS, and the "sumkick" program was taken off of the JC BBS.  Both of these
are in the Bay Area.

/kim




# This is a shell archive.  Remove anything before this line, then
# unpack it by saving it in a file and typing "sh file".  (Files
# unpacked will be owned by you and have default permissions.)
#
# This archive contains:
# patching.kick SumKick.uue README.SUM

echo x - patching.kick
cat > "patching.kick" << '//E*O*F patching.kick//'
This file discribes how to modify kickstart to automatically "ADDMEM" on
boot up, and how to change the upside down hand to any graphics you want.

Also included in this file is the text of a message I posted some time ago
discribing how to patch WACK to allow you to redirect output anywhere,
such as a printer or disk file - super valuable for hacking. I hope this
text informs and encourages you to have some fun of your own. Too many
people have forgotten what computers really are - the world's greatest
toy!!! On with it...


Patching kickstart:

The first question to answer is "Where do I put my patch?". One good spot
is the place where the upside down hand is drawn, which is where I've
put the "ADDMEM" patch. The second question is "How do I send the bootup
routines to my code?". I have chosen to modify a pointer in the device
driver-type structure at the beginning of the "strap" routine. How did
I find out about "strap"? You type "mods" in the 1.0 version of WACK and
it gives you a list of devices,resouces,and that kind of stuff. "strap"
is the code that boots a "workbench" type of disk and displays the
upside down hand. The address that WACK V1.0 gives you is the address of
a "rom tag". A "rom tag" is a fancy name that means a bunch of data. The
format of the data is found in the documentation of the skeleton device
driver in the ROM KERNAL MANUAL VOLUME 2, near the very back. The pointer
we are going to change is called "RT_INIT". It's a pointer to the "strap"
routine. The pointer, located at address $FE889A normally contains
$FE88D6. We'll change it to $FE8CFE, the part of kickstart that displays
the upside down hand. I'll take about the display routine in detail
later. Now we need code to put at $FE8CF8. Fortunately, V1.2 of kickstart
added a very convenient command to add memory. Here's a routine to do it:

 JMP $FE8D6A ;SKIP OVER THIS PATCH (SO IT WILL ONLY BE RUN ONCE)
 MOVEM.L D0/D1/D2/A0/A1/A6,-(A7)
 MOVE.L 4,A6
 MOVE.L #NUMBER OF BYTES TO ADD,D0
 MOVE.L #$10005,D1 ; ADD "FAST" MEMORY
 MOVEQ #0,D2
 MOVE.L #$ADDRESS OF EXTRA MEMORY,A0
 SUB.L A1,A1
 JSR -618(A6)
 MOVEM.L (A7)+,D0/D1/D2/A0/A1/A6
 JMP $FE88D6 ;GO TO THE NORMAL "STRAP" PROGRAM. OUR PART IS FINISHED.

Simple eh? IMPORTANT NOTE!!!:
If you have done the AMAZING COMPUTING 512K upgrade and did the 2 chip
fix which disables the RAM so it won't be allocated as chip RAM....
you must add a few lines of code to enable the RAM BEFORE you do the
add!!!! A few lines like this:

 BCLR #7,$BFD100 ;TURN ON MOTOR
 BSET #3,$BFD100
 BCLR #3,$BFD100
 BSET #7,$BFD100 ;TURN OFF MOTOR
 BSET #3,$BFD100
 BCLR #3,$BFD100

The changes can be made fairly easily using DISKZAP. Here are the sector
numbers: (I think the byte numbers are right, but double check me!
That goes for all the numbers I give in this file.)

The pointer: SECTOR $145, BYTE $9A
The display hand patch code: SECTOR $147, BYTE $F8

***********************************************************************
******** NOW FOR THE REALLY FUN PART!!!!!
******** AMAZE YOUR FRIENDS WITH A CUSTOM BIT MAP WHERE THE
******** "INSERT WORKBENCH" SCREEN USED TO BE (BEFORE YOU MODIFIED
******** IT USING THE INFORMATION BELOW)
***********************************************************************

THE DISPLAY HAND ROUTINE IN DETAIL:
This is the routine that is called when you boot (or reset) and have a
disk in the drive that is not a bootable disk (or no disk at all).
The infamous "upside down hand" routine.
It uses a combination of line drawing and straight bit maps to optimize
memory use. The hand and the disk are made by drawing lines and doing area
fills. The text - "Work Bench", "V1.2" - is made using straight bit maps.
Because the routine is table driven, modifying the display is easy.
All you have to know is the format of the tables. Since the AUTO-ADDMEM
fix discribed above uses the line draw portion for space, I will talk
about the bit map part. First, load up DPAINT and create a picture, any
picture, as long as it isn't too big. USE THE ONE COLOR MODE!
 Before you get a feel for how much
room you have, keep it very small. Save it as a brush, so it won't be saved
in a compressed format. Now you need to know the format of the bit map in
"strap":

The first byte determines whether or not this is the last display
sequence. If the high bit is set, the routine exits. The second byte
is a bit plane mask, determining which bit planes may be written to.
If this is $FF, then all bit planes are writable. Which ones are actually
written to depend on which color register was defined as the "pen". In
this case, color register 3 was chosen. This means that, assuming all bit
planes are enabled, bit planes 1 and 2 will be written in with ones,
selecting color register 3, just like we asked. If however, we set the
mask to 2, only bit plane 2 will be written in, and so we will actually
be displaying color register 2. If we put a 1 in, color 1 is displayed, and
if 0 is there, nothing is displayed (not real useful). Nothing mysterious
there. The third and forth bytes are the dimensions of the thing we are
displaying, the third byte being the width and the forth the height.
The fifth and sixth bytes are the coordinates to place the picture, first
X, then Y. After that is the actual data.

"Where do I get the 'actual data'?"

We examine that DPAINT file you created. Type "TYPE FILENAME OPT H",
where "FILENAME" is the name of your picture. You should see a bunch of
hexadecimal numbers and ASCII text to the right. Notice "ILBMHMHD".
After that notice 4 bytes which are of no use to us. Continue and note
that you find the width and height as 1 word each next to each other
in a convienient hex form. Write them down so we know them later. Next find
"BODY" and notice the size in bytes following it. I hope that number
isn't larger than about $190!! If it is, scale back a bit. Now the
nasty part: copy down all those strange looking numbers following the
size. This is another reason to keep the picture small!!! As mentioned
before, your picture can be displayed in any of 3 color registers.
You can define the color registers to be anything you want. Just
locate sector $146 and find the byte sequence that is as follows:
0FFF0000077C0BBB. They are the first 4 color registers. Place your picture
in the format discribed above at sector $148, byte $1B8 (or whereever you
see "00010408...")

For those of you who have been busily skipping over all of the above and
just want an example, here it is:

00            01        04     08      55 66              0123456787898...
more to come  color #1  width  height  X & Y destination  your picture
(FF-the end)

There is no limit to what kinds of things you can create except how
many bytes you can find!! I personally have a simple white on black
"INSERT DOS", but you could get really elaborate. For example, you
could write a custom routine to draw a circle with a line through it and
the letters S and T in the center. BE CREATIVE!!! HAVE FUN!!!

NOTE: THIS NEXT ONE IS SUPER USEFUL FOR TEARING APART ROM ROUTINES
(AND OTHER THINGS)

Patching WACK V1.004:

For those who are interested, I patched WACK so that you can redirect
output anywhere, such as a printer or disk file (defaults to AmigaDOS
window)...best of all, this can be done by CHANGING ONLY 3 BYTES!!!!!!!!

Here it is: (assumes V1.004 of WACK)

1) From FILEZAP, go to record #178, change 2nd "23c2" to "6004"
2) Go to record 274 (maybe 275), find "660e2f3900000014". Change the
"14" to "10".
3) ENJOY!!! (you will also want to change the "raw:..." text so the
window is less bothersome)

Here's why it works:

WACK automatically calls INPUT and OUTPUT, but later overwrites them
both with the filehandle returned from the opening of the "RAW:" window.
The "6004" is a BRA.S *+4 which skips over the writing to _STDOUT.
Why WACK does this is a mystery; I guess it was written in a funky
language like "C". The "10" change causes WACK to send _STDIN to
CLOSE instead of _STDOUT, so the "RAW:" window disappears.

One more thing:
If anyone knows a better way of hacking files than FILEZAP, please let
me know.


CONCLUDING NOTE:

THERE ARE THOUSANDS OF OTHER NEAT INSIGHTS INTO KICKSTART TO BE MADE,
PATCHES TO BE DONE. UNFORTUNATELY, COMMODORE DOESN'T PUBLISH SOURCE
CODE (AND THUS FORFEITS MILLIONS IN POTENTIAL PROFITS) FOR SOME
REASON. THIS IS ONE "WHY" NO ONE CAN ANSWER, NOT EVEN THE PEOPLE WHO
HAD THIS BRILLIANT IDEA.

              ********* BUT *********

IF ALL THE TECHNICALLY ORIENTED PEOPLE OUT THERE WOULD DO THEIR SHARE
AND HELP DOCUMENT SOME OF KICKSTART, ESPECIALLY THE BOOT UP CODE AND
AMIGADOS, THE PROCESS WOULD BE VERY QUICK AND PAINLESS. AND WE WOULD
ALL BENEFIT.

-- Dan Babcock, user OPS239. If you ever have any questions at any time,
just send me a message and I will try to answer.

//E*O*F patching.kick//

echo x - SumKick.uue
cat > "SumKick.uue" << '//E*O*F SumKick.uue//'

begin 755 SumKick
M```#\P`````````-``````````Q```!Q0```;D```,M```!E0```"D```!1`\
M```(0```!4```#E````+0```(4````]````W0``#Z0```'$CSP```"`CP```*
M`"0CR````"A"N0````PL>0````0CS@````23R4ZN_MHH0$JL`*QG``"H80`!'
M;"!L`*S1R-'((&@`$-'(T<A(YR`P1?D```"L1_D````L=`%P`!`8)LI@`A38`
M4<C__$(:(#D````D('D````H$AA3@&\>#`$`(&_T4H(FRF`*$AA3@`P!`"!O/
M!!3!8/)"&F#<0AI"FR`"3-\,!$AY````+"\`3KD````<(\`````43KD````L"
M(\`````8(\`````<3KD`````<``N>0```"!.=6$``,9A``"P(\`````,0J<OZ
M`"1`("H`)&<0+'D````(($`B*```3J[_@B(J`"!G*"0\```#[4ZN_^(CP```H
M`!0CP````!@CP````!QG"N6(($`I:``(`*1.N0````!P`&`$("\`!"YY````>
M("\`+'D````$(#D````(9P(B0$ZN_F)*N0````QG#DZN_WPB>0````Q.KOZ&B
M(!].=4CG`08N/``#@`<L>``$3J[_E$S?8(!P9&"P0>P`7$ZN_H!![`!<3J[^8
MC$YU0KD````(0_D```&L(#P````A3J[]V"/`````"&>V3G4``````^P````:=
M`````0```;H```&J```!I````6H```%>```!4````4(```$B```!'````18`!
M``#V````Y````-0```#&````P````+0```"F````<@```&P```!4````3@``.
M`"`````4````#@````@````"`````@````(```$T````S`````(````+````>
MK@```+H````````#\D```^H```!N``$`````````````````````````````Y
M`````````````````````````````````````````````````````````````
M`````````````````````````````````````````````````````````````
M`````````````````````````````````````````````````````````````
M`````````````````````````````````````````````````````````````
M`````````````````````````````````````````````````````````````
M`````````````````````````````````````````````````````````````
M`````````````````````````````````````````````````````````````
M`````````````````````````````````````````````````````````````
M``````````````````````````````````````````````````````````!DD
M;W,N;&EB<F%R>0````/R0``#Z0```,M.5?_B<`!";?_J*T#_[`RM`````@`(6
M;1`B;0`,(&D`!!`0#```/V882'D`````3KD`````6(]"ITZY```!/%B/#*T`*
M```!``AO&B)M``P@:0`$5(@0$$B`2,`$@````#`K0/_L#*T````"``AO(")MQ
M``P@:0`($!`,```M9A!2B!`0#```9F8&.WP``?_J2'D````Q3KD`````6(](-
M>0```%].N0````!8CW``+P`O`$ZY`````%"/+P`K0/_F3KD`````6(]"IR\`_
M+RW_[$AY````ARM`_^).N0```)1/[P`0*T#_\$J`9@`"#G`"+P`O/``$``!.\
MN0````!0CRM`__1*@&<``=8@;?_B,7P``@`<(4``*"%\```"```D0J@`+"\(0
M3KD```#(6(\@;?_T#)!+24-+9@`!:DAY````F$ZY`````%B/(&W_XC%\``(`I
M'"%M__0`*"%\``0````D(7P```(``"PO"$ZY````R%B/2'D```"M3KD`````W
M6(\@;?_TT?P``__H*U#__"\\``#_^B\M__1.N0````!0CR!M__31_``#_^QR:
M!2\!+P@K0/_X3KD`````4(]2@-&M__@O+?_X+RW__$AY````M$ZY`````$_O?
M``P,;0`!_^IF``#.("W__+"M__AG``#"2'D```#63KD`````6(\@;?_B,7P`(
M`@`<(6W_]``H(7P```(``"0A?``$````+"\(3KD```#(6(\@;?_T(6W_^`'HR
M(&W_XC%\``,`'"%M__0`*"%\```"```D(7P`!````"PO"$ZY````R%B/(&W_L
MXC%\``0`'"\(3KD```#(6(\@;?_B$"@`'TB`2,!*@&<2+P!(>0```/-.N0``>
M``!0CV`>2'D```#^3KD`````6(]@#DAY```!!4ZY`````%B/(&W_XC%\``D`1
M'$*H`"0O"$ZY````R%B/+SP`!```+RW_]$ZY````&%"/8`Y(>0```35.N0``_
M``!8CR\M_^).N0```+18CV`.2'D```%G3KD`````6(\O+?_B3KD````86(\O]
M+?_F3KD```"<6(]"ITZY```!/%B/3EU.=0```^P````"`````````R(````ZN
M````#0````,```+Z```"W@```J0```*4```"A````?(```',```!=````3P`@
M``#0````G@```)`````J`````@````0```&V```!F@````P````&```#````5
M`N0```*J```"F@```HH```'X```!T@```7H```%"````I````)8````P````N
M`@````@```,8````L@````(````)```##````,`````*````#````O````+4/
M```"P@```FH```)6```"(@```6P```$F````^````-H````````#\D```^H`T
M``!E55-!1T4Z(%-U;4MI8VL@6T1&,#I\1$8Q.GQ$1C(Z?$1&,SI=(%LM9BAIL
M>&ET*5T*`%-U;4MI8VL@+2!+:6-K4W1A<G0@1&ES:R!3=6T@(%8Q+C$@,C4MS
M36%Y+3@W"@!#;W!Y<FEG:'0@*$,I(#$Y.#<L(&)Y($)E;FIA;6EN($9U;&QEV
M<@H`=')A8VMD:7-K+F1E=FEC90!296%D:6YG($M)0TM35$%25"XN+@!$;VYET
M(0H`3VQD4W5M.B`P>"4M.&QX("!.97=3=6TZ(#!X)2TX;'@*`$9I>&EN9R!+8
M24-+4U1!4E0@0VAE8VM3=6TN+BX`17)R;W(C)6QX"@!$;VYE(0H`*BHJ($52(
M4D]2("HJ*B!.;W0@82!+24-+4U1!4E0@9&ES:R$@5')Y($%G86EN+@H`*BHJT
M($524D]2("HJ*B!.;W0@16YO=6=H($-(25`@365M;W)Y(2!4<GD@06=A:6XNJ
M"@`J*BH@15)23U(@*BHJ($)A9"!$<FEV92!4>7!E(2!4<GD@06=A:6XN"@``+
M``````/R0``#Z0````H@;P`$("\`"&$```1.=2(`0H#0F&0&!H`````!!($`_
M```!9NY&@$YU```#\D```^D````42.<`.BAO`!0@;P`8(F\`'$7Z`#I/[_]TE
M)D\L>0````1.KOWV</]*&U?(__Q&@&<2+P!(;P`$2%1.N0````!/[P`,3^\`/
MC$S?7`!.=1;`3G4```/L`````0````L````Z`````````_)```/I````""\"^
M)"\`"$AO``PO`B\Y````&$ZY`````$_O``PD'TYU```#[`````$````!````7
M#@````$````%````%`````````/R0``#Z0````4@;P`$((A8D$*H``0A2``(0
M3G4``````_)```/I````.4CG/R`H+P`@%B\`)R\\_____TZY````1"H`+`5T/
M_[2%6(]F!G``8```;B\\``$``4AX`").N0`````D0,^*2H?/BE"/9@XO!DZY5
M````6'``6(]@0B5$``H50P`)%7P`!``(0BH`#A5&``]"ITZY````,"5``!!*%
MA%B/9PPO"DZY````;%B/8`Q(:@`43KD`````6(\@"DS?!/Q.=4CG("`D;P`,W
M2JH`"F<*+PI.N0```(!8CQ5\`/\`"'3_)4(`%'0`%"H`#R\"3KD```!82'@`M
M(B\*3KD````83^\`#$S?!`1.=0```^P````!````!P```(X````(````#```3
M`#8````4````;@```,H```!*````@````*X```#6`````````_)```/I````Q
M"R\")"\`"$AX`#`O`DZY`````%"/)!].=2\")"\`""\"3KD```!(6(\D'TYU=
M```#[`````(````*````#@```"(````````#\D```^D````A2.<X`"0O`!`F=
M+P`42H)F!'``8"XO/``!``$O`TZY`````"!`R8A*A,F(4(]F!'``8!`1?``%H
M``@Q0P`2(4(`#B`(3-\`'$YU2.<P`"!O``S'B$J#QXAG```F$7P`_P`(=/\A+
M0@`4=/\A0@`8=``T*``2+P(O"$ZY````&%"/3-\`#$YU```#[`````(````,#
M````'@```'@````````#\D```^D````/2.<P`BQY````"$SO``X`$$ZN_]!,$
MWT`,3G4``"\.+'D````(3J[_RBQ?3G4O#BQY````"$ZN_\0L7TYU```#[```1
M``,````!````,````"`````&`````````_)```/I````-R\.+'D````$3.\`3
M`P`(3J[_.BQ?3G4``"\.+'D````$(F\`""`O``Q.KO\N+%].=2\.+'D````$%
M(F\`"$ZN_MHL7TYU+PXL>0````0@+P`(3J[^MBQ?3G4O#BQY````!"`O``A.!
MKOZP+%].=2\.+'D````$(F\`"$ZN_IXL7TYU+PXL>0````0B;P`(3J[^F"Q?K
M3G4O#BQY````!"!O``A,[P(!``PB+P`43J[^1"Q?3G4``"\.+'D````$(F\`R
M"$ZN_CXL7TYU+PXL>0````0B;P`(3J[^."Q?3G4```/L````"@````$```#,3
L````N````)@```"$````<````%P```!(````-````!P````$`````````_+,]
``
end
size 3824
//E*O*F SumKick.uue//

echo x - README.SUM
cat > "README.SUM" << '//E*O*F README.SUM//'
;
;	Introducing -- 'SumKick'!
;	============================================================
;	SumKick is a utility that allows you to fix the  checksum on
;	a KICKSTART disk that you have modified.  This allows you to
;	customize your  KICKSTART  disk.   This utility will work on
;	all versions of the KICKSTART disk.
;
;	USAGE:	SumKick [DF0:|DF1:|DF2:|DF3:] [-f(ixit)]
;
;	To use this utility insert a KICKSTART disk in any drive and
;	type:    SumKick DFx: -f      where 'x' is the drive number.
;	Make sure the disk is write enabled or the checksum will not
;	be updated.
;
;	NOTICE: This program is Copyright (C) 1987, Benjamin Fuller.
;		You are free to use this utility for  non-commercial
;		purposes only!    This utility can be distributed on
;		electronic bulletin board systems  or  public domain
;		disks with the restriction that this message remains
;		a  part  of the  utility.   The  author retains  all
;		commercial rights to this utility.            Enjoy!
//E*O*F README.SUM//

echo Possible errors detected by \'wc\' [hopefully none]:
temp=/tmp/shar$$
trap "rm -f $temp; exit" 0 1 2 3 15
cat > $temp <<\!!!
    185   1564   8809 patching.kick
     90     92   5391 SumKick.uue
     22    160    978 README.SUM
    297   1816  15178 total
!!!
wc  patching.kick SumKick.uue README.SUM | sed 's=[^ ]*/==' | diff -b $temp -
exit 0

-- 
UUCP:  kim@amdahl.amdahl.com
  or:  {sun,decwrl,hplabs,pyramid,ihnp4,uunet,oliveb,cbosgd,ames}!amdahl!kim
DDD:   408-746-8462
USPS:  Amdahl Corp.  M/S 249,  1250 E. Arques Av,  Sunnyvale, CA 94086
CIS:   76535,25

andy@cbmvax.UUCP (Andy Finkel) (10/09/87)

In article <15590@amdahl.amdahl.com> kim@amdahl.amdahl.com (Kim DeVaughn) writes:
>Patching WACK V1.004:
>
>For those who are interested, I patched WACK so that you can redirect
>output anywhere, such as a printer or disk file (defaults to AmigaDOS
>window)...best of all, this can be done by CHANGING ONLY 3 BYTES!!!!!!!!
>
>WACK automatically calls INPUT and OUTPUT, but later overwrites them
>both with the filehandle returned from the opening of the "RAW:" window.
>The "6004" is a BRA.S *+4 which skips over the writing to _STDOUT.
>Why WACK does this is a mystery; I guess it was written in a funky
>language like "C".

Ummm...it does funny things because it *already has* the ability to redirect
output.  

>THERE ARE THOUSANDS OF OTHER NEAT INSIGHTS INTO KICKSTART TO BE MADE,
>PATCHES TO BE DONE. UNFORTUNATELY, COMMODORE DOESN'T PUBLISH SOURCE
>CODE (AND THUS FORFEITS MILLIONS IN POTENTIAL PROFITS) FOR SOME
>REASON. THIS IS ONE "WHY" NO ONE CAN ANSWER, NOT EVEN THE PEOPLE WHO
>HAD THIS BRILLIANT IDEA.

Well, if you can tell me what the millions in potential profits are,
I'll be glad to listen.  Of course, if it it involves people sending
me 500,000 dollars in unmarked bills, I suspect that it wouldn't
be a good ide......actually, come to think of it *I* like this concept :-)

-- 
andy finkel		{ihnp4|seismo|allegra}!cbmvax!andy 
Commodore-Amiga, Inc.

"Interfere?  Of course we'll interfere.  Always do what you're best at,
 I always say."

Any expressed opinions are mine; but feel free to share.
I disclaim all responsibilities, all shapes, all sizes, all colors.

jdow@gryphon.CTS.COM (Joanne Dow) (10/13/87)

In article <2460@cbmvax.UUCP> andy@cbmvax.UUCP (Andy Finkel) writes:
>In article <15590@amdahl.amdahl.com> kim@amdahl.amdahl.com (Kim DeVaughn) writes:
>  Of course, if it it involves people sending
>me 500,000 dollars in unmarked bills, I suspect that it wouldn't
>be a good ide......actually, come to think of it *I* like this concept :-)
>
Mr. Finkel! I'm shocked! This is utterly improper behavior for one of our
revered CATS employees! (Er, 500K is a little cheap these days. you can't
live on it long enough in the style to which you'd like to become used to.
Try more like a couple mil, eh?)
<@_->
>-- 
>andy finkel		{ihnp4|seismo|allegra}!cbmvax!andy 
>Commodore-Amiga, Inc.

-- 
<@_@>
	BIX:jdow
	INTERNET:jdow@gryphon.CTS.COM
	UUCP:{akgua, hplabs!hp-sdd, sdcsvax, ihnp4, nosc}!crash!gryphon!jdow

Remember - A bird in the hand often leaves a sticky deposit. Perhaps it was
better you left it in the bush with the other one.