[comp.sys.amiga] Assembly Blues

steelie@pro-charlotte.cts.com (Jim Howard) (08/11/88)

Can anyone out there figure out what is wrong with the following 
excerpt of code? (besides the obvious sloppy style)
 
It is *SUPPOSED* to calculate the sc_ViewPort value of the wbench 
screen, and then use SetRGB4 to change color register 0 to
some other color.  I assume this will make the background color
change..  But so far, I have been able to get nothing but 
software errors as soon as I run it.. Doesnt change the color or 
anything..  I know this code doesnt close the screen or do any
of the nicetys, but for all apparent(at least to me) reasons,
it should at least FUNCTION...
 
 
 
        include "intuition/intuition.i"

        xref    _LVOOpenLibrary
        xref    _LVOSetRGB4
        xref    _LVOOpenScreen
        xref    _LVOCloseScreen
        xdef    sc_ViewPort
        xdef    sc_RastPort

NULL    equ     0                       ;for use in window structure


        movea.l 4,a6                    ;directly load exec base
        lea     intname,a1              ;get intuition.library
        jsr     _LVOOpenLibrary(a6)     ;open it
        move.l  d0,intbase              ;save pointer 

        lea     grpname,a1              ;get graphics.library
        jsr     _LVOOpenLibrary(a6)     ;open it
        move.l  d0,grpbase              ;save pointer

        lea     screenvars,a0
        move.l  intbase,a6
        jsr     _LVOOpenScreen(a6)
        move.l  d0,screen

        move.l  screen,d0
        add.l   #sc_RastPort,d0
        move.l  d0,myraster
        sub.l   #sc_RastPort,d0
        add.l   #sc_ViewPort,d0
        move.l  d0,myview

        move.l  grpbase,a6
        move.l  myview,a0
        move.l  #0,d0                   
        move.b  #5,d1                  
        move.b  #0,d2                  
        move.b  #0,d3                  
        jsr     _LVOSetRGB4(a6)

        move.l  intbase,a6
        move.l  screen,a0
        jsr     _LVOCloseScreen(a6)
        rts     
        

intname         dc.b    'intuition.library',0
        cnop    0,2
grpname         dc.b    'graphics.library',0
        cnop    0,2

intbase         ds.l    0
grpbase         ds.l    0
myview          ds.l    0
screen          ds.l    0
myraster        ds.l    0

screenvars     dc.w  0                    * ns_LeftEdge
               dc.w  0                    * ns_TopEdge
               dc.w  320                  * ns_Width
               dc.w  200                  * ns_Height
               dc.w  3                    * ns_Depth
               dc.b  3                    * ns_DetailPen
               dc.b  1                    * ns_BlockPen
               dc.w  0                    * ns_ViewModes
               dc.w  WBENCHSCREEN         * ns_Type
               dc.l  0                    * ns_Font
               dc.l  0                    * ns_DefaultTitle
               dc.l  0                    * ns_Gadgets
               dc.l  0                    * ns_CustomBitMap

 
 
Also,  has anyone noticed that when using Blink, if any of
the XREF's are more than about 15 characters long, then
the *@#$% thing wont recognize it???  Really annoying when
you try something like  XREF   _LVOViewPortAddress
 
the thing only looks at recognizes it as _LVOViewPortAdd
, and then cant find that in amiga.lib !

Respond via e-mail, as I dont want to waste any more space
than I already have with this.
 
Thanks,


   UUCP:  ....!crash!pro-charlotte!steelie    | Pro-Charlotte - (704) 567-0029
   ARPA:  crash!pro-charlotte!steelie@nosc.mil| 300/1200/2400 baud  24 hrs/day
   INET:  steelie@pro-charlotte.cts.com       | Log in as "register"

koster@cory.Berkeley.EDU (Herbert West) (08/12/88)

In article <3295@crash.cts.com> steelie@pro-charlotte.cts.com (Jim Howard) writes:
>Can anyone out there figure out what is wrong with the following 
>excerpt of code? (besides the obvious sloppy style)
>
">screenvars     dc.w  0                    * ns_LeftEdge
">               dc.w  0                    * ns_TopEdge
">               dc.w  320                  * ns_Width
">               dc.w  200                  * ns_Height
">               dc.w  3                    * ns_Depth
">               dc.b  3                    * ns_DetailPen
">               dc.b  1                    * ns_BlockPen
">               dc.w  0                    * ns_ViewModes
">               dc.w  WBENCHSCREEN         * ns_Type
">               dc.l  0                    * ns_Font
">               dc.l  0                    * ns_DefaultTitle
">               dc.l  0                    * ns_Gadgets
">               dc.l  0                    * ns_CustomBitMap

My guess would be you want COSTOMSCREEN instead of WBENCHSCREEN.
Usually with intuition, the machine bombs when things aren't just exactly
right.

Try single stepping the program with your debugger, and see if it is the
OpenScreen that does it.

jms@antares.UUCP (joe smith) (08/14/88)

In article <3295@crash.cts.com> steelie@pro-charlotte.cts.com (Jim Howard) writes:
>        movea.l 4,a6                    ;directly load exec base
>        lea     intname,a1              ;get intuition.library
>        jsr     _LVOOpenLibrary(a6)     ;open it
>        move.l  d0,intbase              ;save pointer 
>        lea     grpname,a1              ;get graphics.library
>        jsr     _LVOOpenLibrary(a6)     ;open it
>        move.l  d0,grpbase              ;save pointer

The OpenLibrary call requires 2 arguments; a pointer to the name of the
library on A0 and the library version number in D0.  If Intuition is
openned OK, then the large positive number left over in D0 is guarenteed
to make the call to open Graphics to fail.

        movea.l 4,a6
        lea     intname,a1
        moveq.l #0,d0                  ;Zero means to accept any version
        jsr     _LVOOpenLibraray(a6)
        move.l  d0,intbase
        beq     Abort_No_Intuition     ;Give up if OpenLibrary failed
        lea     grpname,a1
        moveq.l #0,d0                  ;Zero means to accept any version
        jsr     _LVOOpenLibraray(a6)
        move.l  d0,grpbase
        beq     Abort_No_Graphics      ;Give up if OpenLibrary failed

It is absolutely mandatory to test the result returned by OpenLibrary if
you want to avoid the Guru.
-- 
+-----------------------------------------------------------------------------+
|  TYMNET:   JMS@F29            UUCP: {ames|pyramid}oliveb!tymix!antares!jms  |
|  INTERNET: JMS%F29.Tymnet@Office-1.ARPA   PHONE: Joe Smith @ (408)922-6220  |
+-----------------------------------------------------------------------------+

mriley@pnet02.cts.com (Mark Riley) (08/14/88)

Try adding the following to the code that opens the libraries:

>        movea.l 4,a6                    ;directly load exec base
>        lea     intname,a1              ;get intuition.library
         MOVEQ #0,D0                     ;LIBRARY VERSION NUMBER       
>        jsr     _LVOOpenLibrary(a6)     ;open it
>        move.l  d0,intbase              ;save pointer 
>
>        lea     grpname,a1              ;get graphics.library
         MOVEQ #0,D0                     ;LIBRARY VERSION NUMBER       
>        jsr     _LVOOpenLibrary(a6)     ;open it
>        move.l  d0,grpbase              ;save pointer

Also, in the new screen structure take out the WBENCHSCREEN and make it
a zero.  Good luck, -Mark-

UUCP: {ucbvax!ucsd,rutgers}!crash!gryphon!pnet02!mriley
INET: mriley@pnet02.cts.com

"Hey, I don't _use_ programs, I write them..."  ;-)

mriley@pnet02.cts.com (Mark Riley) (08/14/88)

In regards to the ASM program to change screen colors:

You seem to have rewritten the example, but did you bother to assemble
and run it?  I'd be very surprised if it worked.  The following two
lines (it seems to me) need to be changed:

>      move.l  sc_RastPort(a0),myraster
>      move.l  sc_ViewPort(a0),myview

To something like this:

       lea     sc_RastPort(a0),a1
       move.l  a1,myraster
       lea     sc_ViewPort(a0),a1
       move.l  a1,myview

These structures are contained within the screen structure as opposed
to the screen structure containing ptrs to them.

-Mark-

UUCP: {ames!elroy, <backbone>}!crash!gryphon!pnet02!mriley
INET: mriley@pnet02.cts.com

"Hey, I don't _use_ programs, I write them..."  ;-)