; Justice Unlimited Gadget Microcode ; (C) 2004 Nathan (Acorn) Pooley ; ; gtime.inc ; ;@DOC@ code to remember what time it is ; ;############################################ ;############### TIME ####################### ;############################################ ; ; NOTE: DO NOT USE v_tmp* VARIABLES HERE!!! ; ; ; resolve time by adding any accumulated seconds ; and checking for timed events ; time: btfsc b_showing_time bsf b_spinchange ; set spinchanged if showing time movf v_time_addsec,w ; extra seconds bz time_done ; nothing to do? subwf v_time_addsec,f ; atomically decrease addsec addwf v_time_s,f ; add seconds movf v_time_s,w addlw LOW -60 bnc time_events movwf v_time_s incf v_time_m,f ; add minutes movf v_time_m,w addlw LOW -60 bnc time_events movwf v_time_m incf v_time_h,f ; add hours movf v_time_h,w addlw LOW -48 ; wrap time at 48 hours bnc time_events bsf b_game_over clrf v_time_h time_events: #if 0 addwf v_cluetime_s,f ; add seconds movf v_cluetime_s,w addlw LOW -60 bnc time_events2 movwf v_cluetime_s incf v_cluetime_m,f ; add minutes movf v_cluetime_m,w addlw LOW -60 bnc time_events2 movwf v_cluetime_m incf v_cluetime_h,f ; add hours movf v_cluetime_h,w addlw LOW -48 ; wrap time at 48 hours bnc time_events2 #endif time_events2: btfsc b_game_over ; after game ends, no event occur bra time_checksleep ; ; TODO: check for timed events ; time_checksleep: dcfsnz v_off_cnt,f ; time to turn off? bsf b_sleep ; time to go to sleep (or turn off or...) time_done: return ;############################################ ;############### SLEEP TIME ################# ;############################################ ; ; NOTE: DO NOT USE v_tmp* VARIABLES HERE!!! ; ; ; reset time before sleep occurs ; reset_sleep_time: movlw SLEEP_TIME ; ; set time until b_sleep gets set ; w = time in sec (actual time ranges from w-1 to w sec) ; set_sleep_time: movwf v_sleeptime_tmp rcall time movff v_sleeptime_tmp, v_off_cnt btfss b_turn_off bcf b_sleep return |
This file Copyright (C) 2004 by Nathan (Acorn) Pooley
Go to DRUID Development page
Go to DRUID page
Go to JU Gadgets page
Go to Justice Unlimited homepage
Go to Acorn's personal webpage
Contact Acorn
See comments from others
Post your own comments
File created by do_doc at Wed Aug 4 18:03:20 2004