Path: utzoo!attcan!uunet!ncrlnk!ncrcae!hubcap!gatech!rutgers!mailrus!ulowell!page From: page@swan.ulowell.edu (Bob Page) Newsgroups: comp.sources.amiga Subject: v02i060: flip - display hack Message-ID: <10144@swan.ulowell.edu> Date: 10 Nov 88 21:51:03 GMT Organization: University of Lowell, Computer Science Dept. Lines: 224 Approved: page@swan.ulowell.edu Submitted-by: rucklidg@svax.cs.cornell.edu (William Rucklidge) Posting-number: Volume 2, Issue 60 Archive-name: graphics/flip.1 Here's a screen hack I came up with a while ago. [binary included too, it's small. ..Bob] # This is a shell archive. # Remove everything above and including the cut line. # Then run the rest of the file through sh. #----cut here-----cut here-----cut here-----cut here----# #!/bin/sh # shar: Shell Archiver # Run the following text with /bin/sh to create: # README # flip.c # flip.uu # This archive created: Thu Nov 10 16:45:22 1988 cat << \SHAR_EOF > README Here's Yet Another Screen Hack I wrote in a moment of boredom. Type "flip", and observe. Try typing a few other commands, like "list". Type "flip" again to restore (or do anything which affects screen ordering/position (e.g. Left-Amiga-N)). For some reason or other this doesn't work reliably if you have more than the Workbench screen open. It won't crash the machine, but it won't have the desired effect. - William Rucklidge rucklidg@svax.cs.cornell.edu SHAR_EOF cat << \SHAR_EOF > flip.c /* * flip.c - yet another screen hack * * William Rucklidge rucklidg@svax.cs.cornell.edu * * This code is released into the public domain. What's the point in * copyrighting something like this, anyway? * * Thanks to jimm, for dcop. * * This will work on simple workbench screens. There seems to be some problem * when more than one screen is open: GfxBase->ActiView doesn't seem to contain * the right information (the copper lists and the View don't match). I'm * probably just not looking in the right place, though. * * This makes some assumptions about the copper list: that the modulo registers * are loaded before the bitplane data pointers, that the bitplane data pointers * are loaded in successive instructions, high then low, and that the copper * list being mangled is that of a fully displayed screen (not a window into a * larger bitmap). These assumptions are all true for automatically generated * copper lists. * * This does seem to work with vscreen'd and morerowed Workbench screen. * */ #include #include #include /* The codes for a few copper instructions */ #define MOVEBPL1MOD 0x0108 #define MOVEBPL2MOD 0x010A #define MOVEBPL1PT 0x00E0 #define MAXPLANES 6 #define PTSKIP 4 #define MOVEBPLPT(x) (MOVEBPL1PT + ((x) - 1) * PTSKIP) extern void *OpenLibrary(), CloseLibrary(), Forbid(), Permit(); struct GfxBase *GfxBase; typedef int boolean; #undef FALSE #undef TRUE #define FALSE 0 #define TRUE 1 void mangleCprList(list, isLOF, bpl, vy) struct cprlist *list; /* A copper list to be mangled. */ boolean isLOF; /* Is this a LOF coppper list? */ unsigned short bpl; /* The number of bytes per line */ unsigned short vy; /* The number of lines */ { register short *cp, inst; char *oldbplpt; char *newbplpt; register int i; long offset; boolean wasflipped = FALSE; if (!list) { return; } for (i = list->MaxCount, cp = (short *)list->start; i > 0; i--, cp += 2) { inst = *cp; if ((inst == MOVEBPL1MOD) || (inst == MOVEBPL2MOD)) { /* Mangle the modulus */ if (*(cp + 1) < 0) { wasflipped = TRUE; } *(cp + 1) = - (bpl << 1) - *(cp + 1); } else if ((inst >= MOVEBPLPT(1)) && (inst < MOVEBPLPT(MAXPLANES + 1)) && (!(inst & 3))) { /* This is a load bitplane address register instruction. * Make sure that this instruction is followed by one to * load the other half of the register */ if ((*(cp + 2) == inst + 2) && (i > 1)) { /* Mangle the bitplane address */ /* Pick out the address from the operands of the instructions */ oldbplpt = (char *)((((long)*(cp + 1)) << 16) + (unsigned short)(*(cp + 3))); offset = (vy - 1) * (long)bpl + (isLOF ? 0 : -((short)bpl << 1)); if (!wasflipped) { newbplpt = oldbplpt + offset; } else { newbplpt = oldbplpt - offset; } /* Install the new address */ *(cp + 1) = (long)newbplpt >> 16; *(cp + 3) = (long)newbplpt & 0xffff; } } } } int main() { unsigned short bpl, vy; GfxBase = OpenLibrary("graphics.library", 0L); /* We don't want anyone rebuilding the copper lists while we mangle them */ Forbid(); /* Get bytes per line and screen height */ bpl = ((GfxBase->ActiView->ViewPort->DWidth) >> 3) & ~1; vy = GfxBase->ActiView->ViewPort->DHeight; mangleCprList(GfxBase->ActiView->LOFCprList, TRUE, bpl, vy); mangleCprList(GfxBase->ActiView->SHFCprList, FALSE, bpl, vy); Permit(); CloseLibrary(GfxBase); return(0); } SHAR_EOF cat << \SHAR_EOF > flip.uu begin 644 flip M```#\P`````````#``````````(```(>````$@````$```/I```"'D[Z`;!.! M5?_R2.<,($)M__)*K0`(9@A,WP0P3EU.=2!M``@Z*``((FT`""1I``1@``#<> M.!*X?`$(9P:X?`$*9B!*:@`";`8[?``!__(P+0`.XT!$0)!J``(U0``"8```O MJKA\`.!M``"BN'P`^&P``)HP!,!\``-F``"0,`140#(J``2R0&8``(*Z?``!A M;WHP*@`"2,!R$..@=``T*@`&T((K0/_\,"T`$%-`P.T`#B\`2FT`#&<$<`!@* M"C(M``[C03`!1$!(P"0?U(`K0O_T2FW_\F8.("W__-"M__0K0/_X8`P@+?_\Y MD*W_]"M`__@@+?_XD_O``HO+(`Z3KH&0EA/_ M<`!.74YU9W)A<&AI8W,N;&EB0``87!#[(`&1>R`!K7)9@XR/``0:PATF M`"+"4``$*4Z`"DCG@(`(+@`$`2EG$$OZ``A.KO_B8`9"I_-?U M3G-#^@`@3J[^:"E`@`YF#"X\``.`!TZN_Y1@!$ZZ`!I03TYU9&]S+FQI8G)A2 M0`!```P+(`"P?P`!B\`3KH%I%!/*4"`$F84@ M0J=(>0`!``!.N@5H4$\N;(`&3G4@;(`20F@`!"!L@!(Q?``!`!`B;(`2,WP`9 M`0`*(&R`!B`L@`:0J``$4(`I0(`6(&R`%B"\34%.6$*G3KH%6%A/)$!*J@"LE M9RXO+0`,+RT`""\*3KH`LD_O``PY?``!@!H@;(`2`&B````$(&R`$@!H@```^ M"F!$2&H`7$ZZ!6A83TAJ`%Q.N@4R6$\I0(`<(&R`'$JH`"1G$"!L@!PB:``D< M+Q%.N@206$\O+(`<+PI.N@)84$\I;(`<@"!.N@2$(&R`$B"`3KH$D"!L@!(AN M0``&9Q9(>`/M2'H`+$ZZ!&Q03R!L@!(A0``,+RR`(#\L@"1.NOW"7$]"9TZZP M`M143R1?3EU.=2H`3E4``$CG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