*---------------------------------------------------------------------- * File Name: io.asm * * Copyright (c) 1994 Sega of America, Inc. All Rights Reserved. * * Author(s): Unni Pillai * Date: 6-06-94 * Description: Contains IO READ routines, accessed from within VBL * History: * *---------------------------------------------------------------------* section .text nolist include "io.i" ; references for file io.asm include "marequ.h" ; mars equates list *------------------------------------------------------------------------- * _Read_IO: reads value from the FP6B, and buffers the obtained values * * void _Read_IO() * in - * out .bss variable KeyTable1 (buffer containing the following: * 0 .w current value * 2 .w changed value * 4 .w held down values * IOerrFlag1 (only if error) * MODS * name date comments * ---- -------- ------------------------------------- * UP 06/19/94 created *---------------------------------------------------------------------- xdef Read_IO dc.l 0 Read_IO: cmp.b #$0d,idcode1 ;no? check if FP6B attached to port 1 beq fp6b_01 ;yes? get FP6B data on port 1 readioexit: rts ;return to VBI fp6b_01: moveq #0,d1 jsr JOYGET6 ;read FP6B attached to port 1 tst.l d0 ;check error condition beq readerror ;error occurred,return to call bsr storeIO ;store value not.w d0 ;make active 1's lea KTable1,a1 ;buffer containing previous values moveq #0,d1 moveq #0,d2 move.w (a1),d1 ;obtain previous values move.w d1,d2 eor.w d0,d1 ;d1 contains only changed bits and.w d0,d2 ;d2 contains only previously held down bits move.w d0,(a1)+ ;store latest value move.w d1,(a1)+ ;store changed value move.w d2,(a1)+ ;store held down bits jmp readioexit readerror: st IOerrFlag1 jmp readioexit *------------------------------------------------------------------------- * _storeIO: stores pad key press values into buffer (KeyTab1) * * void _storeIO() * in d0.l contains output from JOYGET6 * out .bss variable KeyTab1 (buffer containing the following: * 0 .w * MODS * name date comments * ---- -------- ------------------------------------- * UP 07/05/94 created * NOTE * This routine is based on routine ScanJoy1 from LOGODEMO, written by * Andy Onions of RealTime Software. *---------------------------------------------------------------------- xdef storeIO dc.l 0 storeIO: movem.l d0-d1/a0,-(a7) lea KeyTab1,a0 ;point to button status table moveq #16-1,d1 ;16 buttons sj_key lsr.w #1,d0 ;check bit bcs.s sj_up ;skip if up(i.e. button not pressed) tst.b (a0) ;test held status bne.s sj_next ;skip if already down(i.e. held down previous) st KeyHit ;flag hit occurred (global) move.w #$101,(a0) ;flag hit and held bra.s sj_next ;next bit sj_up clr.b (a0) ;not held (leave hit status) sj_next addq.w #2,a0 ;next status entry dbra d1,sj_key ;do all bits movem.l (a7)+,d0-d1/a0 rts *------------------------------------------------------------------------- * _ClearKeys: clears buffer key press values (KeyTab1) * * void _ClearKeys() * in * out * MODS * name date comments * ---- -------- ------------------------------------- * UP 07/05/94 created * NOTE * This routine is based on routine ClearKeys from LOGODEMO, written by * Andy Onions of RealTime Software. *---------------------------------------------------------------------- xdef ClearKeys dc.l 0 ClearKeys: sf KeyHit ;flag no key hit lea KeyTab1+1,a0 ;point at hit entries moveq #15-1,d0 ;15 entries .ck_lp sf (a0)+ ;clear hit flag addq.w #1,a0 ;index next hit status dbra d0,.ck_lp ;do all rts ****************************************************************************** * _MDtoMARS transfers position and button press value to the MARS via * communication registers. * Communication occurs under the following assumption: * Communication register 0 i.e $a15120 contains semaphore. * MD tests the status of the semaphore before attempting to * write to the communication registers. * void _MDtoMARS() * Input: * Output: *----------------------------------------------------------------------------* * New Products Engr Dept. PD at SOA * Unni Pillai 05/31/94 *----------------------------------------------------------------------------* * MODS * name date comments * ---- ----- -------------------------------------------- * UP 05/31/94 created ****************************************************************************** xdef MDtoMARS dc.l 0 MDtoMARS: lea KTable1,a0 ;array contains position and button data move.b comm0(a5),ComLock .waitforMARS bset.b #7,ComLock bne .waitforMARS move.w (a0)+,comm2(a5) ;store current value in register 2&3 move.w (a0)+,comm4(a5) ;store changed bits in register 4&5 move.b #0,ComLock ;return communication port to MARS move.b ComLock,comm0(a5) rts