Area-Commands (graphicslib) OLD! - Druckversion

+- AmiBlitz³ (
+-- Forum: Blitzbasic2 (
+--- Forum: Snippets & Libraries (
+--- Thema: Area-Commands (graphicslib) OLD! (/thread-65.html)

Seiten: 1 2 3

Area-Commands (graphicslib) OLD! - hackball - 01.02.2014

Hallo Leute,

hier mal eine alte Lib für BB2 von mir. Wenn ich mich recht erinnere, funktionierte die recht gut, evtl. gab es auch mal Speicherlecks (Chipmem) oder so, kann mich nicht mehr erinnern.
Wäre schön, wenn da mal jemand drüber schauen könnte.

; RayAreaGfxLib
; programmed for BlitzBasic 2 by Frank Brandis
; (c)opyright 1995 by Frank Brandis
; maximum of areasteps = 360 !!!!


; graphics
#_allocraster=-492 ;d0=(d0,d1)
#_freeraster =-498 ;   (a0,d0,d1)
#_inittmpras =-468 ;   (a0,a1,d0)
#_initarea   =-282 ;   (a0,a1,d0)

#_areamove   =-252 ;d0=(a1,d0,d1)
#_areadraw   =-258 ;d0=(a1,d0,d1)
#_areaend    =-264 ;   (a1)
#_areaellipse=-186 ;d0=(a1,d0,d1,d2,d3) ;only os3 ????? i dunno ..
#_drawellipse=-180 ;   (a1,d0,d1,d2,d3)
#_setapen    =-342 ;   (a1,d0)

; exec
#_allocmem   =-198 ;d0=(d0,d1)
#_freemem    =-210 ;   (a1,d0)

!libheader {#rayarealib,0,0,0,0}

!args {#word,#word,#word}
!libs {#graphicslib,#la6}
!subs {_areastart,0,0}
!name {"Area","x,y,col        ;start of filled polygon"}

!args {#word,#word}
!libs {#graphicslib,#la6}
!subs {_areastep,0,0}
!name {"AreaStep","x,y    ;next coord of filled polygon"}

!libs {#graphicslib,#la6}
!subs {_areafill,0,0}
!name {"AreaFill","       ;closing the polygon"}

!args {#word,#word,#word,#word,#word}
!libs {#graphicslib,#la6}
!subs {_areacirc,0,0}
!name {"WCirclef","x,y,xrad,yrad,col"} ;doesn`t work (areaellipse_)

!args {#long,#word,#word,#word,#word}
!subs {_setptrn,0,0}
!name {"Pattern","*rp,areaptrn1,areaptrn2,areaptrn3,areaptrn4"}

!afunction {#long}
!args {#long,#long,#long,#word}
!libs {#graphicslib,#la0,#execlib,#la1}
!subs {_areainit,0,0}
!name {"AreaInit","(*rp,width,height,maxcoords)  TRUE if success"}

!afunction {#long}
!libs {#execlib,#la6}
!subs {_areafinit,0,0}
!name {"AreaFinit","  BOOLEAN TRUE if success"}

!args {#long,#word}
!subs {_linepat,0,0}
!name {"LinePattern","*rp,pattval    ;pattval could be %1100110011001100"}

!args {#long,#long,#byte}
!subs {_setptrna,0,0}
!name {"PatternA","*rp,&patdef,patsize; user pattern def, patsize must be one of x^2 !!"}

!args {#long,#byte}
!subs {_setolpen,0,0}
!name {"OutlinePen","*rp,colour  ;"}

!args {#long,#byte}
!subs {_oline,0,0}
!name {"Outline","*rp,bool.b     ;   0 or 1,switches areaborders off or on"}


LEA  rastprt(pc),a0
MOVE.l      (a0),a1   ;rp here  :)

MOVEM.l    d0/d1,-(a7);x coord retten
MOVE.l        d2,d0   ;colour nach d0
JSR    _setapen(a6)

MOVEM.l    (a7)+,d0/d1   ;x coord rest.

JSR   _areamove(a6)   ;AreaMove_ *rp,x,y

LEA  rastprt(pc),a0
MOVE.l      (a0),a1
JSR   _areadraw(a6)   ;AreaDraw_ *rp,x,y

LEA  rastprt(pc),a0
MOVE.l      (a0),a1   ;*rp in a1

MOVEM.l    d0-d3,-(a7);x coord wegen lvosetapen_ retten
MOVE.l        d4,d0   ;color nach d0
JSR     _setapen(a6)

MOVEM.l    (a7)+,d0-d3;x coord rest.

; JSR _areaellipse(a6) ;AreaEllipse_ *rp,x,y,rx,ry  ,col
JSR _drawellipse(a6)
JSR     _areaend(a6)  ;AreaEnd_ *rp

LEA  rastprt(pc),a0
MOVE.l      (a0),a1
JSR    _areaend(a6)   ;AreaEnd_ *rp

LEA      gfxbas(pc),a2
MOVE.l           a0,(a2)
LEA     execbas(pc),a2
MOVE.l           a1,(a2)

LEA     rastprt(pc),a1         ;rastport sichern
MOVE.l           d0,(a1)

MOVE.l           d3,d0         ;max. areasteps
ADD.l            #1,d0         ;ein schritt zu maxsteps hinzu
MULU             #5,d0         ;mal 5,wegen rasteralloc.
LEA      msteps(pc),a0
MOVE.l           d0,(a0)       ;als maxsteps sichern

LEA        widt(pc),a1
MOVE.w           d1,(a1)
MOVE.w           d1,d0         ;width, should be windows max width
LEA        heit(pc),a1
MOVE.l           d2,(a1)
MOVE.l           d2,d1         ;height, should be windows max height
LEA      gfxbas(pc),a1
MOVE.l         (a1),a6
JSR   _allocraster(a6)
LEA         ras(pc),a1
MOVE.l           d0,(a1)       ;ras.l=AllocRaster_(640,256)
CMP.l #0,d0:BEQ noinit

LEA        widt(pc),a0        ;
MOVE.l         (a0),d0        ;
DIVU             #8,d0        ;
LEA        heit(pc),a0        ;
MOVE.l         (a0),d1        ;
MULU             d1,d0        ; MOVE.l #$14000,d0   ;(640/8)*256)

LEA         ras(pc),a0
MOVE.l         (a0),a1
LEA      tmpras(pc),a0
JSR    _inittmpras(a6)   ;err.l=InitTmpRas_(tmpras,buf.l,(640/8)*256)

LEA     execbas(pc),a0
MOVE.l         (a0),a6
LEA      msteps(pc),a1
MOVE.l         (a1),d0
MOVE.l      #$10001,d1
JSR      _allocmem(a6)
LEA        buff(pc),a0
MOVE.l           d0,(a0)     ;buff$=String$(" ",(msteps+1)*5)

CMP.l #0,d0:BEQ  noinit

LEA      gfxbas(pc),a0
MOVE.l         (a0),a6
LEA        buff(pc),a0
MOVE.l         (a0),a1
LEA     areainf(pc),a0  ;eigene structur
MOVE.l         #360,d0
JSR      _initarea(a6)  ;err.l=InitArea_(*ai.AreaInfo,&buff$,360)

LEA     rastprt(pc),a0
MOVE.l         (a0),a1
LEA      tmpras(pc),a0
MOVE.l           a0,SizeOf.RastPort\TmpRas(a1)     ;*rp\TmpRas=tmpras
LEA     areainf(pc),a0
MOVE.l           a0,SizeOf.RastPort\AreaInfo(a1)   ;*rp\AreaInfo=*ai
MOVEQ            #1,d0
BRA okinit
MOVEQ           #0,d0


LEA        widt(pc),a0   ;
MOVE.l         (a0),d0   ;MOVE.w         #640,d0
LEA        heit(pc),a0   ;
MOVE.l         (a0),d1   ;MOVE.w         #256,d1
LEA      gfxbas(pc),a0
MOVE.l         (a0),a6
LEA         ras(pc),a1
MOVE.l         (a1),a0
JSR    _freeraster(a6)   ;FreeRaster_ *ras,640,256

LEA     execbas(pc),a0
MOVE.l         (a0),a6
LEA      msteps(pc),a0   ;
MOVE.l         (a0),d0

LEA        buff(pc),a0   ;
MOVE.l         (a0),a1
JSR       _freemem(a6)
; d0=result

MOVE.l       d0,a1
LEA   patt1(pc),a0
MOVE.w       d1,(a0)+
MOVE.w       d2,(a0)+
MOVE.w       d3,(a0)+
MOVE.w       d4,(a0)

LEA   patt1(pc),a0
MOVE.l       a0,SizeOf.RastPort\AreaPtrn(a1)
MOVE.b       #2,SizeOf.RastPort\AreaPtSz(a1) ;heavy error last version

MOVE.l       d0,a1    ;rastprt
MOVE.l       d1,SizeOf.RastPort\AreaPtrn(a1)
MOVE.b       d2,SizeOf.RastPort\AreaPtSz(a1)

MOVE.l d0,a1
MOVE.w d1,SizeOf.RastPort\LinePtrn(a1)

MOVE.l d0,a1
MOVE.b d1,SizeOf.RastPort\AOlPen(a1)
; MOVE.w SizeOf.RastPort\Flags(a1),d0
; BSET   #3,d0
; MOVE.w d0,SizeOf.RastPort\Flags(a1)

MOVE.l  d0,a1
SUB.l   d0,d0
MOVE.w SizeOf.RastPort\Flags(a1),d0
CMP.b   #0,d1
BEQ dof
BSET    #3,d0
bck:MOVE.w d0,SizeOf.RastPort\Flags(a1)
dof:BCLR #3,d0:BRA bck

tmpras:  ;struct
Dc.l 0
Dc.l 0

areainf:Dcb.l 8,0

execbas:Dc.l 0
gfxbas: Dc.l 0
rastprt:Dc.l 0
ras:    Dc.l 0
msteps: Dc.l 0
buff:   Dc.l 0
widt:   Dc.w 0
heit:   Dc.w 0

patt1:  Dc.w 0,0,0,0

Re: Area-Commands (graphicslib) OLD! - hackball - 01.02.2014

Hier noch ein Beispiel:

;     AreaDemo 2
;     tests AreaCommands from RayAreaLib (C) by Frank Brandis


; setting up a screen

; Pal, HighRes, Interlace,8 Planes=255+1 Colors

Screen1,0,0,672,512,8,$8004,"this is a test",2,1

;then,open a window
; backdrop,noborder,activate

*rp=RastPort(1)  ;getting RastPort

     ;initialising AreaLib
If AreaInit(*rp,672,512,500)<>1 Then End    ;no succeed ????

; Pattern *rp,$AAAA,$AAAA,$AAAA,$AAAA ;check this out

OutlinePen *rp,1   ;sets the outline pen,(not needed)
Outline    *rp,On

While Joyb(0)<>1           ;while left button not hit

    Delay_1                ;DOSlib: waiting one frame

    x=Rnd(600)+10          ;starting new Polygone with random coords

    col.w =Rnd(254)+1      ;colour min. 1,max. 255

    Area x,y,col               ;starting new polygone

    b=Rnd(5)+3            ;minimum of 3 (more) coords,max. 8

    For a.b=1 To b
        x=Rnd(600)+10      ;random coordinates
        y=Rnd(536)+10      ;

        AreaStep x,y       ;setting next area point

    AreaFill               ;closing and drawing this polygone


ok.l=AreaFinit   ;try to freeing all memory


End   ;bye bye
*edit screenmode comment
*edit testprog lha added
*edit polygons are actually 4+ corners, Area starts the first one and Areasteps adds 3 or more...

Re: Area-Commands (graphicslib) OLD! - hackball - 01.02.2014

Hier noch ein paar (alte) Anwendungsbeispiele:


oder das hier noch:



Re: Area-Commands (graphicslib) OLD! - Blackbird - 01.02.2014

Sieht doch schonmal gut aus...!

Hast du schonmal getestet obs auf den NG-Maschinen auch läuft ?

Re: Area-Commands (graphicslib) OLD! - hackball - 01.02.2014

Was ist denn eine NG-Maschine bei dir? Nur GFX-Karte oder PPC/OS4?

Re: Area-Commands (graphicslib) OLD! - Blackbird - 01.02.2014

nicht nur OS4 sondern auch MOS

wenns auf Graka läuft, dann besteht die Hoffnung das es auch dort funktioniert...

ich habe jetzt nicht weiter im Source geschnüffelt, deswegen die Frage

Re: Area-Commands (graphicslib) OLD! - hackball - 01.02.2014

Das sind Standard-OS-Aufrufe in die GFXlib. Allerdings m68k. Ob das auf OS4/MOS dann Chipmem alloziert, weiß ich aber nicht. GFX-Kartenbetrieb hatte ich zumindest mit dem Vectoreditor schon getestet, das ging.

Re: Area-Commands (graphicslib) OLD! - Blackbird - 01.02.2014

wenn du executabels hast zum testen, dann kann ich auf beiden mal probieren wenn du willst....

Re: Area-Commands (graphicslib) OLD! - hackball - 03.02.2014

Das mit den RTG-Screens läuft noch nicht so automatisch, wie ich mir das dachte. z.B. bekomme ich einen RTG-8 Bit Screen, aber sehe nur einen kleinen Ausschnitt. Aber laufen tut es:-)

Re: Area-Commands (graphicslib) OLD! - hackball - 30.03.2014

Ich glaube, ich weiß (wieder), warum es manchmal crasht. Die maximale Anzahl an Area-Steps wird nicht gecheckt. da müßte man einen Branch einbauen oder einen Fehler werfen.

LEA      gfxbas(pc),a0
MOVE.l         (a0),a6
LEA        buff(pc),a0
MOVE.l         (a0),a1
LEA     areainf(pc),a0  ;eigene structur
MOVE.l         #360,d0   ;<<<<<   hard coded max steps for polygon !!!
JSR      _initarea(a6)  ;err.l=InitArea_(*ai.AreaInfo,&buff$,360)

*Edit: gfxbase könnte man auch direkt nach a6.... usw.