; Justice Unlimited Gadget Microcode ; (C) 2004 Nathan (Acorn) Pooley ; ; gvars.inc ; ;@DOC@ Variable and Bit definitions ; ;############################################ ;############### STRUCTURES ################# ;############################################ ; ; MODE STRUCTURES ; STYPE_MASK EQU 0xc0 ; ; TEXT mode structure ; MTYPE_TEXT EQU 0x40 s_TXT_LEN EQU 0x00 ; size of entire structure s_TXT_CNT EQU 0x01 ; number of lines (also TYPE) s_TXT_STR_HI EQU 0x02 ; string id of first line s_TXT_STR_LO EQU 0x03 ; string id of first line s_TXT_ACTION EQU 0x04 ; mode to goto when clicked ; ; ENTRY mode structure ; MTYPE_ENTRY EQU 0x80 s_GST_LEN EQU 0x00 ; size of entire structure s_GST_MASK EQU 0x01 ; char type mask (also TYPE) s_GST_STR_HI EQU 0x02 ; string id of prompt string s_GST_STR_LO EQU 0x03 ; string id of prompt string s_GST_ACTION EQU 0x04 ; mode to goto when clicked ; ; CALL FUNCTION mode structure ; MTYPE_FUNC EQU 0xc0 s_FNC_LEN EQU 0x00 ; size of entire structure s_FNC_ID EQU 0x01 ; function to call (also TYPE) s_FNC_PARM1 EQU 0x02 ; load this into v_str_addrhi before calling s_FNC_PARM2 EQU 0x03 ; load this into v_str_addrlo before calling ; ; MENU mode structure ; MTYPE_MENU EQU 0x00 s_MNU_LEN EQU 0x00 ; size of entire structure s_MNU_CNT EQU 0x01 ; number of menu items (also TYPE) s_MNU_STR_HI EQU 0x02 ; string id of first line s_MNU_STR_LO EQU 0x03 ; string id of first line ; (menu item strings are next N strings) s_MNU_ACTION1 EQU 0x04 ; mode to goto when clicked on menu item 1 s_MNU_ACTION2 EQU 0x05 ; mode to goto when clicked on menu item 2 ; ... ;############################################ ;############### VARIABLES ################## ;############################################ #if 0 && DEBUG_BITS ; ; DEBUG BITS ; #define db_blink PORTA,0 #define db_no_ack PORTA,1 #define db_aa PORTA,2 #define db_bb PORTA,3 #define db_out_en_retry PORTA,4 #define db_error PORTA,5 ; used by error func #endif ; ; PORTB Bits ; #define but_click PORTB,7 ; click spinner #define but_spina PORTB,6 ; spinner input A #define but_spinb PORTB,5 ; spinner input B #define but_sync PORTB,1 ; synchronize time #define irrx PORTB,0 ; from ir detector #if ENABLE_TEST_MODE #define but_testmode PORTB,4 ; enter test mode if low #endif #if SIMULATE_INPUT #define but_click2 PORTB,3 ; click when toggled #define but_inc PORTB,2 ; increment spinval when toggled #define but_dec PORTB,1 ; decrement spinval when toggled #endif ; ; PORTC Bits ; #define disab_spinner TRISC,0 ; enable spinner when out low #define disab_display TRISC,1 ; enable display when low #define disab_light TRISC,2 ; enable light when high #define disab_sound TRISC,3 ; click speaker #define disab_irrx TRISC,4 ; enable ir receiver when low #define ser_io_tris TRISC,5 ; tristate serial io #define ser_io PORTC,5 ; serial io (bidirectional) ; ; BITS ; #define b_output_error v_bits1,0 ; error sending to display #define b_light v_bits1,1 ; backlight on #define b_spinwrap v_bits1,2 ; spinner can wrap #define b_got_input v_bits1,3 ; true if input buffer is ; not empty #define b_spinchange v_bits1,4 ; spinner value changed #define b_sleep v_bits1,5 ; go to sleep (if bit set) #define b_game_over v_bits1,6 ; set when game ends #define b_showing_time v_bits1,7 ; set if displaying time #define b_turn_off v_bits2,0 ; turn off NOW #define b_popping v_bits2,1 ; used in load_mode #define b_error_occurred v_bits2,2 ; set if error occurs #define b_num_started v_num_bits,0 ; used in number displaying #define b_num_overflow v_num_bits,1 ; overflowed number #define b_num_bad_digit v_num_bits,2 ; non numeric digit ; ; BYTES ; v_bits1 EQU 0x00 ; general purpose bits (see above) v_bits2 EQU 0x01 ; general purpose bits (see above) v_num_bits EQU 0x02 ; bits used for number calculations v_tmp EQU 0x03 ; temorary variables v_tmp2 EQU 0x04 v_tmp3 EQU 0x05 v_wait_cnt EQU 0x6c v_sleeptime_tmp EQU 0x58 ; tmp used in sleep_time funcs v_macsv_1 EQU 0x60 ; save values in debugging macros v_macsv_2 EQU 0x61 v_macsv_3 EQU 0x62 v_macsv_4 EQU 0x63 ; INPUT ISR Registers v_oldb EQU 0x10 ; old value of PORTB (spinner bits cleared) v_bnopush EQU 0x11 ; hi bit clear if any buttons were held in v_bdebounce EQU 0x12 ; recently toggled buttons clear v_bchanged EQU 0x13 ; (temporary) buttons recently toggled v_brelmask EQU 0x14 ; bits which may be released v_bhold_cnt EQU 0x15 ; countdown holding button in ; INPUT - used in input function v_inbuf_ptr EQU 0x16 ; tail of input buffer v_bval EQU 0x17 ; current button values v_spinval_old EQU 0x18 ; to see if val actually changed ; high level INPUT results v_spinval EQU 0x19 ; spinner (encoder) value v_spinmax EQU 0x1a ; max value for spinner v_bheld EQU 0x1b ; buttons that were held in ;v_spinval_init EQU 0x41 ; initial value of spinval (in enable_input) ; OUTPUT v_putc_save_w EQU 0x1c ; save w v_cpos EQU 0x1d ; temp for cursor position v_str_cnt EQU 0x1e ; temorary variables v_str_addrlo EQU 0x1f v_str_addrhi EQU 0x20 ; ; SOUND ; v_snd_val EQU 0x64 v_snd_duration1 EQU 0x65 v_snd_duration2 EQU 0x66 ; ; Character Definition ; v_chdef_cnt EQU 0x67 ; ; PUTNUM ; v_num_hi EQU 0x21 ; number to print (hi) v_num_lo EQU 0x22 ; number to print (lo) v_num_digit_hi EQU 0x23 ; digit to print (hi) v_num_digit_lo EQU 0x24 ; digit to print (lo) v_ptime_sec EQU 0x25 ; seconds to print v_ptime_min EQU 0x26 ; minutes to print ; PUTL v_putc_cnt EQU 0x27 ; running count of chars sent v_putl_savew EQU 0x28 ; temporary v_putl_linenum EQU 0x29 ; line number to draw (in low bit) ; GAME TIME v_time_addsec EQU 0x2a ; seconds to add to v_time_s v_time_s EQU 0x2b ; seconds v_time_m EQU 0x2c ; minutes v_time_h EQU 0x2d ; hours v_isr_save_w EQU 0x2e ; save W reg v_isr_save_status EQU 0x2f ; save STATUS reg ; ; Event priority: (highest priority first) ; ; 1) handle clicks ; 2) process input buffer ; 3) handle spinner-changed ; 5) handle timer events - TODO - not implemented yet ; ; ; TIMERS ; ; timer0 - system clock ; timer2 - debounce clock ; ; FUNCTION POINTERS (actually indices into function table) ; each one indicates what happens when an event occurs ; from highest priority to lowest priority ; NOTE: input is processed at highest priority v_func_btn0_click EQU 0x30 ; when spinner is clicked v_func_spinchange EQU 0x31 ; when spinner changes v_func_default EQU 0x68 ; default (usually 0 to do nothing) v_func_keepmode EQU 0x32 ; stay in current mode (or not) v_func_newmode EQU 0x33 ; set new mode v_func_event1 EQU 0x34 ; event pending - hi priority v_func_event2 EQU 0x35 ; event pending - v_func_event3 EQU 0x36 ; event pending - lo priority #if 0 v_func_parm1 EQU 0x37 ; parameter 1 to function v_func_parm2 EQU 0x38 ; parameter 2 to function #endif v_cluenum EQU 0x37 ; current clue number v_cluetime_h EQU 0x38 v_cluetime_m EQU 0x6d v_cluetime_s EQU 0x6e v_clue_str_hi EQU 0x71 v_clue_str_lo EQU 0x70 ; ; MODES ; #if 0 v_mode EQU 0x39 ; current mode v_mode_str_id EQU 0x3a ; string for current mode v_mode_type EQU 0x3b ; type of mode (See MTYPE_...) v_mode_choice EQU 0x3c ; last byte in mode struct v_mode_len EQU 0x3d ; first byte in mode struct ; (with type removed from hi 2 bits #else v_mode EQU 0x39 ; current mode v_mode_type EQU 0x3a ; type of mode (See MTYPE_...) v_mode_cnt EQU 0x3b ; # items in menu/text or mask in entry v_mode_str_hi EQU 0x54 ; first string in mode v_mode_str_lo EQU 0x55 ; first string in mode v_mode_action EQU 0x56 ; last byte in mode struct #endif ; ; ENTRY MODE ; v_entry_ptr EQU 0x3e ; pointer to entry buffer #if USE_ENTMASK #define b_entmsk_lower v_mode_cnt,0 ; a-z #define b_entmsk_upper v_mode_cnt,1 ; A-Z #define b_entmsk_digit v_mode_cnt,2 ; 0-9 #define b_entmsk_space v_mode_cnt,3 ; <space> #endif #if 0 ; ; SAVE PREVIOUS MODE ; v_mode_prev EQU 0x3f ; previous mode v_spinval_prev EQU 0x40 ; previous mode spinval v_spinval_start EQU 0x41 ; used to init spinval in setmode ; (not used if 0) #else ; ; MODE STACK ; v_modestack_ptr EQU 0x3f ; modestack pointer #endif ; ; IR LOOK ; v_ircnt EQU 0x69 ; # ir pulses recvd v_ircnt2 EQU 0x6b ; # times displayed ; ; OFF COUNTER ; v_off_cnt EQU 0x50 ; turn off when reaches 0 ; reset on input v_off_bval EQU 0x57 ; last known value of PORTB (when off) ; ; ERROR REPORTING ; #if REPORT_ERRORS v_errno EQU 0x6a v_hang_state EQU 0x42 ; if hang occurs, this is what was ; happening (0=unknown) #if 0 v_oerrcnt_restart EQU 0x43 ; restarts due to output error v_oerrcnt_noack EQU 0x44 ; noack output errors v_oerrcnt_en_retry EQU 0x46 ; retries during enable v_oerrcnt_bus EQU 0x47 ; bus collision output errors v_oerrcnt_wcol EQU 0x48 ; write collision output errors v_oerrcnt_nosspif EQU 0x4d ; no sspif output errors #endif v_cnt_turnon EQU 0x4e ; times turned on v_cnt_outenab EQU 0x4f ; output_enable calls #endif #define FIX_ENAB 1 #if FIX_ENAB v_en_cnt EQU 0x50 v_en_delay EQU 0x51 #endif ; ; SIMULATION MODES ; #if SIMULATE_SERIAL v_ssbuf_ptr EQU 0x49 v_ss_save_fsr0l EQU 0x4a v_ss_save_fsr0h EQU 0x4b #endif #if SIMULATE_INPUT v_si_oldb EQU 0x4c #endif ; ; DEBUGGING VARIABLES ; #if INTERNAL_WATCHDOG WATCH_TIME EQU 10 ; in seconds ; If v_time_addsec reaches ; WATCH_TIME then ; assume something is hung #endif ; ; BUFFERS ; BUF_MODESTACK EQU 0x300 ; mode stack BUF_MODESTACK_END EQU 0x380 ; end of mode stack BUF_EVENTS EQU 0x381 ; event buffer BUF_INPUT EQU 0x400 ; input buffer - bank 4 BUF_ENTRY EQU 0x500 ; entry buffer BUF_MODE EQU 0x580 ; info about current mode BUF_ENTCHARS EQU 0x581 ; entry buffer character table #if SIMULATE_SERIAL BUF_SIMSERIAL EQU 0x200 ; simserial buffer #endif ; ; SPECIAL USES FOR SPECIAL REGISTERS ; FSR0 - general purpose indirection reg ; FSR1 - input buffer head pointer ; FSR2 - used in low priority interrupts ; |
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:04:02 2004