amiga-request@ab20.larc.nasa.gov (Amiga Sources/Binaries Moderator) (03/14/91)
Submitted-by: ewhac@well.uucp (Leo 'Bols Ewhac' Schwab) Posting-number: Volume 91, Issue 058 Archive-name: utilities/bpd-9011.11/part01 [ includes uuencoded executable ...tad ] Hi there. Here's a little goodie I concocted to make my EuroTesting a bit easier. It's called BPD, and it causes your system to come up in true PAL mode when you reboot. No, I am not trying to ape Nico Francois. The fact that we happen to write substantially the same program at the same time is pure coincidence. Honest. (I will confess that I added the NTSC option after having seen his program, and deciding that doing NTSC was a good idea, too.) I hope you like it. Schwab #!/bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh <file", e.g.. If this archive is complete, you # will see the following message at the end: # "End of archive 1 (of 1)." # Contents: BPD.asm BPD.doc BPD.uu README # Wrapped by tadguy@ab20 on Wed Mar 13 19:58:36 1991 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f 'BPD.asm' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'BPD.asm'\" else echo shar: Extracting \"'BPD.asm'\" \(9543 characters\) sed "s/^X//" >'BPD.asm' <<'END_OF_FILE' X*\ :ts=8 bk=0 X* X* BPD.asm: Stands for "Boot PAL, Dammit!" Written as an alternative to X* all those other programs that attempt to set PAL mode, and X* never get it right. X* X* See, in order for PAL mode to *truly* take effect, you have X* to convince graphics.library that it's running PAL. To do X* that, you have to get in before graphics configures itself X* and set the PAL bit in the ECS agnus. And in order to do X* *that*, you have to be part of the boot sequence. X* X* So this program does precisely that by creating and X* installing a resident RomTag into the system that survives X* reboots. X* X* Usage: BPD [ '?' | 'REMOVE' | 'NTSC' ] X* X* Thanks to Bryce Nesbitt for providing me with an example X* of how to create resident RomTags. X* X* Leo L. Schwab, Silent Software, Inc. 9010.20 X* NTSC hack added (inspired by Nico Francois) 9011.11 X*/ X include 'exec/types.i' X include 'exec/execbase.i' X include 'exec/resident.i' X include 'exec/memory.i' X X xref _LVOFindResident X xref _LVOAllocMem X xref _LVOCopyMem X xref _LVOSumKickData X xref _LVODisable X xref _LVOEnable X xref _LVOOpenLibrary X xref _LVOCloseLibrary X X xref _LVOOutput X xref _LVOWrite X X xref _vposr ; Custom chip register X XTAG_PRI EQU 100 ; Above graphics.library. X X X**************** X* And we're off! X* X SECTION BPD,CODE XHello: X movea.l a0,a3 ; Save argument pointer X movea.l 4.w,a6 ; ExecBase X lea dosname(pc),a1 X moveq #0,d0 X jsr _LVOOpenLibrary(a6) X moveq #20,d2 X move.l d0,d6 X beq openfailed X X lea Name(pc),a1 X jsr _LVOFindResident(a6) X X* See if ECS Agnus is installed. We check for ID's 0x20 and 0x30. Anything X* else is considered something we don't know how to deal with. X* X move.w _vposr,d1 ; Get ID bits X andi.w #$3F00,d1 ; Mask off extraneous stuff. X cmpi.w #$3000,d1 ; Is it NTSC ECS Agnus? X beq.s 1$ X cmpi.w #$2000,d1 ; Is it PAL ECS Agnus? X bne notecs X X* Scan command line to see what the user wants to do. X* X1$ move.b (a3)+,d1 X cmpi.b #' ',d1 X beq.s 1$ ; Skip past leading blanks. X cmpi.b #'?',d1 ; Usage line X beq usage X cmpi.b #'r',d1 ; Remove X beq remove X cmpi.b #'R',d1 X beq remove X cmpi.b #'n',d1 ; NTSC X beq.s 2$ X cmpi.b #'N',d1 X bne.s install X X* Exceedingly cheap hack to support PAL machines that want to boot into X* NTSC mode (inspired by Nico Francois' NTSC-PAL programs). This will X* cause the bootnode to stuff a 0 into the magic ECS Agnus register, X* which should make the system come up in NTSC mode. X* X2$ clr.w movearg X X X* No meaningful command line arguments supplied, so we'll assume s/he wants X* to install it. X* Xinstall tst.l d0 X bne installed ; Already installed X X* Allocate memory to survive reboot. X* X move.l #RESIDENT_SIZ,d0 X move.l #MEMF_CHIP!MEMF_PUBLIC,d1 X jsr _LVOAllocMem(a6) X tst.l d0 X beq nomem X move.l d0,a2 ; Save pointer X X* Relocate pointers to destination. X* X lea RelTable(pc),a0 X lea ResStart(pc),a1 X sub.l a1,d0 ; Compute relocation difference X move.l d0,d7 ; Save it for later X X2$ move.l (a0)+,d0 ; Fetch address of thing to relocate X beq.s 3$ ; NULL-terminated array X move.l d0,a1 X add.l d7,(a1) ; Add offset to thing X bra.s 2$ X3$: X X* Set a few more things atomically. X* X jsr _LVODisable(a6) X X* Insert MemList into system KickMem list. (I would have used AddHead(), X* but SysBase.KickMemPtr is not a struct List. Oh well... X* X lea MyMemList(pc),a0 ; Address of our memlist X move.l KickMemPtr(a6),d0 X move.l d0,(a0) ; Append current system entry to us X add.l d7,a0 ; Add relocation offset X move.l a0,KickMemPtr(a6) ; Add us to system X X* Insert into Resident module list. This is done so that running BPD twice X* before rebooting will not cause it to be installed twice (that would be X* bad, you see...). X* X lea MyResModule(pc),a0 ; Our ResModule array X move.l ResModules(a6),d0 ; Already ResModules here? X beq.s 4$ X bset.l #31,d0 ; Yes, set special indirection flag X move.l d0,4(a0) ; and store pointer. X4$: X add.l d7,a0 ; Add relocation offset X move.l a0,ResModules(a6) ; Insert us into Exec list X X* Insert into KickTagPtr list. X* X lea MyKickTagPtr(pc),a0 ; Our KickTagPtr array X move.l KickTagPtr(a6),d0 ; Already KickTagPtrs here? X beq.s 5$ X bset.l #31,d0 ; Yep... X move.l d0,4(a0) X5$: X add.l d7,a0 ; Relocate... X move.l a0,KickTagPtr(a6) ; Insert us into Exec list X X* Copy resident code and data into allocated memory. X* X lea ResStart(pc),a0 ; src X movea.l a2,a1 ; dest X move.l #RESIDENT_SIZ,d0 X jsr _LVOCopyMem(a6) X X* Recompute KickCheckSum. X* X jsr _LVOSumKickData(a6) X move.l d0,KickCheckSum(a6) X X* Return to reality. X* X jsr _LVOEnable(a6) X lea BPD.msg(pc),a2 X bsr climsg X lea installed.msg(pc),a2 X bsr climsg X Xexit lea change.msg(pc),a2 X bsr climsg Xeexit movea.l d6,a1 X jsr _LVOCloseLibrary(a6) Xopenfailed move.l d2,d0 ; D2 usually set to 0 by climsg X rts X Xerrexit moveq #20,d2 X bra.s eexit X X X**************** X* User wants to remove the goodie. X* Xremove tst.l d0 X beq.s nothere ; Nothing to remove X X* Remove ourselves from the system lists. First the KickMemPtr list. X* X lea KickMemPtr(a6),a1 X1$ movea.l a1,a0 X move.l (a0),d1 X beq.s nothere ; Couldn't find MemList entry. X X movea.l d1,a1 X cmp.l ML_ME+ME_ADDR(a1),d0 ; See if it's us. X bne.s 1$ X X move.l (a1),(a0) ; Pull us from the list. X X* Now try to find us in the KickTagPtr list. X* X lea KickTagPtr(a6),a0 Xtablehop move.l (a0),d1 X beq.s nothere ; End of tables; Couldn't find us. X bclr.l #31,d1 X movea.l d1,a1 X Xtableloop move.l (a1)+,d1 X bgt.s 2$ X lea -4(a1),a0 ; Indirection, get pointer to it X bra.s tablehop ; and loop to next table X X2$ cmp.l d1,d0 ; Is it us? X bne.s tableloop X X* We found ourselves. Now perform remove. (Since I know the format of X* the table I installed, I can make assumptions about the data I'm zapping.) X* X move.l (a1),d1 ; Get pointer to next table. X btst.b #7,(a0) ; Did we get here by indirection? X bne.s 3$ X bclr.l #31,d1 ; No, clear indirection bit. X3$ move.l d1,(a0) ; Patch to jumper over us. X X* Reset KickCheckSum. X* X jsr _LVOSumKickData(a6) X move.l d0,KickCheckSum(a6) X X lea BPD.msg(pc),a2 X bsr.s climsg X lea removed.msg(pc),a2 X bsr.s climsg X bra.s exit X X X**************** X* Diagnostic messages. X* Xinstalled lea BPD.msg(pc),a2 X bsr.s climsg X lea already.msg(pc),a2 X bsr.s climsg X bra.s errexit X Xnomem lea nomem.msg(pc),a2 X bsr.s climsg X bra.s errexit X Xnotecs lea notecs.msg(pc),a2 X bsr.s climsg X bra.s errexit X Xnothere lea BPD.msg(pc),a2 X bsr.s climsg X lea not.msg(pc),a2 X bsr.s climsg X lea installed.msg(pc),a2 X bsr.s climsg X bra errexit X Xusage lea ID(pc),a2 X bsr.s climsg X lea usage.msg(pc),a2 X bsr.s climsg X bra exit X X**************** X* Routine to print to CLI. X* Xclimsg exg d6,a6 ; Error string pointer in A2 X jsr _LVOOutput(a6) X move.l d0,d1 X beq.s noout ; No output channel X X move.l a2,d2 ; Compute string length X1$ tst.b (a2)+ X bne.s 1$ X suba.l d2,a2 X move.l a2,d3 X subq.l #1,d3 X jsr _LVOWrite(a6) ; Write string Xnoout exg d6,a6 X moveq #0,d2 X rts X X X**************** X* Relocation table. Contains pointers to addresses to be moved. X* XRelTable dc.l RL0,RL1,RL2,RL3,RL4,RL5,RL6,RL7,RL8,0 X X* Diagnostic strings. X* Xdosname dc.b 'dos.library',0 XBPD.msg dc.b 'BPD ',0 Xalready.msg dc.b 'already ' Xinstalled.msg dc.b 'installed.',10,0 Xnot.msg dc.b 'not ',0 Xnotecs.msg dc.b 'ECS Agnus not present.',10,0 Xnomem.msg dc.b 'No memory for resident RomTag.',10,0 Xremoved.msg dc.b 'removed.',10,0 Xusage.msg dc.b 'This program may be freely distributed.',10,10 X dc.b 'Usage: BPD [REMOVE | NTSC]',10,0 Xchange.msg dc.b 'Change will take effect on next reboot.',10,0 X X X************************************************************************ X* The resident stuff intended to survive reboot. X* XResStart: cnop 0,2 X X* The Resident structure. X* XRomTag: ;STRUCTURE RT,0 X dc.w RTC_MATCHWORD ; UWORD RT_MATCHWORD XRL0: dc.l RomTag ; APTR RT_MATCHTAG XRL1: dc.l ResEnd ; APTR RT_ENDSKIP X dc.b RTF_COLDSTART ; UBYTE RT_FLAGS X dc.b 1 ; UBYTE RT_VERSION X dc.b NT_BOOTNODE ; UBYTE RT_TYPE X dc.b TAG_PRI ; BYTE RT_PRI XRL2: dc.l Name ; APTR RT_NAME XRL3: dc.l ID ; APTR RT_IDSTRING XRL4: dc.l PALTrick ; APTR RT_INIT X X X* The MemList. X* XMyMemList: ; STRUCTURE ML,LN_SIZE X ; STRUCTURE LN,0 X dc.l 0 ; APTR LN_SUCC X dc.l 0 ; APTR LN_PRED X dc.b NT_MEMORY ; UBYTE LN_TYPE X dc.b 0 ; BYTE LN_PRI XRL5: dc.l Name ; APTR LN_NAME X dc.w 1 ; UWORD ML_NUMENTRIES X ; STRUCTURE ME,0 XRL6: dc.l ResStart ; APTR ME_ADDR X dc.l RESIDENT_SIZ ; ULONG ME_LENGTH X X X* Array of pointers to RomTag structures describing things to be made X* resident. If the entry in the array has bit 31 set (0x80000000), then X* the pointer (sans high bit) is in fact a pointer to *another* array of X* RomTag pointers. A NULL terminates the array. X* (These also need relocation.) X* XRL7: XMyKickTagPtr dc.l RomTag,0 XRL8: XMyResModule dc.l RomTag,0 X X X* Name and ID strings. (I wonder if Xoper will show these?) X* XName dc.b 'BPD.resident',0 XID dc.b 'BPD (Boot PAL, Dammit!) v1.1 by Leo L. Schwab ' X dc.b '(11 Nov 1990)',13,10,0 X X**************** X* Why we went to all this trouble. Kind of anti-climactic, isn't it? X* (PAL Now Brown Cow) X* XPALTrick: btst.b #6,$BFE001 ; Check mouse button X beq.s palexit ; If pressed, let user boot normally X Xmovearg EQU *+2 ; The immediate argument to the MOVE X move.w #$0020,$DFF1DC ; Turn on PAL bit in ECS Agnus Xpalexit: moveq #0,d0 X rts X XResEnd EQU * XRESIDENT_SIZ EQU ResEnd-ResStart ; Size of preserved block. X X END END_OF_FILE if test 9543 -ne `wc -c <'BPD.asm'`; then echo shar: \"'BPD.asm'\" unpacked with wrong size! fi # end of 'BPD.asm' fi if test -f 'BPD.doc' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'BPD.doc'\" else echo shar: Extracting \"'BPD.doc'\" \(2723 characters\) sed "s/^X//" >'BPD.doc' <<'END_OF_FILE' XBPD Amiga Users' Manual BPD X X NAME X BPD -- Install/remove wedge to boot system into PAL mode. X X SYNOPSIS X BPD [ '?' | 'REMOVE' | 'NTSC' ] X X DESCRIPTION X BPD installs, via resident RomTags, a wedge into the boot sequence X that turns on the PAL bit in ECS Agnus. This operation happens X very early in the boot process, before graphics.library configures, X so the system will come up well and truly in PAL mode, with all the X GfxBase fields set correctly. X X BPD uses the same reboot survival technology as RAD:, so if you have X a machine with more than 512K of CHIP RAM, you must use 'SetPatch r' X to get this to work. X X BPD must be run from the CLI. The command line options are: X X '?': X Prints a usage synopsis. X 'REMOVE': X Removes the wedge. (Just 'r' will work here.) X 'NTSC': X Installs an NTSC version of the wedge, which is useful if X you're European. (Just 'n' will work here.) X <anything else>: X Installs the PAL wedge. BPD will not permit itself to be X installed twice. X X After installing or removing the wedge, reboot the system to make the X change take effect. If you wish to temporarily prevent the system X from coming up in the different mode with BPD installed, hold down X the left mouse button during reboot. X X If you don't have an ECS Agnus in your machine, BPD won't let you do X anything. X X NOTES X BPD was written as a result of discovering just how hard it was to X get a system to boot up in PAL mode, short of attacking the machine X with a soldering iron. Other programs such as PALBoot don't do the X job because by the time they've run, graphics has already configured X itself for NTSC, so all the GfxBase fields reflect NTSC values. X X It was important to me to test software under PAL mode, and I wanted X to do it right, so I wrote this. X X BPD is intended for 1.3. 2.0 has built-in the ability to bring up X PAL displays. X X AUTHOR X Leo L. Schwab, Silent Software, Inc. X USENET: ewhac@well.sf.ca.us X BIX: ewhac X PeopleLink: ewhac X X SEE ALSO X SetPatch X X BUGS X BPD seems to interact badly with 2090A hard disk controllers. (The X evidence is largely anecdotal at this time; I'm still investigating X this.) If you have a 2090A, BPD may or may not work for you. X X If you run 'BPD REMOVE', attempts to reinstall BPD before rebooting X will fail; it thinks it's still installed. Fixing this was rather X more trouble than I was willing to expend. X X According to the program 'SI' (part of the Cramden Utilities), after X installing BPD, ExecBase reports the powerline frequency to be 50 Hz. X You may want to watch out for this. (Maybe this is a bug in the OS?) X X BPD was not written to consider the WorkBench startup, so I don't X recommend attaching an icon to it. END_OF_FILE if test 2723 -ne `wc -c <'BPD.doc'`; then echo shar: \"'BPD.doc'\" unpacked with wrong size! fi # end of 'BPD.doc' fi if test -f 'BPD.uu' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'BPD.uu'\" else echo shar: Extracting \"'BPD.uu'\" \(1503 characters\) sed "s/^X//" >'BPD.uu' <<'END_OF_FILE' Xbegin 644 BPD XM```#\P`````````"``````````$```#B`````````^D```#B)D@L>``$0_H"^ XM`'``3J[]V'04+`!G``$&0_H#"DZN_Z`R.0#?\`0"03\`#$$P`&<(#$$@`&8`' XM`5P2&PP!`"!G^`P!`#]G``%J#`$`<F<``-8,`0!29P``S@P!`&YG!@P!`$YFM XM!D)Y```#?$J`9@`!#B`\````I"(\`````TZN_SI*@&<``08D0$'Z`59#^@)46 XMD(DN`"`89P8B0-^18/9.KO^(0?H"6"`N`B(@@-''+4@"(D'Z`F@@+@$L9P@(& XMP``?(4``!-''+4@!+$'Z`D@@+@(F9P@(P``?(4``!-''+4@")D'Z`?XB2B`\K XM````I$ZN_9!.KOV<+4`"*DZN_X)%^@$480``O$7Z`1EA``"T1?H!J6$``*PB/ XM1DZN_F(@`DYU=!1@\DJ`9W)#[@(B($DB$&=H(D&PJ0`09O(@D4'N`B8B$&=6> XM"($`'R)!(AEN!D'I__Q@[+"!9O(B$0@0``=F!`B!`!\@@4ZN_9PM0`(J1?H`F XMI&%,1?H`]&%&8))%^@"683Y%^@"583A@ED7Z`+YA,&".1?H`GF$H8(9%^@!XS XM82!%^@"+81I%^@!Y811@`/]R1?H!?V$*1?H`O&$$8`#_4,V.3J[_Q"(`9Q`D4 XM"DH:9OR5PB8*4X-.KO_0S8YT`$YU```"Y````N@```+P```"]````O@```,&% XM```##````Q0```,<`````&1O<RYL:6)R87)Y`$)01"``86QR96%D>2!I;G-TD XM86QL960N"@!N;W0@`$5#4R!!9VYU<R!N;W0@<')E<V5N="X*`$YO(&UE;6]RK XM>2!F;W(@<F5S:61E;G0@4F]M5&%G+@H`<F5M;W9E9"X*`%1H:7,@<')O9W)AM XM;2!M87D@8F4@9G)E96QY(&1I<W1R:6)U=&5D+@H*57-A9V4Z($)01"!;4D5-K XM3U9%('P@3E130UT*`$-H86YG92!W:6QL('1A:V4@969F96-T(&]N(&YE>'0@Q XM<F5B;V]T+@H`2OP```+B```#A@$!$&0```,D```#,0```W````````````H`$ XM```#)``!```"X@```*0```+B`````````N(`````0E!$+G)E<VED96YT`$)0L XM1"`H0F]O="!004PL($1A;6UI="$I('8Q+C$@8GD@3&5O($PN(%-C:'=A8B`@" XM*#$Q($YO=B`Q.3DP*0T*``@Y``8`O^`!9P@S_``@`-_QW'``3G4``````^P`# XM```3`````````N0```,,```#%````QP```!F```!X````>0```'H```![```` XM`?````'T```!^````?P```(````"Z````O````+T```"^````P8````````#V X-\@```^H````````#\OP`0 X`` Xend Xsize 1048 END_OF_FILE if test 1503 -ne `wc -c <'BPD.uu'`; then echo shar: \"'BPD.uu'\" unpacked with wrong size! fi # end of 'BPD.uu' fi if test -f 'README' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'README'\" else echo shar: Extracting \"'README'\" \(1952 characters\) sed "s/^X//" >'README' <<'END_OF_FILE' X Hi there. Here's a little goodie I concocted to make my EuroTesting Xa bit easier. It's called BPD, and it causes your system to come up in true XPAL mode when you reboot. X X No, I am not trying to ape Nico Francois. The fact that we happen Xto write substantially the same program at the same time is pure coincidence. XHonest. (I will confess that I added the NTSC option after having seen his Xprogram, and deciding that doing NTSC was a good idea, too.) X X I hope you like it. X X Schwab X X---------------- X Why BPD is better than: X XPALBoot X------- X X PALBoot writes a custom boot block to a floppy, which flips the PAL Xbit in the ECS Agnus chip. X X Boot blocks are executed by the system strap module, which is the Xlast thing to happen in the system configuration cycle. Thus, all PALBoot Xbuys you is a 50Hz VBlank rate. The rest of the system still reports it's in XNTSC mode. X XGoPAL X----- X X GoPAL is a CLI command that flips the PAL bit in the ECS Agnus chip. X X GoPAL suffers from the same shortcomings as PALBoot: The chip is the Xonly thing touched. None of the system variables are updated to tell Xsoftware it's running under PAL rates. X XBootPAL X------- X X BootPAL installs a resident ROMTag which survives reboot and Xexecutes as part of the boot sequence. Upon reboot, it flips the PAL bit in Xthe ECS Agnus chip, and updates various system variables. X X This is much better than the previous two. However, the ROMTag Xpriority is set too low, which means that the boot code executes long after Xgraphics has configured itself. So the program resorts to poking system Xvariables itself. Apart from the fact that this is philosophically Xincorrect, it is impossible to know all the fields that need to be changed, Xor their correct values. X X It also appears to remove itself improperly, which could trash other Xresident ROMTag goodies (like RAD:) depending on the order in which you Xinvoked things. X X It's also 100 bytes bigger than mine :-). END_OF_FILE if test 1952 -ne `wc -c <'README'`; then echo shar: \"'README'\" unpacked with wrong size! fi # end of 'README' fi echo shar: End of archive 1 \(of 1\). cp /dev/null ark1isdone MISSING="" for I in 1 ; do if test ! -f ark${I}isdone ; then MISSING="${MISSING} ${I}" fi done if test "${MISSING}" = "" ; then echo You have the archive. rm -f ark[1-9]isdone else echo You still need to unpack the following archives: echo " " ${MISSING} fi ## End of shell archive. exit 0 -- Mail submissions (sources or binaries) to <amiga@uunet.uu.net>. Mail comments to the moderator at <amiga-request@uunet.uu.net>. Post requests for sources, and general discussion to comp.sys.amiga.misc.