Themabewertung:
  • 0 Bewertung(en) - 0 im Durchschnitt
  • 1
  • 2
  • 3
  • 4
  • 5
Area-Commands (graphicslib) OLD!
#1
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.

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



#rayarealib=22

; 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}

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

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

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

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

!astatement
!args {#long,#word,#word,#word,#word}
!libs
!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}
!args
!libs {#execlib,#la6}
!subs {_areafinit,0,0}
!name {"AreaFinit","  BOOLEAN TRUE if success"}

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

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

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

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

!libfin

._areastart
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
RTS

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

._areacirc
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
RTS
RTS

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

.
._areainit
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
noinit:
MOVEQ           #0,d0
okinit:
RTS

._areafinit

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
RTS

.
._setptrn
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
RTS

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

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

._setolpen
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)
RTS

._oline
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)
RTS
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
Even
Zitieren
#2
Hier noch ein Beispiel:

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


DEFTYPE.w


; 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
Window1,0,0,672,512,$1900,"",1,0


*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
    y=Rnd(536)+10

    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
    Next

    AreaFill               ;closing and drawing this polygone

Wend



ok.l=AreaFinit   ;try to freeing all memory

CloseWindow1
CloseScreen1

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...
Zitieren
#3
Hier noch ein paar (alte) Anwendungsbeispiele:

   

oder das hier noch:

       


   
Zitieren
#4
Sieht doch schonmal gut aus...!

Hast du schonmal getestet obs auf den NG-Maschinen auch läuft ?
Zitieren
#5
Was ist denn eine NG-Maschine bei dir? Nur GFX-Karte oder PPC/OS4?
Zitieren
#6
PPC.
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
Zitieren
#7
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.
Zitieren
#8
wenn du executabels hast zum testen, dann kann ich auf beiden mal probieren wenn du willst....
Zitieren
#9
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:-)
Zitieren
#10
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.

Code:
...
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.
Zitieren


Gehe zu:


Benutzer, die gerade dieses Thema anschauen: 2 Gast/Gäste