*---------------------------------------------------------------------- * File Name: mdapp.asm * * Copyright (c) 1994 Sega of America, Inc. All Rights Reserved. * * Author(s): Unni Pillai * Date: 07-01-94 * Description: Contains routines executed from the main loop, and also * routine executed immediately after MSInit. * History: * name date comments * ---- ---- -------------------------------------- * up 07/14/94 modified mapp1 * * Note: lbeven is a dummy label. This label is needed since the * Sierra Assembler 3.1 needs absolute addresses for * conditional statements. All files with print strings * must have this label at the begining of the section. *---------------------------------------------------------------------* nolist section .text lbeven: include "mdapp.i" ; references include "vdp.h" ; vdp equates include "varequ.h" ; mars equates include "mdcon.mac" ; macros include "io.h" ; some io equates include "io.mac" ; io macros list *------------------------------------------------------------------------ * _Mapp1: Sets up the text string which undergoes * color cycling in vbl. This routine makes references to * routine console and related macros. * * void _Mapp1( ) * MODS * name date comments * ---- -------- ----------------------------------------- * UP 06/19/94 created * UP 07/14/94 scripted out strings except "current value" *------------------------------------------------------------------------ xdef Mapp1 ; global define dc.l 0 Mapp1: st mflag lea mainlpstr,a0 jsr console nop rts mainlpstr: * C_ATTR 1+Pal1 * C_POS 4,4 * dc.b 'MAIN APPLICATION' * ALIGNODD C_ATTR 1+Pal0 C_POS 1,1 dc.b 'Value' * ALIGNODD * C_POS 2,15 * dc.b 'value read from com2' ** C_ATTR 1+Pal1+Pri * C_POS 2,14 * dc.b 'Changed BITS' * C_POS 4,5 * dc.b 'occurs during VBL' C_STOP *------------------------------------------------------------------------ * _Mapp2: This routine prints the latest pad press values onto * the display screen. references made to B_PRINT, and * binhex. executed from within the main application loop. * * void _Mapp2( ) * MODS * name date comments * ---- -------- ----------------------------------------- * UP 06/19/94 created * UP 07/14/94 changed row address to start from row 1,col7 * (previously row10). also loop counter value * changed to 0 *----------------------------------------------------------------------------- xdef Mapp2 ; global define dc.l 0 Mapp2: movem.l d0-d2/a0-a2,-(a7) lea KTable1,a2 ;06/23/94 move.l #$00070001,d2 ;col 7 row 1 * move.l #$0018000d,d2 ;col 24 row 13 moveq #0,d1 ;clear d1 * moveq #2-1,d1 ;load counter value moveq #0,d1 .prtlp1: move.w (a2)+,d0 ;get value lea textbuff,a0 jsr binhex ;converts value to hex move.b #0,(a0) ;flag lea textbuff,a1 move.l d2,d0 ;move col/row address to d0 (input to B_PRINT) jsr B_PRINT ;print to screen addq.w #$0001,d2 ;add one row dbra d1,.prtlp1 ;loop till done mapp2exit: movem.l (a7)+,d0-d2/a0-a2 rts *------------------------------------------------------------------------ * _Mapp3: This routine is a redundant routine, which prints values * from comm ports. prints the latest value passed to the * MD-SH comm regs. references made to B_PRINT, and binhex * * void _Mapp3( ) * MODS * name date comments * ---- -------- ----------------------------------------- * UP 06/29/94 created * UP 07/14/94 changed row address *------------------------------------------------------------------------ xdef Mapp3 ; global define dc.l 0 Mapp3: movem.l d0/d1/d2/a0/a1/a2,-(a7) moveq #0,d0 moveq #0,d1 lea marsreg,a2 adda.l #$22,a2 move.b (a2)+,d0 ;obtain value (most significant byte) move.w d0,d1 move.b (a2)+,d0 ;least significant byte lsl.w #8,d1 or.w d1,d0 lea textbuff,a0 jsr binhex move.b #0,(a0) lea textbuff,a1 move.l #$0018000f,d0 ;col/row address jsr B_PRINT movem.l (a7)+,d0/d1/d2/a0/a1/a2 rts *------------------------------------------------------------------------ * _Mapp4: Highlights the display, based on joypad press. * references made to console * Executed from within the main loop. * * void _Mapp4( ) * MODS * name date comments * ---- -------- ----------------------------------------- * UP 06/30/94 created *------------------------------------------------------------------------ xdef Mapp4 ; global define dc.l 0 Mapp4: moveq #0,d0 ; clear d0 lea KTable1,a0 ; array containing pad presses move.w (a0),d0 ; d0 contains latest pad press and.w #$ffff,d0 ; mask d0 cmpi.w #$8000,d0 ; check if mode pressed beq.s .mc_mode ; yes, so move .chklp1 cmpi.w #$4000,d0 ; check if TRG-X pressed beq.s .mc_trgx ; yes,so move .chklp2 cmpi.w #$2000,d0 ; check if TRG-Y pressed beq.s .mc_trgy ; yes so move .chklp3 cmpi.w #$1000,d0 ; check if TRG-Z pressed beq.s .mc_trgz ; yes so move .chklp4 cmpi.w #$0080,d0 ; check if START pressed beq.s .mc_start ; yes so move .chklp5 cmpi.w #$0040,d0 ; check if TRG-A pressed beq.s .mc_trga ; yes so move .chklp6 cmpi.w #$0020,d0 ; check if TRG-B pressed beq .mc_trgc ; yes so move .chklp7 cmpi.w #$0010,d0 ; check if TRG-C pressed beq .mc_trgb ; yes so move .chklp8 cmpi.w #$0008,d0 ; check if RIGHT pressed beq .mc_right ; yes so move .chklp9 cmpi.w #$0004,d0 ; check if LEFT pressed beq .mc_left ; yes so move .chklp10 cmpi.w #$0002,d0 ; check if DOWN pressed beq .mc_down ; yes so move .chklp11 cmpi.w #$0001,d0 ; check if UP pressed beq .mc_up ; yes so move .mc_done: rts .mc_mode: move.w #0,selected jmp .mc_move .mc_trgx: move.w #1,selected jmp .mc_move .mc_trgy: move.w #2,selected jmp .mc_move .mc_trgz: move.w #3,selected jmp .mc_move .mc_start: move.w #4,selected jmp .mc_move .mc_trga: move.w #5,selected jmp .mc_move .mc_trgb: move.w #6,selected jmp .mc_move .mc_trgc: move.w #7,selected jmp .mc_move .mc_right: move.w #8,selected jmp .mc_move .mc_left: move.w #9,selected jmp .mc_move .mc_down: move.w #10,selected jmp .mc_move .mc_up: move.w #11,selected .mc_move: lea padstr,a0 ;point to padstr data jsr console rts *------------------------------------------------------------------------ * _Mapp5: Prepares cursor movement based on pad key presses. * Executed from within the main loop. Based on d-pad press * increments in 2 cell increments. currently dx=+/-2 * dy=+/-2 * * void _Mapp5( ) * MODS * name date comments * ---- -------- ----------------------------------------- * UP 07/05/94 created * UP 07/06/94 dx=+/-1 dy=+/-1 *------------------------------------------------------------------------ xdef Mapp5 dc.l 0 Mapp5: TESTHELD KCodeLeft ;holding left beq.s .noleft ;skip if not moveq #-1,d0 ;dx moveq #0,d1 ;dy bsr cursormove ;move cursor .noleft TESTHELD KCodeRight ;holding right beq.s .noright ;skip if not moveq #1,d0 ;dx moveq #0,d1 ;dy bsr cursormove ;move cursor .noright TESTHELD KCodeUp ;holding up beq.s .noup ;skip if not moveq #0,d0 ;dx moveq #-1,d1 ;dy bsr cursormove ;move cursor .noup TESTHELD KCodeDown ;holding down beq.s .nodown ;skip if not moveq #0,d0 ;dx moveq #1,d1 ;dy bsr cursormove ;move cursor .nodown rts *------------------------------------------------------------------------ * _cursormove: Prepares cursor movement values and buffers to VRAM. * Executed from within the function Mapp5. Compares value * obtained from mapp5 for limit check ie value lies * within the boundary condition. Left most edge(col1) * top of cursor movement limited to row 18, bottom limited * to row 22. * * void _cursormove( ) * MODS * name date comments * ---- -------- ----------------------------------------- * UP 07/05/94 created * UP 07/14/94 restrict cursor movement to top 4 rows *------------------------------------------------------------------------ xdef cursormove dc.l 0 cursormove: movem.l d0-d1,-(a7) add.w BigBuffer+6,d0 ;add x and dx cmp.w #$80+33*8,d0 ;check right edge bgt.s offkeyx ;skip if too big * cmp.w #$80+7*8-2,d0 ;check left cmp.w #$80+1*8-2,d0 ;check left edge blt.s offkeyx ;skip if too small move.w d0,BigBuffer+6 ;update cursor x (slave) offkeyx: add.w BigBuffer,d1 ;add y to dy * cmp.w #$80+20*8,d1 ;compare bottom cmp.w #$80+4*8,d1 bgt.s offkeyy ;skip if too low * cmp.w #$80+16*8,d1 ;compare top cmp.w #$80+1*8,d1 blt.s offkeyy ;skip if too high move.w d1,BigBuffer ;update cursor y (slave) offkeyy: movem.l (a7)+,d0-d1 rts *------------------------------------------------------------------------ * _MVCursor: Physically moves cursor. * Executed from within the VBL. * * void _MVCursor( ) * MODS * name date comments * ---- -------- ----------------------------------------- * UP 07/05/94 created *------------------------------------------------------------------------ xdef MVCursor dc.l 0 MVCursor: movem.l d0/a0,-(a7) move.w #SpriteAttr,d0 ;sprite attribute address jsr SetVRAMWrite ;set write to VRAM lea BigBuffer,a0 ;point to data buffer move.l (a0)+,VDPData ;move sprite data to VRAM move.l (a0)+,VDPData ;move sprite data to VRAM movem.l (a7)+,d0/a0 rts