; 11/27/1996 kth ; kcal 0.2b @program prog_code,prog_name include kevin.h ; 11/30/96 improved box code / skip unneeded prog_code: drawcal: jsr flib[clr_scr] ;drawbox #0,xval,#239,#127 drawbox #0,#0,#239,#121 ;x y str color ;char* buf char* fmt arg... setfont #2 move.w year,-(a7) ; arg pea numfmt(PC) ; fmt pea numtemp(PC) ; buf jsr romlib[sprintf] lea 10(a7),a7 move.w #0001,-(a7) ; color pea numtemp(PC) ; Variable of string to print move.w #11,-(a7) ; y move.w #135,-(a7) ; x jsr romlib[puttext] ; ROM call to puttext lea 10(a7),a7 ; Clear the stack setfont #1 putstr #1,#1,#0,titlestr drawbox #14,#33,#14+7*30,#33+6*14 drawbox #14,#24,#14+7*30,#32 putstr #14,#25,#0,daynames move.w #33,yval ;leap year? ;if ((($year % 4)==0) && ((($year%100)>0) || (($year%400)==0))) { ; 1; ;} else { ; 0; ;} move.b #0,leapflag ;init to 0 move.w year,d0 divu.w #4,d0 swap d0 cmp.w #0,d0 bne notleap clr.l d0 move.w year,d0 divu.w #100,d0 swap d0 cmp.w #0,d0 bgt setleap clr.l d0 move.w year,d0 divu.w #400,d0 swap d0 cmp.w #0,d0 beq setleap bra notleap setleap: move.b #1,leapflag notleap: ;length of month gomoday: move.w #31,monthdays cmp.w #2,month bne tm4 move.w #28,monthdays cmp.b #1,leapflag bne tmdone add.w #1,monthdays bra tmdone tm4: cmp.w #4,month bne tm6 move.w #30,monthdays bra tmdone tm6: cmp.w #6,month bne tm9 move.w #30,monthdays bra tmdone tm9: cmp.w #9,month bne tm11 move.w #30,monthdays bra tmdone tm11: cmp.w #11,month bne tmdone move.w #30,monthdays bra tmdone tmdone: godow: ;compute day of week for first day of month move.w year,dow_yr move.w month,dow_mn cmp.w #2,dow_mn bgt dow_cont add.w #12,dow_mn sub.w #1,dow_yr dow_cont: clr.l d0 move.w dow_mn,d0 add.w #1,d0 mulu.w #26,d0 divu.w #10,d0 ;n1=(26*(mn+1))/10 move.w d0,dow_n1 clr.l d0 move.w dow_yr,d0 mulu.w #125,d0 divu.w #100,d0 ;n2=(int) ( ( 125* (long) yr) / 100); move.w d0,dow_n2 move.w dow_n1,d0 move.w dow_n2,d1 add.w d0,d1 clr.l d0 move.w dow_yr,d0 divu.w #100,d0 sub.w d0,d1 clr.l d0 move.w dow_yr,d0 divu.w #400,d0 add.w d0,d1 move.w d1,dow_n1 clr.l d1 move.w dow_n1,d1 divu.w #7,d1 swap d1 move.w d1,dow ; day=((date+n1+n2-(yr/100)+(yr/400)-1)%7); move.w #0,d6 ; start of month move.w #0,daynum move.b #0,flipflag move.w #5,d5 ystart: move.w #14,xval move.w #6,d4 xstart: eor.b #1,flipflag cmp.w dow,d6 blt calboxcont add.w #1,daynum move.w monthdays,d0 cmp.w daynum,d0 blt calboxcont move.w daynum,-(a7) ; arg pea numfmt(PC) ; fmt pea numtemp2(PC) ; buf jsr romlib[sprintf] lea 10(a7),a7 add.w #2,xval add.w #2,yval move.w #0001,-(a7) ; color pea numtemp2(PC) ; Variable of string to print move.w yval,-(a7) ; y move.w xval,-(a7) ; x jsr romlib[puttext] ; ROM call to puttext lea 10(a7),a7 ; Clear the stack sub.w #2,xval sub.w #2,yval calboxcont: add.w #1,d6 move.w xval,d2 move.w yval,d3 add.w #30,d2 add.w #14,d3 cmp.b #1,flipflag bne skipbox drawbox xval,yval,d2,d3 skipbox: add.w #30,xval dbra d4,xstart add.w #14,yval dbra d5,ystart setfont #2 move.w #1,-(a7) lea monthtable,a3 clr.l d4 move.l #10,d3 move.w month,d4 sub.w #1,d4 mulu.w d3,d4 add.l d4,a3 pea (a3) move.w #11,-(a7) ;y move.w #55,-(a7) ;x jsr romlib[puttext] lea 10(a7),a7 main_loop: jsr flib[idle_loop] test_up: cmp #338,d0 ; up bne test_down add.w #1,year cmp.w #10000,year blt drawcal move.w #1,year bra drawcal test_down: cmp #344,d0 ; down bne test_left sub.w #1,year cmp.w #0,year bgt drawcal move.w #9999,year bra drawcal test_left: cmp #337,d0 ; left bne test_right sub.w #1,month cmp.w #0,month bgt drawcal move.w #12,month sub.w #1,year ; inc year if month > december cmp.w #0,year bgt drawcal move.w #9999,year bra drawcal test_right: cmp #340,d0 ;right bne test_clr add.w #1,month cmp.w #13,month blt drawcal move.w #1,month add.w #1,year ; dec year if month < jan cmp.w #10000,year blt drawcal move.w #1,year bra drawcal test_clr: cmp #263,d0 bne test_mode move.w save_year,year move.w save_month,month bra drawcal test_mode cmp #266,d0 bne test_esc move.w year,save_year move.w month,save_month test_esc: cmp #$108,d0 bne main_loop rts ;***************************************************** prog_name: dc.b "Kcal 0.2 - Kevin Huber",0 titlestr dc.b "Kcal v0.2",223," Copyright ",169," 1996 Kevin Huber",0 ;1234567890123456789012345678901234567890 daynames dc.b " Sun Mon Tue Wed Thu Fri Sat ",0 xval dc.w 0 yval dc.w 0 xloop dc.w 0 yloop dc.w 0 year dc.w 1996 month dc.w 11 save_year dc.w 1996 save_month dc.w 11 flipflag dc.b 0 leapflag dc.b 0 dc.b 0 dow dc.w 5 dow_day dc.w 0 dow_yr dc.w 0 dow_mn dc.w 0 dow_n1 dc.w 0 dow_n2 dc.w 0 daynum dc.w 0 monthdays dc.w 30 numfmt dc.b "%d",0 numtemp dc.b " ",0 numtemp2 dc.b " ",0 monthtable: mjan dc.b "January ",0 mfeb dc.b "February ",0 mmar dc.b "March ",0 mapr dc.b "April ",0 mmay dc.b "May ",0 mjun dc.b "June ",0 mjul dc.b "July ",0 maug dc.b "August ",0 msep dc.b "September",0 moct dc.b "October ",0 mnov dc.b "November ",0 mdec dc.b "December ",0 ;msafety dc.b 0,0,0,0,0,0,0,0,0,0,0 ;*************** End of Fargo program **************** reloc_open add_library romlib add_library flib reloc_close end