#RastPort.AreaInfo
11 messages in this thread
C/Assembler Programmers –
AreaMove() keeps crashing on me. I've traced the problem to a bad
RastPort.AreaInfo pointer. Isn't InitArea() supposed to adjust that
pointer? Is InitTmpRas() going to give me a similar problem?
Should InitArea() be setting RastPort.AreaInfo correctly or am I supposed
to do that myself?
– Jim, on AP!
Jim,
after having allocated a Raster and an AreaBuffer, and after having inited
your TmpRas and AreaInfo structures, so yes, you have to poke <g> the
pointers to these structures into your (Window's ?) RastPort structure.
It's a bit tricky to get the value for rassize, I hope you set it right.
Tell me if this would not help, so I may E-Mail you some asm code fragment
I use since day one to set up the TmpRas and AreaBuffer.
– wkc – … via AP from Hamburg, Germany
Werner –
Thanks for the response. I've tried setting RastPort.AreaInfo manually
and it doesn't seem to work. (Well, it works for one pass, and then
somehow resets to 0.)
I'm opening a screen using OpenScreenTagList(), then referencing
RastPort.AreaInfo and RastPort.TmpRas using the pointer I get from
Screen.RastPort. Here, I'll show you:
OPEN_SCREEN movea.l #0,a0 ; no NewScreen pointer
lea ScTags,a1 ; new screen base address
CALLSYS OpenScreenTagList,_IntuitionBase
move.l d0,screen_p
beq CLOSE_TRAS
move.l d0,viewport_p
add.l #sc_ViewPort,viewport_p
move.l d0,rastport_p
add.l #sc_RastPort,rastport_p
So here I get the pointer to the screen's RastPort and load it into
rastport_p. Then I call InitArea() and InitTmpRas():
* set up RastPort.AreaInfo
lea areainfo,a0 ; pointer to AreaInfo structure
lea areabuffer,a1 ; pointer to vector buffer
move.l #MAXVECTORS,d0 ; number of vectors that buffer can hold
CALLSYS InitArea,_GfxBase
* set up RastPort.TmpRas
lea tmpras,a0 ; pointer to TmpRas structure
movea.l tmprasbuf,a1 ; pointer to TmpRas buffer
move.l #PLANESIZE,d0 ; size of one bitplane is enough space
CALLSYS InitTmpRas,_GfxBase
Here's how I call AreaMove(), AreaDraw(), and AreaEnd(). Just to see if I
did indeed have to set RastPort.AreaInfo manually, I stuck a little test
in the loop:
dopoly1:
movea.l rastport_p,a1
moveq.l #10,d0
CALLSYS SetAPen,_GfxBase
lea poly1dat,a2
movea.l rastport_p,a1
move.l rp_AreaInfo(a1),d4
lea areainfo,a3
cmp.l a3,d4 ; compare contents of RastPort.AreaInfo with
; actual location of struct AreaInfo
bne signal_areainfo_error
move.b #6,d2 ; point count (after initial)
move.w (a2)+,d0 ; x-coord
move.w (a2)+,d1 ; y-coord
CALLSYS AreaMove,_GfxBase
cmp.w #-1,d0
beq signal_areafn_error ; make sure AreaMove() doesn't fail
dp1loop:
move.w (a2)+,d0
move.w (a2)+,d1
CALLSYS AreaDraw,_GfxBase
cmp.w #-1,d0
beq signal_areafn_error ; make sure AreaDraw() doesn't fail
subq.b #1,d2
bne dp1loop
CALLSYS AreaEnd,_GfxBase
rts
signal_areainfo_error:
movea.l bm1_Planes,a4 ; trash screen a little if there's
add.l #8200,a4 ; a problem
movem.l d0-d7/a0-a7,(a4)
add.l #200,a4
movem.l d0-d7/a0-a7,(a4)
lea areainfo,a3 ; fix the problem?
movea.l rastport_p,a4
move.l a3,rp_AreaInfo(a4)
rts
Here's what I saw when I traced it with MonAm: First, the program traps
the incorrect RastPort.AreaInfo pointer (a 0, usually) and corrects it.
Then it quits back to the calling function ("main"). The main loop calls
the polygon routine again. It passes the AreaInfo pointer test, and the
AreaMove() succeeds. Then it goes to the first AreaDraw() — and when
AreaDraw() pulls the RastPort.AreaInfo pointer, it gets a 0!
(Incidentally, I also stepped through AreaMove() and AreaDraw() and got
totally confused at the end. It looks as though AreaMove() tried to
change the pointer RastPort.BitMap!)
Sorry to unload on you like this, but I seem to be hopelessly lost here.
:l
>> Tell me if this would not help, so I may E-Mail you some asm code
>> fragment I use since day one to set up the TmpRas and AreaBuffer.
That would help. Thanks.
– Jim, on AP!
Jim,
I got your reply, and I will give your code a test.
Please give me two days to check and sending the results along with my
code fragment, the comments of which I have to change from German into
English first…
– wkc – … via AP from Hamburg, Germany
Thanks for your help, Werner. 🙂
– Jim, on AP!
Jim,
I just tested your code and, of course, the display routine crashes the
system.
This is because you are forgetting to re-load the RastPort into a1 on
every library call – remember, a1 will mostly contain crap after a call.
This is how your display routine should look like:
dopoly1:
movem.l d2/a2-a3/a6,-(sp) ; added for security
movea.l rastport_p,a1
movea.l a1,a3 ; >> SAVE IT FOR LATER
moveq.l #10,d0
CALLSYS SetAPen,_GfxBase
lea poly1dat,a2
* movea.l rastport_p,a1 ; commented out, now it is..
movea.l a3,a1 ; >> GET RASTPORT
move.b #6,d2
move.w (a2)+,d0 ; x-coord
move.w (a2)+,d1 ; y-coord
CALLSYS AreaMove,_GfxBase
dp1loop:
move.w (a2)+,d0
move.w (a2)+,d1
movea.l a3,a1 ; >> GET RASTPORT !!
CALLSYS AreaDraw,_GfxBase
subq.b #1,d2
bne.s dp1loop ; MADE SHORT
movea.l a3,a1 ; >> GET RASTPORT !!
CALLSYS AreaEnd,_GfxBase
movem.l (sp)+,d2/a2-a3/a6 ; added for security
rts
This will run just fine on my machine. If you still have problems, then I
think you did not manage to set up TmpRas and AreaInfo correctly. Let me
know!
BTW, what sorta piece of s/w are you developing ?
– wkc – … via AP from Hamburg, Germany
>> This is because you are forgetting to re-load the RastPort into a1 on
>> every library call….
Oh. <g> Well, I'll give that a try. Thanks again.
>> BTW, what sorta piece of s/w are you developing ?
Right now, I'm just trying to get the hang of both 3D polygon graphics and
Amiga programming. I was hoping to do some sort of a BattleTech game, as
I seem to find something wrong with all of the ones out there. <g>
– Jim, on AP!
Jim,
hang in there. I'd pay money for a good Battletech game, as would my
sister.
Jim;
I'll second that – I've been waiting for one for a long time (and even
considering coding one myself – not that I don't already have enough stuff
to do <G>)
Gasp! That message hasn't scrolled _yet_? <g> I wrote it almost a month ago!
>> …(and even considering coding one myself – not that I don't already >>
have enough stuff to do <G>)
<g> I know what you mean.
Unfortunately, it looks like it's going to take me a looooooooong time to
figure out how to get polygons drawn with any speed at all.
– Jim, on AP!
Werner –
It works! I directly set RastPort.AreaInfo and RastPort.TmpRas, then made
your changes (put RastPort back in a1 before every lib call), and it
works.
The only problem is…I only seem to be getting ~160 polygons per second
with this very simple program on my A4000/040 with 18MB RAM…not too
good, eh? I guess I'll just have to look into hacking the hardware
(eeek!). :l
Thanks again!
– Jim, on AP!