Guest User

Untitled

a guest
Dec 23rd, 2017
269
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 3.18 KB | None | 0 0
  1. // can stop at every...
  2. // - mainboard cycle             ca. 21.477 MHz
  3. // - mainboard CPU opcode cycle  ca. 1.79 or 2.68 or 3.58 MHz
  4. // - mainboard CPU opcode        < 1 MHz
  5. // - APU cycle                   24.576 MHz
  6. // - APU CPU opcode cycle        ?
  7. // - APU CPU opcode              ?
  8.  
  9.  
  10. function SNES_Start : T_State;
  11. label
  12.         n00,    resume_n00,     // 65c816 (native) mode opcode $00
  13.         n00c1,                  // cycle 1
  14.         n00c1c, resume_n00c1c,  // cycle 1 CPU core
  15.         n00c1m, resume_n00c1m,  // cycle 1 mainboard
  16.         n00c1a, resume_n00c1a;  // cycle 1 audio
  17.         // ...
  18.         e00,    resume_e00,     // 6502 (emulation) mode opcode $00
  19.         // ...
  20. var
  21.         APU            : T_APU       absolute SNES.APU;                           // audio processing unit
  22.         Core           : T_65c816    absolute SNES.Mainboard.CPU.Core;            // "65c816" CPU core, part of the "5A22" CPU
  23.         CoreWaitstates : u4          absolute SNES.Mainboard.CPU.CoreWaitstates;  // CPU core runs at 1/6, 1/8 or 1/12 speed of the mainboard oscillator
  24.         Mainboard      : T_Mainboard absolute SNES.Mainboard;                     // contains everything except the APU
  25.         Time           : i32         absolute SNES.Mainboard.Time;                // used for synchronizing the mainboard oscillator with the APU oscillator
  26. begin
  27. SNES_Stop := False;
  28. // insert state dispatch here
  29. n00:
  30.         if SNES_Stop then exit(State_n00);                                      {$IFDEF Step_5A22_Core_Opcode}  exit(State_n00);     {$ENDIF}  resume_n00:
  31.         n00c1:
  32.                 n00c1c:                                                         {$IFDEF Step_5A22_Core_Cycle}   exit(State_n00c1c);  {$ENDIF}  resume_n00c1c:
  33.                         // insert CPU core PHI1 code here
  34.                         CPU_PHI1;  // emulate the CPU reacting to the CPU core
  35.                 n00c1m:
  36.                         if (Time <= 0) then begin                               {$IFDEF Step_Mainboard_Cycle}   exit(State_n00c1m);  {$ENDIF}  resume_n00c1m:
  37.                                 Mainboard_Update;
  38.                                 Inc(Time, Mainboard.Oscillator.CycleDuration);
  39.                         end;
  40.                 n00c1m:                                                         {$IFDEF Step_APU_Cycle}         exit(State_n00c1a);  {$ENDIF}  resume_n00c1a:
  41.                         APU_Update;  // emulate audio
  42.                         Dec(Time, APU.Oscillator.CycleDuration);
  43.                         if (CoreWaitstates <> 0) then begin  // time to wake up the CPU core?
  44.                                 Dec(CoreWaitstates);
  45.                                 goto n00c1m;
  46.                         end;
  47.                         // insert CPU core PHI2 code here (CPU core reacts to DataBus and signals)
  48.         // cycle 2
  49.         // ...
  50.         // last cycle of opcode $00
  51.                 // ...
  52.                 // ...
  53.                 // ...
  54.                         // insert opcode dispatch here
  55. // native mode opcode $02
  56. // ...
  57. // native mode opcode $FF
  58. // emulation mode opcode $00
  59. // ...
  60. // emulation mode opcode $FF
  61. Assert(False);  // this code should never be reached
  62. end;
Advertisement
Add Comment
Please, Sign In to add comment