/[gxemul]/trunk/src/promemul/dreamcast.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/src/promemul/dreamcast.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 32 by dpavlin, Mon Oct 8 16:20:58 2007 UTC revision 34 by dpavlin, Mon Oct 8 16:21:17 2007 UTC
# Line 1  Line 1 
1  /*  /*
2   *  Copyright (C) 2006  Anders Gavare.  All rights reserved.   *  Copyright (C) 2006-2007  Anders Gavare.  All rights reserved.
3   *   *
4   *  Redistribution and use in source and binary forms, with or without   *  Redistribution and use in source and binary forms, with or without
5   *  modification, are permitted provided that the following conditions are met:   *  modification, are permitted provided that the following conditions are met:
# Line 25  Line 25 
25   *  SUCH DAMAGE.   *  SUCH DAMAGE.
26   *   *
27   *   *
28   *  $Id: dreamcast.c,v 1.12 2006/11/02 06:47:14 debug Exp $   *  $Id: dreamcast.c,v 1.15 2006/12/30 13:31:02 debug Exp $
29   *   *
30   *  Dreamcast PROM emulation.   *  Dreamcast PROM emulation.
31   *   *
# Line 52  Line 52 
52  /*  The ROM FONT seems to be located just after 1MB, in a real Dreamcast:  */  /*  The ROM FONT seems to be located just after 1MB, in a real Dreamcast:  */
53  #define DREAMCAST_ROMFONT_BASE          0x80100020  #define DREAMCAST_ROMFONT_BASE          0x80100020
54    
55    static int booting_from_cdrom = 0;
56    
57    
58  /*  /*
59   *  dreamcast_romfont_init()   *  dreamcast_romfont_init()
# Line 118  void dreamcast_machine_setup(struct mach Line 120  void dreamcast_machine_setup(struct mach
120          int i;          int i;
121          struct cpu *cpu = machine->cpus[0];          struct cpu *cpu = machine->cpus[0];
122    
123          for (i=0xb0; i<=0xfc; i+=sizeof(uint32_t)) {          for (i=0; i<0x50; i+=sizeof(uint32_t)) {
124                  /*  Store pointer to PROM routine...  */                  /*  Store pointer to PROM routine...  */
125                  store_32bit_word(cpu, 0x8c000000 + i, 0x8c000100 + i);                  store_32bit_word(cpu, 0x8c0000b0 + i, 0x8c000040 + i);
126    
127                  /*  ... which contains only 1 instruction, a special                  /*  ... which contains only 1 instruction, a special
128                      0x00ff opcode which triggers PROM emulation:  */                      opcode which triggers PROM emulation:  */
129                  store_16bit_word(cpu, 0x8c000100 + i, 0x00ff);                  store_16bit_word(cpu, 0x8c000040 + i, SH_INVALID_INSTR);
130          }          }
131    
132          /*  PROM reboot, in case someone jumps to 0xa0000000:  */          /*  PROM reboot, in case someone jumps to 0xa0000000:  */
133          store_16bit_word(cpu, 0xa0000000, 0x00ff);          store_16bit_word(cpu, 0xa0000000, SH_INVALID_INSTR);
134    
135          dreamcast_romfont_init(machine);          dreamcast_romfont_init(machine);
136  }  }
# Line 139  void dreamcast_machine_setup(struct mach Line 141  void dreamcast_machine_setup(struct mach
141   */   */
142  int dreamcast_emul(struct cpu *cpu)  int dreamcast_emul(struct cpu *cpu)
143  {  {
144          int addr = cpu->pc & 0xff;          int addr = (cpu->pc & 0xff) - 0x40 + 0xb0;
145          int r1 = cpu->cd.sh.r[1];          int r1 = cpu->cd.sh.r[1];
146          int r6 = cpu->cd.sh.r[6];          int r6 = cpu->cd.sh.r[6];
147          int r7 = cpu->cd.sh.r[7];          int r7 = cpu->cd.sh.r[7];
148    
149          switch (addr) {          /*  Special case: Reboot  */
150            if ((uint32_t)cpu->pc == 0xa0000000) {
151          case 0x00:                  fatal("[ dreamcast reboot ]\n");
                 /*  Special case: Reboot  */  
                 fatal("[ dreamcast reboot ]\n");  
152                  cpu->running = 0;                  cpu->running = 0;
153                  break;                  return 1;
154            }
155    
156            switch (addr) {
157    
158          case 0xb0:          case 0xb0:
159                  /*  SYSINFO  */                  /*  SYSINFO  */
# Line 227  int dreamcast_emul(struct cpu *cpu) Line 230  int dreamcast_emul(struct cpu *cpu)
230                   *  The easiest way to support both is probably to keep track                   *  The easiest way to support both is probably to keep track
231                   *  of whether the IP.BIN code was started by the (software)                   *  of whether the IP.BIN code was started by the (software)
232                   *  ROM emulation code, or not.                   *  ROM emulation code, or not.
233                     */
234                    if (booting_from_cdrom) {
235                            fatal("[ dreamcast: Switching to bootstrap 1 ]\n");
236                            booting_from_cdrom = 0;
237                            cpu->pc = 0x8c00b800;
238                            return 1;
239                    } else {
240                            fatal("[ dreamcast: Returning to main menu. ]\n");
241                            cpu->running = 0;
242                    }
243                    break;
244    
245            case 0xf0:
246                    /*
247                     *  GXemul hack:
248                   *                   *
249                   *  TODO                   *  By jumping to this address (0x8c000080), a "boot from
250                     *  CDROM" is simulated. Control is transfered to the license
251                     *  code in the loaded IP.BIN file.
252                   */                   */
253                  fatal("[ Boot menu? TODO ]\n");                  debug("[ dreamcast boot from CDROM ]\n");
254                  goto bad;                  booting_from_cdrom = 1;
255                    cpu->pc = 0x8c008300;
256                    return 1;
257    
258          default:goto bad;          default:goto bad;
259          }          }
# Line 244  int dreamcast_emul(struct cpu *cpu) Line 266  int dreamcast_emul(struct cpu *cpu)
266  bad:  bad:
267          cpu_register_dump(cpu->machine, cpu, 1, 0);          cpu_register_dump(cpu->machine, cpu, 1, 0);
268          printf("\n");          printf("\n");
269          fatal("[ dreamcast_emul(): unimplemented dreamcast PROM call ]\n");          fatal("[ dreamcast_emul(): unimplemented dreamcast PROM call, "
270                "pc=0x%08"PRIx32" ]\n", (uint32_t)cpu->pc);
271          cpu->running = 0;          cpu->running = 0;
272          return 1;          return 1;
273  }  }

Legend:
Removed from v.32  
changed lines
  Added in v.34

  ViewVC Help
Powered by ViewVC 1.1.26