load 'macros.dump' include 'driver.equ' include 'pl.equ' ;----------------------------------------------- ; ; Imported addresses ; ;----------------------------------------------- IMPORT D_FastMult IMPORT P_DrawTabs IMPORT P_Fix2Int IMPORT P_LShift IMPORT D_SelectFont IMPORT D_Set4Pat ;----------------------------------------------- ; ; Forward addresses and entries ; ;----------------------------------------------- ENTRY ruler_marks ;------------------------------------------------------------------------------ ; ; P_Do_Ruler () ; P_Do_Ruler PROC EXPORT ;Using P_RulerData input ppi:l,start:w,vis_start:w,vis_end:w,vert:w ; pass in necess. globals input hrulrect:l,vrulrect:l,portrect:l,contentrect:l,pagemode:w output mindist:w local max:w,min:w,gran:w,i:w,length:w,space:w local tmp:w,j:w,k:w,v_line:l,h_line:l,start_offset:w local dist:l,tmp_dist:l,min_pix:l,h_pos:l,v_pos:l,pos:l local v_end:l,ruleraddr:l,Q_Line:w,inch_min:w local tmprect:r,foorect:r BEGIN _PenNormal cmpw vis_start,vis_end jeq EXIT stz Q_Line stz length stzl dist movelong #ruler_marks,ruleraddr call D_Set4Pat,in=(#LightYellow:w) ; ; if (vert) lda vert jeq ELSE1 ; ; { moverect [vrulrect],tmprect moveword vis_start,tmprect moveword vis_end,tmprect+4 tool _ClipRect,in=(!tmprect:l) tool _PaintRect,in=(!tmprect:l) tool _SetPenSize,in=(#2:w,#1:w) call D_Set4Pat,in=(#Black:w) moverect [portrect],foorect moveword [contentrect]:#4,foorect+4 tool _ClipRect,in=(!foorect:l) subword [vrulrect]:#6,#2,s pushword #0 _MoveTo tool _Line,in=(#0:w,#P_VRulLength:w) tool _ClipRect,in=(!tmprect:l) movelong !tmp_dist,v_pos movelong !pos,h_pos movelong !Q_Line,v_line movelong !length,h_line moveword #4,start_offset subword [vrulrect]:#6,#2,a movefixword a,pos movefixword #P_MIN_VPIX,min_pix brl ENDIF1 ; ; } else { ELSE1 moverect [hrulrect],tmprect moveword vis_start,tmprect+2 moveword vis_end,tmprect+6 tool _ClipRect,in=(!tmprect:l) tool _PaintRect,in=(!tmprect:l) call D_Set4Pat,in=(#Black:w) moverect [portrect],foorect moveword [contentrect]:#6,foorect+6 tool _ClipRect,in=(!foorect:l) tool _MoveTo,in=(tmprect+2:w,#P_HRulTop+P_HRulWdth-7:w) tool _Line,in=(#640:w,#0:w) tool _MoveTo,in=([vrulrect]:#2:w,#P_HRulTop+P_HRulWdth-1:w) tool _Line,in=(#640:w,#0:w) tool _ClipRect,in=(!tmprect:l) movelong !pos,v_pos movelong !tmp_dist,h_pos movelong !length,v_line movelong !Q_Line,h_line moveword #2,start_offset subword [hrulrect]:#4,#7,a movefixword a,pos movefixword #P_MIN_HPIX,min_pix ; ; } ENDIF1 _PenNormal ; More inits. ; ; max = (short) Fix2Long(FixDiv(Int2Fix(vis_end-start),ppi))+1; spacelong subword vis_end,start,a pushfixword a pushlong ppi _FixDiv pulllong ax rcall P_Fix2Int,in=(ax:ax) inc a sta max ; ; min = (short) Fix2Long(FixDiv(Int2Fix(vis_start-start),ppi))-1; spacelong subword vis_start,start,a pushfixword a pushlong ppi _FixDiv pulllong ax rcall P_Fix2Int,in=(ax:ax) dec a sta min ; ; ---- movefixword vis_end,v_end ; ; for (gran=7;(dist=0);gran--) moveword #7,gran brl FOR1 ; ; { LOOP1 ; dist = ppi / (1<=min;i-=space) lda #0 sta i bra FOR6 LOOP6 subword i,space,i FOR6 scmpw a,min bge LOOP6 ; ; tmp_dist = FixMul(ppi,Int2Fix(i)) + Int2Fix(start+start_offset); addword start,start_offset,s pushword #0 tool _FixMul,in=(ppi:l,i:w,#0:w),out=(:l) addlong 1:s,5:s,tmp_dist ply ply ply ply lda pagemode bne ENDIF7 addword space,space,a addword a,i,i addlong tmp_dist,dist,tmp_dist addlong tmp_dist,dist,tmp_dist ENDIF7 ; ; for (;i<=max;i+=space,tmp_dist+=dist) brl FOR8 LOOP8 rcall P_Fix2Int,in=([h_pos]:ax),out=(a:a) pha rcall P_Fix2Int,in=([v_pos]:ax),out=(a:a) pha _MoveTo subword #0,i,a bpl GOTJ lda i GOTJ tool _UDivide,in=(a:w,#10:w),out=(j:w,k:w) lda k beq NO_K addword a,#'0',a pha _DrawChar bra DRAW_J NO_K lda vert beq DRAW_J tool _DrawChar,in=(#' ':w) tool _DrawChar,in=(#' ':w) DRAW_J addword j,#'0',a pha _DrawChar lda vert beq HorizScritch pushword #3 pushword #0 pushword #62 rcall P_Fix2Int,in=([v_pos]:ax) subword a,#4,a pha bra CONT8 HorizScritch pushword #0 pushword #1 rcall P_Fix2Int,in=([h_pos]:ax) dec a dec a pha pushword #3 CONT8 _MoveTo _Line addword i,space,i addlong tmp_dist,dist,tmp_dist FOR8 scmpw max,i jge LOOP8 ENDFOR8 EXIT lda vert bne gone call P_DrawTabs gone return ENDP ;---------------------------------------------------------- P_RulerData PROC EXPORT EXPORT ruler_marks ; 2 8 32 128 th of an inch ; 1 ; 4 ; 16 ; 64 ; ruler_marks DC.W -5,-4,-3,-2,-1,-1,-1,-1 DC.W -11,-8,-6,-4,-2,-2,-2,-2 ;P_VisLMarg ds 2 ; what are these? ;P_VisIndent ds 2 ;P_VisRMarg ds 2 ENDP END