NEW
  AUTO 3,1
*--------------------------------------
* MBAR.New(*S.MBITEM mbitems)
*--------------------------------------
MBAR.New		>LDYAI S.MBAR
				>SYSCALL2 getmem
				bcs .99

				>STYA ZPObjPtr
				
				lda #S.OBJ.T.MBAR
				sta (ZPObjPtr)			S.OBJ.T

				lda #0

				ldy #S.MBAR-1

.1				sta (ZPObjPtr),y
				dey
				bne .1

				>PULLA
				ldy #S.MBAR.MBITEMS
				sta (ZPObjPtr),y
				>PULLA
				iny
				sta (ZPObjPtr),y

				
				clc
				rts
*--------------------------------------
MBAR.Init		>STYA ZPMENUPtr
				>STYA ZPPtr1

				ldy #S.MBITEM.S
				lda (ZPPtr1),y
				bmi .80
				
				stz	DX
				stz DX+1
	
.1				lda (ZPPtr1)
				beq .8
				
				lda #S.MBITEM.TEXT
				clc
				adc ZPPtr1
				tay
				lda ZPPtr1+1
				adc #0
				
				ldx hSYSFON
				jsr FON.GetTextSize
				
				ldy #S.MBITEM.X1

				lda DX
				sta (ZPPtr1),y

				iny

				lda DX+1
				sta (ZPPtr1),y
				
				iny						#S.MBITEM.XT
				
				lda DX
				clc
				adc PREFS.MBARXMARGIN
				sta DX
				sta (ZPPtr1),y

				iny

				lda DX+1
				adc #0
				sta DX+1
				sta (ZPPtr1),y
				
				lda DX
				clc
				adc CB.CACHE+S.CB.SrcW
				sta DX

				lda DX+1
				adc CB.CACHE+S.CB.SrcW+1
				sta DX+1

				iny						#S.MBITEM.X2

				lda DX
				clc
				adc PREFS.MBARXMARGIN
				sta DX
				sta (ZPPtr1),y

				iny
				
				lda DX+1
				adc #0
				sta DX+1
				sta (ZPPtr1),y
				
				lda (ZPPtr1)
				clc
				adc ZPPtr1
				sta ZPPtr1
				bcc .1
				inc ZPPtr1+1
				bra .1
				
.8				lda #$80

				ldy #S.MBITEM.S
				sta (ZPMENUPtr),y
				
.80				clc
				rts
*--------------------------------------
MAN
SAVE usr/src/lib/libgui.s.mbar
LOAD usr/src/lib/libgui.s
ASM
