*---------------------------------------------------------------------- * File Name: general.asm * * Copyright (c) 1994 Sega of America, Inc. All Rights Reserved. * * Author(s): Unni Pillai * Date: 6-03-94 * Description: This file contains general purpose routine accessed by * the MD side. * * * History: * *---------------------------------------------------------------------* nolist section .text include "z80.h" ;z80 hardware equates include "vdp.h" ;vdp hardware equates and masks include "vdp.i" ;references to VDP variables include "general.mac" ;general purpose macros include "general.i" ;references used by general.asm list *-------------------------------------------------------------------- * _initVDP: Initializes VDP on MD * Sets the VDP to 28 cell mode, sets up VRAM addresses for * sprite tables etc * This sets up 24 WORDS of work RAM as a 'copy' of * the VDP registers. ICD_BLK4 sets up the hardware in * a similar way, without slaving the VDP registers, * but THIS code does slave the registers in work RAM * as the VDP has write only registers (status excepted). * It also enables the display and Vertical interrupts * as well as setting up the VRAM addresses in the VDP. * * * void _initVDP( ) * * MODS * name date comments * ---- -------- ------------------------------------- * UP 06/02/94 created *---------------------------------------------------------------------- xdef initVDP dc.l 0 initVDP: movem.l d0-d1/a0-a1,-(a7) lea.l InitialVDP(pc),a0 ; point to VDP initialization data lea.l VDPSlaves,a1 ; point to VDP slave register in work RAM moveq #-$80,d0 ; register increment moveq #24-1,d1 ; count .sl_slave: move.b d0,(a1)+ ; save register number move.b (a0)+,(a1)+ ; save register data addq.w #1,d0 ; increment register dbra d1,.sl_slave ; slave all regs bsr SetVDPRegs ; set VDP registers (but not DMA VDP registers) move.w #64,CellMapCols ; set up cell map width move.w #32,CellMapRows ; set up cell map height movem.l (a7)+,d0-d1/a0-a1 rts *---------------------------------------------------------------------------- * _initMDIO: Initializes IO ports on MD. sets all ports to PARALLEL * MODE. Also sets all the control ports for single line * control(default setting with regular 6/3 pads), and sets * TH (bit d6) high on all data ports. This routine disables * the Z80 off the bus upon entry and enables the Z80 before exit * * void _initMDIO( ) * * MODS * name date comments * ---- -------- ------------------------------------- * UP 06/02/94 created *---------------------------------------------------------------------- xdef initMDIO dc.l 0 initMDIO: movem.l d0/a0,-(a7) Z80di move.l #$00a10013,a0 ;serial control port 1 address move.b #$00,(a0) ;set port 1 to PARALLEL MODE move.b #$00,$6(a0) ;set port 2 to PARALLEL MODE move.b #$00,$c(a0) ;set port 3 to PARALLEL MODE move.l #$00a10009,a0 ;control register for port 1 move.b #$40,(a0) ;set bit d6(TH) to output on port 1 move.b #$40,2(a0) ;set bit d6(TH) to output on port 2 move.b #$40,4(a0) ;set bit d6(TH) to output on port 3 move.l #$00a10003,a0 ;i/o data register for port 1 move.b #$40,(a0) ;set TH(bit d6)=1 high on port 1 move.b #$40,2(a0) ;set TH(bit d6)=1 high on port 2 move.b #$40,4(a0) ;set TH(bit d6)=1 high on port 3 Z80ei movem.l (a7)+,d0/a0 rts *-------------------------------------------------------------------- * _ChgCol: Updates String Color every vbl * * void _ChgCol( ) * MODS * name date comments * ---- -------- ------------------------------------- * UP 06/16/94 created *---------------------------------------------------------------------- xdef ChgCol dc.l 0 ChgCol: move.w twinklecol,d1 ;get colour add.w twinklech,d1 ;update it and.w #$0ff,d1 ;mask green and red only (YELLOW) beq.s mp_change ;skip to negate if 0 cmp.w #$0ff,d1 ;check highes value bne.s mp_write ;skip to write if not mp_change neg.w twinklech ;switch cycle direction mp_write move.w d1,twinklecol ;save new colour tst.b VDPLock ;check VDP can be used on interrupts bmi.s mp_locked ;skip if not moveq #47*2,d0 ;foreground 2 jsr SetCRAMWrite ;write to CRAM move.w d1,VDPData ;write new colour to VRAM mp_locked rts *-------------------------------------------------------------------- * _InitCursor: Initializes the cursor * * void _InitCursor( ) * MODS * name date comments * ---- -------- ------------------------------------- * UP 07/05/94 created * UP 07/14/94 changed cursor starting position to 1,1 *---------------------------------------------------------------------- xdef InitCursor dc.l 0 InitCursor: * move.w #$80+14*8,BigBuffer ;y(vertical position) move.w #$80+1*8,BigBuffer ;y(vertical position) move.w #0,BigBuffer+2 ;size and link move.w #105,BigBuffer+4 ;cell * move.w #$80+7*8-2,BigBuffer+6 ;x(horizontal position) move.w #$80+1*8-2,BigBuffer+6 ;x(horizontal position)left most edge move.l #MVCursor,PollAddress rts *---------------------------------------------------------------------------- * _wait: inserts delay * * void _wait( ) * * MODS * name date comments * ---- -------- ------------------------------------- * UP 06/13/94 created *---------------------------------------------------------------------- xdef wait dc.l 0 wait: moveq #4,d6 ; this delay is being setup for demo purpose only .dlylp1: moveq #0,d5 move.w #$fffe,d5 ; delay counter .dlylp2: dbra d5,.dlylp2 dbra d6,.dlylp1 ; end of delay rts *---------------------------------------------------------------------------- * _waitless: smaller delay * * void _waitless( ) * * MODS * name date comments * ---- -------- ------------------------------------- * UP 06/13/94 created *---------------------------------------------------------------------- xdef waitless dc.l 0 waitless: moveq #0,d5 move.w #$ffff,d5 dlylp1: dbra d5,dlylp1 rts