XDEF Water XREF __SEG_END_SSTACK,grow_lights,PORT_T,display_string,disp,is_watering,PORT_S,PORT_P,sprinkler_event,word_out,SPRINKLER_ARR,byte_out,sprinkler_arr_i Constants: Section ;STEP_ARR dc.b $0A,$12,$14,$0C,$0 ;array sequence to spin motor ARRAY_LENGTH dc.b $04 Variables: Section Water: ;push register and accumulator values for retention PSHA PSHB PSHD PSHX PSHY ;get out of here if we should not be watering (don't do anything with sprinkler) or the display LDAB is_watering CMPB #$FF LBNE Return ;sprinkler stuff LDAB sprinkler_event ;check the event flag CMPB #$FF ;all 1's indicates that the event has fired, if it's not equal, show watering LBNE ShowWatering ;still display the watering... message ;handle sprinkle event LDAB sprinkler_arr_i ;check which array position we are at INCB ;go to next index STAB sprinkler_arr_i ; ^ CMPB #8 ;check if we have reached the end of the array BLT Continue ;continue if not at the end of the array MOVB #$00,sprinkler_arr_i ;reset the array index to the beginning LDAB #$00 Continue: LDX #SPRINKLER_ARR ABX STX word_out LDAA 0,X STAA PORT_P STAB byte_out CLR sprinkler_event ;... ShowWatering: ;print the temperature movb #'W',disp movb #'a',disp+1 movb #'t',disp+2 movb #'e',disp+3 movb #'r',disp+4 movb #'i',disp+5 movb #'n',disp+6 movb #'g',disp+7 movb #'.',disp+8 movb #'.',disp+9 movb #'.',disp+10 movb #' ',disp+11 movb #' ',disp+12 movb #' ',disp+13 movb #' ',disp+14 movb #' ',disp+15 ;next line movb #' ',disp+16 movb #' ',disp+17 movb #' ',disp+18 movb #' ',disp+19 movb #' ',disp+20 movb #' ',disp+21 movb #' ',disp+22 movb #' ',disp+23 movb #' ',disp+24 movb #' ',disp+25 movb #' ',disp+26 movb #' ',disp+27 movb #' ',disp+28 movb #' ',disp+29 movb #' ',disp+30 movb #' ',disp+31 movb #0,disp+32 ;string terminator, acts like '\0' LDD #disp ;both of these steps are necessary to jsr display_string ;print to the LCD screen Return: ;restore registers and accumulators PULY PULX PULD PULB PULA RTS