jumpgame.c

来自「一个两碟控制的VCD的代码,两碟之间的转动及连续播放,已大量生产的CODE.」· C语言 代码 · 共 317 行

C
317
字号
/* Copyright 1998, ESS Technology, Inc.					*//* SCCSID @(#)jumpgame.c	1.32 11/17/98 */register volatile int *mvd asm("r27");#include "common.h"#include "mvd.h"#include "dsc.h"#include "timedef.h"#include "const.h"#include "panelcmd.h"#ifdef DRAM_GAME#include "util.h"#include "display.h"#include "ngame.h"#endif#ifdef ECHO#include "echo.h"#endif#ifdef JUMPGAME#define DEASSERT_DSC_STROBE     SET_AUX5volatile int Jump_addr=0; #ifdef DRAM_GAME#define DISABLE_BUSCON/* Use these absolue address to pass parameters between VCD code and game */#define GAME_TYPE		0x8020#define GAME_PARAMETER		0x8024#define GAME_ECHO		0x8028#define NGAME_MEM_OFFSET_0	0x00	 /* MEM_OFFSET1 & MEM_OFFSET0	 */#define NGAME_MEM_OFFSET_1	0x04	 /* MEM_OFFSET1 & MEM_OFFSET0	 */#define NGAME_MEM_OFFSET_2	0x08	 /* MEM_OFFSET1 & MEM_OFFSET0	 */#define NGAME_MEM_OFFSET_3	0x0c	 /* MEM_OFFSET1 & MEM_OFFSET0	 */extern 	int	regtable[];PRIVATE	int 	save_irqmask, save_buscon_irqmask;PRIVATE void	switch_to_game(void);#endif	/* DRAM_GAME */#define GAMELOC 0#define TESTLOC 1#define PARPTR  0x30BankSwitch(int where){    extern void BB_jump30();    unsigned int timer;    int i;#ifndef CUST3    addMicroRing(SHOW_MSG | SHOW_EVD30);    for (i = 0; i < 40; i++) 	microEngine();#endif    *(long*)PARPTR = where;#ifdef JUMP_512K    system_reset();    timer = glbTimer + EIGHTH_SECOND;#ifdef DSC    DSC_cmd(dsc_watchdog, 0);#endif    do {} while (glbTimer < timer);    mvd[riface_irqmask]=0;    DEASSERT_DSC_STROBE;    Jump_addr >>=2;     asm("ld    _Jump_addr[r25],r2");    asm("addi  r0,#0,r4");    asm("addi  r0,#0,r5");    asm("jspci r2,#0,r0");    asm("nop");    asm("nop");#else	/* 256K JUMP */     /* Stop the CD */    /*     * Switch to browser. First kill all DMA stuff. Wait a bit just to     * be on the safe side.     */    system_reset();    timer = glbTimer + EIGHTH_SECOND;#ifdef DSC    DSC_cmd(dsc_watchdog, 0);#endif    do {} while (glbTimer < timer);#ifdef DRAM_GAME    /* Save registers before jump */    save_irqmask = mvd[riface_irqmask];    save_buscon_irqmask = gbl_buscon_irqmasks;#endif    /* Disable interrupt */    mvd[riface_irqsuppress] = 0;     asm("nop"); asm("nop");    mvd[riface_irqmask]=0;#ifdef DRAM_GAME#ifdef DISABLE_BUSCON    /* Disable all DMA interrupts */    mvd[buscon_dma_irqmasks] = 0;#endif#endif#ifdef DSC#ifndef DRAM_GAME    DSC_cmd(dsc_dvectl3,   0x0);      /* Power down video             */#endif#endif #ifdef DRAM_GAME    if (which_game == RUN_RAM_CLEAR) {	which_game = RUN_REAL_GAME;	/* After ram clear, we will run game */	*(int *)GAME_TYPE = RUN_RAM_CLEAR;#ifdef NGAME_PARALLEL_PORT	/* Run game at offset 0x12030000 (mode 3) */	NGAME_control(1, NGAME_MEM_OFFSET_3);#endif    }    else {	if (big_game)	    *(int *)GAME_TYPE = RUN_BIG_GAME;	else	    *(int *)GAME_TYPE = RUN_REAL_GAME;#ifdef ECHO	*(int *)GAME_ECHO = vcx_echo;#endif#ifdef NGAME_PARALLEL_PORT	*(int *)GAME_PARAMETER = mirroring;	/* Run game at offset 0x12030000 (mode 3) */	NGAME_control(1, NGAME_MEM_OFFSET_3 | mapper);#else	*(int *)GAME_PARAMETER = (mirroring >> 3) | (mapper << 1);#endif	/* DRAM_GAME */    }    switch_to_game();#else    /* jump to the other appliaction    */    /* r22 => jump_addr / 4             */    asm("addi    r0,#0x33f,r22");    asm("lsl     r22,r22,#16");    asm("addi    r22,#0xff00,r22");    asm("jspci   r22,#0,r0");    asm("nop");    asm("nop");#endif#endif	/* JUMP_512K */}#ifdef DRAM_GAMEPRIVATE void switch_to_game(void){    /* Save all registers before jump */    asm("st    _regtable+1*4[r0],r1");    asm("st    _regtable+2*4[r0],r2");    asm("st    _regtable+3*4[r0],r3");    asm("st    _regtable+4*4[r0],r4");    asm("st    _regtable+5*4[r0],r5");    asm("st    _regtable+6*4[r0],r6");    asm("st    _regtable+7*4[r0],r7");    asm("st    _regtable+8*4[r0],r8");    asm("st    _regtable+9*4[r0],r9");    asm("st    _regtable+10*4[r0],r10");    asm("st    _regtable+11*4[r0],r11");    asm("st    _regtable+12*4[r0],r12");    asm("st    _regtable+13*4[r0],r13");    asm("st    _regtable+14*4[r0],r14");    asm("st    _regtable+15*4[r0],r15");    asm("st    _regtable+16*4[r0],r16");    asm("st    _regtable+17*4[r0],r17");    asm("st    _regtable+18*4[r0],r18");    asm("st    _regtable+19*4[r0],r19");    asm("st    _regtable+20*4[r0],r20");    asm("st    _regtable+21*4[r0],r21");    asm("st    _regtable+22*4[r0],r22");    asm("st    _regtable+23*4[r0],r23");    asm("st    _regtable+24*4[r0],r24");    asm("st    _regtable+25*4[r0],r25");    asm("st    _regtable+26*4[r0],r26");    asm("st    _regtable+27*4[r0],r27");    asm("st    _regtable+28*4[r0],r28");    asm("st    _regtable+29*4[r0],r29");    asm("st    _regtable+30*4[r0],r30");    asm("st    _regtable+31*4[r0],r31");    /* Flush cache : game uses location from 0x8000 to 0xa000 */    UTIL_flushcache(0x8000, 8*1024);    /* Jump */    asm("addi    r0,#0x33f,r22");    asm("lsl     r22,r22,#16");    asm("addi    r22,#0xff00,r22");    asm("jspci   r22,#0,r31");    asm("nop");    asm("nop");    /* restore registers */    asm("ld    _regtable+1*4[r0],r1");    asm("ld    _regtable+2*4[r0],r2");    asm("ld    _regtable+3*4[r0],r3");    asm("ld    _regtable+4*4[r0],r4");    asm("ld    _regtable+5*4[r0],r5");    asm("ld    _regtable+6*4[r0],r6");    asm("ld    _regtable+7*4[r0],r7");    asm("ld    _regtable+8*4[r0],r8");    asm("ld    _regtable+9*4[r0],r9");    asm("ld    _regtable+10*4[r0],r10");    asm("ld    _regtable+11*4[r0],r11");    asm("ld    _regtable+12*4[r0],r12");    asm("ld    _regtable+13*4[r0],r13");    asm("ld    _regtable+14*4[r0],r14");    asm("ld    _regtable+15*4[r0],r15");    asm("ld    _regtable+16*4[r0],r16");    asm("ld    _regtable+17*4[r0],r17");    asm("ld    _regtable+18*4[r0],r18");    asm("ld    _regtable+19*4[r0],r19");    asm("ld    _regtable+20*4[r0],r20");    asm("ld    _regtable+21*4[r0],r21");    asm("ld    _regtable+22*4[r0],r22");    asm("ld    _regtable+23*4[r0],r23");    asm("ld    _regtable+24*4[r0],r24");    asm("ld    _regtable+25*4[r0],r25");    asm("ld    _regtable+26*4[r0],r26");    asm("ld    _regtable+27*4[r0],r27");    asm("ld    _regtable+28*4[r0],r28");    asm("st    0x4028[r27],r0");	/* irqsupress */    asm("ld    _regtable+29*4[r0],r29");    asm("ld    _regtable+30*4[r0],r30");    asm("ld    _regtable+31*4[r0],r31");    /* reinstall interrupt vector for VCD code */    install_interrupt_vectors();    /* restore interrupt mask */    mvd[riface_irqsuppress] = 0; asm("nop"); asm("nop");    mvd[riface_irqmask] = save_irqmask;    mvd[buscon_dma_irqmasks] = save_buscon_irqmask;    /* Enable all BUSCON DMA */    mvd[buscon_dma_disable] = 0;    /* Initiate DRAM refresh */    LOW_init_dram();    /* Location GAME_PARAMETER is set just before returning from game */    if (*(int *)GAME_PARAMETER)	process_power_off_key();    /* Initialize remote control */    IR_init();#ifdef SERVO    NGAME_init(3);#else    NGAME_init(2);#endif    {	/* do_blank was set before loading game, now clear it */	extern int do_blank;	do_blank = 0;    }    /* Hide garbage */    fill_screen(COLOR_BLACK);}#endif#endif	/* JUMPGAME *//* The following function is added for TESTMODE. When run 512K, GAME and test    code are in the same bank30.rom. When the two bank switch, I must decide   Jump to game or test code, I use r5 to decide where to Jump. At the same   time, startup.s is also changed. When powerup automatically, the chip    run from powerup. When Switch EAUX13, powerup has not been called.*/#ifdef TEST_MODESwitchToTest(){    unsigned int timer;    system_reset();    timer = glbTimer + EIGHTH_SECOND;#ifdef DSC    DSC_cmd(dsc_watchdog, 0);#endif    do {} while (glbTimer < timer);    DSC_cmd(dsc_dvectl3,   0x0);      /* Power down video             */    mvd[riface_irqmask]=0;    DEASSERT_DSC_STROBE;    Jump_addr >>=2;    asm("ld    _Jump_addr[r25],r2");    asm("addi  r0,#0,r4");    asm("addi  r0,#1,r5");    asm("jspci r2,#0,r0");    asm("nop");    asm("nop");}#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?