; Justice Unlimited Gadget Microcode ; (C) 2004 Nathan (Acorn) Pooley ; ; gadget.asm ; ;@DOC@ Main gadget source file - includes all other files ; include <def_18252.inc> __CONFIG 0x300001,0x20 __CONFIG 0x300002,0x0d __CONFIG 0x300003,0x0e __CONFIG 0x300005,0x01 __CONFIG 0x300006,0x81 __CONFIG 0x300008,0x0f __CONFIG 0x300009,0xc0 __CONFIG 0x30000a,0x0f __CONFIG 0x30000b,0xe0 __CONFIG 0x30000c,0x0f __CONFIG 0x30000d,0x40 RADIX DEC include <gdefs.inc> #define SIM 0 ; 1 = using simulator ; 0 = using hardware #define DEBUG 1 #define DEBUG_BITS 0 #define REPORT_ERRORS 1 #define SIMULATE_SERIAL SIM ; disable serial #define TEST_INPUT 0 ; just run NOPs when input occurs #define CHECK_TABLES 1 ; ensure table does not cross ; page boundaries #define SIMULATE_INPUT SIM ; use rb0, rb1, rb2 to sim input #define USE_PUTL 1 ; use putl instead of clear scrn #define ENABLE_TEST_MODE 0 ; enter test mode if B4=0 #define INTERNAL_WATCHDOG 1 ; watch for hangs #define SIMULATE_NOTIMEOUT SIM ; do not turn off automatically #define SIMULATE_BP SIM ; use sim breakpoints #define USE_ENTMASK 1 ; use entry mask #define PARANOID_PUTC 1 ; latch data more carefully #define QUICK_TURNON 1 ; check spinner more often #define default_mode mode_main_menu ; TODO: when does game really ; start??? GAME_START_HOUR EQU 10 ; GAME STARTS at 10am SS_TX_ADDR EQU 0x50 ; transmit address for display SS_RX_ADDR EQU 0x51 ; receive address for display ; ; debounce time = 0.1 sec ; use prescale of X4 ; ((32768/4)/4) * 0.1 = 204 ; DEBOUNCE_CNT EQU 204 ; was 204 HOLD_CNT EQU 10 ; 10X debounce count (1 sec) SLEEP_NOSPIN_TIME EQU 136 ; time spinner is off OFF_NOSPIN_QTIME EQU 175 ; time spinner is off (QUICK) OFF_NOSPIN_TIME EQU 1 ; 1 sec between checks when off TURN_ON_WAIT_TIME EQU 10 ; debounce on button BSR_DEFAULT EQU 1 ; bank1 is default SLEEP_TIME EQU 2 ; SLEEP after this long with ; no input activity (sec) SLEEP_OFF_TIME EQU 14 ; Sleep time before off (sec) SLEEP_OFF_TIME_LIGHT EQU 4 ; ... faster if light on ;############################################ ;############### VARIABLES ################## ;############################################ include <gvars.inc> include <gmacros.inc> ;############################################ ;############### VECTORS #################### ;############################################ ; ; RESET ; org 0x0000 goto init #if SIMULATE_BP org 0x002e bp_error: return bp_sim_input: ; after display is updated return bp_input: ; when new input is about to be processed return bp_load_mode: ; start of load mode return bp_load_mode2: ; just before branching based on mode type return bp_end: #endif ; ; high priority interrupt - button inputs ; org 0x0008 movf PORTB,w ; get bits bcf b_rbif ; clear interrupt condition movwf INDF1 ; store into buffer incf FSR1L,f bsf b_got_input ; signal input is pending andwf v_bnopush,w ; deal with clicks? bnn isr_button ; more to do if button is or was pushed retfie 1 ; ; low priority interrupt - timers, etc ; org 0x0018 movwf v_isr_save_w ; save registers movff STATUS,v_isr_save_status btfsc b_tmr0if ; timer0? bra isr_timer0 btfsc b_tmr2if ; timer2? bra isr_timer2 ;bra error_badint_low ; cannot do this - b_tmr2if may get ; cleared by higher priority interrupt ;############################################ ;############### isr_return ################# ;############################################ isr_return: movf v_isr_save_w,w movff v_isr_save_status,STATUS retfie #if SIMULATE_BP bp_begin: org bp_end #endif ;############################################ ;############### MAIN JUMP TABLE ############ ;############################################ ; ; function table ; jump to function indexed by w ; main_jump: #if CHECK_TABLES movwf v_tmp addlw LOW -(func_max+1) btfsc STATUS,C bra error_jump movf v_tmp,w #endif include <gfuncs.inc> main_jump_end: #if SIM nop ; this is so main_jump_end != putc_special #endif snd_hi: goto snd_hi_l snd_med: goto snd_med_l snd_lo: goto snd_lo_l fn_sync: goto fn_sync_1 ;############################################ ;############### SPECIAL CHARACTER TABLE #### ;############################################ ; ; special characters ; putc_special: #if CHECK_TABLES movf v_putc_save_w,w andlw 0x7f ; take off hi bit addlw LOW -((putc_jump_end-putc_jump_first)/2) btfss STATUS,N bra error_bad_sc #endif movf v_putc_save_w,w addwf v_putc_save_w,w ; double it (removes hi bit and ; double for jump table) putc_jump_start: addwf PCL putc_jump_first: include <gschar.inc> putc_jump_end: ;############################################ ;############### INTERRUPT SERVICE ########## ;############################################ include <gtime_isr.inc> include <ginput_isr.inc> ;############################################ ;############### TIME ####################### ;############################################ include <gtime.inc> ;############################################ ;############### INPUT ###################### ;############################################ include <ginput.inc> ;############################################ ;############### ERRORS ##################### ;############################################ include <gerror.inc> ;############################################ ;############### OUTPUT ##################### ;############################################ include <gout_par.inc> include <gout_com.inc> include <gread.inc> ;############################################ ;############### MODE ####################### ;############################################ include <gmode.inc> include <gcode.inc> include <gpuzzles.inc> ;############################################ ;############### EVENTS ##################### ;############################################ include <gevent.inc> ;############################################ ;############### OTHER STUFF ################ ;############################################ include <gutil.inc> ;############################################ ;############### INIT ####################### ;############################################ include <ginit.inc> ;############################################ ;############### MAIN LOOP ################## ;############################################ include <gmain.inc> ;############################################ ;############### TEST ####################### ;############################################ include <gsound.inc> include <gtest.inc> ;############################################ ;############### DATA ####################### ;############################################ include <gstrings.inc> include <zend.inc> ;############################################ ;############### BAD PC ERROR ############### ;############################################ org 0x7ffc goto error_badpc ;############################################ ;############### END ######################## ;############################################ end |
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 17:51:28 2004