/**
 * TrueReality - N64/rcp/rcp_dis.c
 * Copyright (C) 1998, 1999 Niki W. Waibel
 *
 * This program is free software; you can redistribute it and/
 * or modify it under the terms of the GNU General Public Li-
 * cence as published by the Free Software Foundation; either
 * version 2 of the Licence, or any later version.
 *
 * This program is distributed in the hope that it will be use-
 * ful, but WITHOUT ANY WARRANTY; without even the implied war-
 * ranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public Licence for more details.
 *
 * You should have received a copy of the GNU General Public
 * Licence along with this program; if not, write to the Free
 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
 * USA.
 *
 * Information about me (the author):
 *   Niki W. Waibel, Reichenau 20, 6890 Lustenau, Austria - EUROPE
 *   niki.waibel@gmx.net
**/





#include <stdio.h>
#include <stdlib.h>
#include <parser_extern.h>
#include <memory_extern.h>
#include "../../include/type_sizes.h"
#include "../rsp_registers.h"
#include "../rsp.h"
#include "../registers.h"








struct rs4300i_reg reg;
struct tr_prefs prefs;
struct tr_mem mem;

                      






void main(int argc, char *argv[])
{
        char    line[80];
        WORD    code;
        int     i;
        FILE    *f;





        mem.sp_imem = malloc(0x1000);
        mem.sp_dmem = malloc(0x1000);
        mem.sp_reg  = malloc(0x20);

        if(argc == 2)
        {
                f = fopen(argv[1], "r");
        }



        rsp_reset();

        prefs.debug = ~1ULL;
        mem.sp_reg_pc = 0x04001000;



        for(;;)
        {
                if(argc == 2)
                {
                        i = fscanf(f, "%lx", &code);
                        if(i != 1)
                                return;
                }
                else
                {
                        do
                        {
                                fputs("input opcode: ", stdout); fflush(stdout);
                                fgets(line, 80, stdin);
                                if(line[0] == '!')
                                {
                                        puts("Exiting RCP disasembler\n");
                                        return;
                                }
                                i = sscanf(line, "%lx", &code);
                        }
                        while(i != 1);
                }



                rsp_reg.code = code;

                printf("%08lx ", code);

                rsp_dis(code);

                mem.sp_reg_pc += 4;



                /* do common things */
                
                rsp_reg.r[0] = 0;
        }

} /* void main(int argc, char *argv[]) */




BYTE doReadMemByte(WORD x) { return(0); }
HWORD doReadMemHalfWord(WORD x) { return(0); }
WORD doReadMemWord(WORD x) { return(0); }
DWORD doReadMemDoubleWord(WORD x) { return(0); }

void doWriteMemByte(BYTE y, WORD x) {}
void doWriteMemHalfWord(HWORD y, WORD x) {}
void doWriteMemWord(WORD y, WORD x) {}
void doWriteMemDoubleWord(DWORD y, WORD x) {}
