Advertisement
Guest User

Untitled

a guest
Oct 15th, 2016
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; Sonic 2 example
  2. ; object load time ~62 cycles
  3. Obj_WeirdPlatform:
  4.         moveq   #0,d0                       ; 4 cycles
  5.         move.b  $24(a0),d0      ; routine counter   ; 12 cycles
  6.         move.w  Obj_WP_Index(pc,d0.w),d1; get offset        ; 14 cycles
  7.         jmp Obj_WP_Index(pc,d1.w)   ; jump to routine   ; 14 cycles
  8.  
  9. Obj_WP_Index:
  10.     dc.w Obj_WP_Init-Obj_WP_Index       ; 0
  11.     dc.w Obj_WP_Type0-Obj_WP_Index      ; 2
  12.     dc.w Obj_WP_Type1-Obj_WP_Index      ; 4
  13.  
  14. Obj_WP_Init:
  15.         ori.b   #4,1(a0)        ; render on playfield   ; 24 cycles
  16.         move.w  #$1234,2(a0)        ; set art_tile      ; 16 cycles
  17.         move.l  #Obj_WP_Map,4(a0)   ; set mappings      ; 24 cycles
  18.         move.b  #1,$18(a0)      ; set priority      ; 16 cycles
  19.         move.b  #$20,$19(a0)        ; set width     ; 16 cycles
  20.  
  21.         move.b  $28(a0),d0      ; get subtype to d0 ; 12 cycles
  22.         lsl.b   #1,d0           ; double it     ; 8 cycles
  23.         addq.w  #2,d0           ; skip over index   ; 4 cycles
  24.         move.b  d0,$24(a0)      ; save routine counter  ; 12 cycles
  25.         rts                         ; 16 cycles
  26.  
  27. ; time to reach this routine on second frame: 62 + 44 = 106 cycles
  28. ; path to get to here: obj loading routine -> Obj_WeirdPlatform -> Obj_WP_Type0
  29. Obj_WP_Type0:
  30.     ...
  31.  
  32. Obj_WP_Type1:
  33.     ...
  34.  
  35.  
  36. ; Sonic & Knuckles example
  37. ; object load time ~40 cycles
  38. Obj_WeirdPlatform:
  39. ;Obj_WP_Init
  40.         ori.b   #4,4(a0)        ; render on playfield   ; 24 cycles
  41.         move.w  #$1234,$A(a0)       ; set art_tile      ; 16 cycles
  42.         move.l  #Obj_WP_Map,$C(a0)  ; set mappings      ; 24 cycles
  43.         move.w  #$80,$08(a0)        ; set priority      ; 16 cycles
  44.         move.b  #$20,$1F(a0)        ; set width     ; 16 cycles
  45.  
  46.         move.b  $28(a0),d0      ; get subtype to d0 ; 12 cycles
  47.         lsl.b   #2,d0           ; quadruple it      ; 10 cycles
  48.         move.l  Obj_WP_Index(pc,d0.w),(a0); set new obj address ; 26 cycles
  49.         rts                         ; 16 cycles
  50.  
  51. Obj_WP_Index:
  52.     dc.l Obj_WP_Type0
  53.     dc.l Obj_WP_Type1
  54.  
  55. ; time to reach this routine on second frame: 40 cycles
  56. ; path to get to here: obj loading routine -> Obj_WP_Type0
  57. Obj_WP_Type0:
  58.     ...
  59.  
  60. Obj_WP_Type1:
  61.     ...
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement