Guest User

Untitled

a guest
Oct 4th, 2018
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; sub_19DC:
  2. PalCycle_Load:
  3.     bsr.w   PalCycle_SuperSonic
  4.     moveq   #0,d0           ; clear working register 1
  5.     moveq   #0,d1           ; clear working register 2
  6.     moveq   #0,d2           ; clear working register 3
  7.     move.b  (Current_Zone).w,d0 ; we want to store the zone number as an offset
  8.     lsl.w   #1,d0           ; (multiply by element size = 2 bytes)
  9.     lea (PalCycle).l,a0     ; load the offset to the pointer index into a0
  10.     move.w  (a0,d0.w),d0        ; load pointer to animated palettes offset index into d0
  11.     lea (a0,d0.l),a0        ; load the actual palette offset into a0
  12.     move.b  (a0),PalSize        ; setup palsize register
  13.     lea (PalCycleTimerCue),a1   ; get the address of the palette cycle frame index
  14.     lea (Normal_palette_line1),a2 ; guess we will load the location of the palette system into a usable register
  15.     subq.w  #1,(PalCycle_Timer).w   ; decrement the palette wait time
  16.     bpl.s   +           ; delay the palette if there is still time left
  17.     move.w  1(a0),PalCycle_Timer    ; set initial countdown
  18.     move.b  PalSize,d0      ; now we need to set up a register to know how many colors we have so that we can load actual colors after the header
  19.     lsl.w   #1,d0           ; (multiply by element size = 2 bytes)
  20.     add.w   #3,d0           ; and include the offset from the setup bytes
  21.     move.w  #3,d1           ; now that we have the offset to the data, we need the offset to the palcycle offset table
  22.     move.b  PalSize,d2      ; prepare the counter register to count colors
  23.     move.b  #0,CycPalColorIndex ; reset color index to 0 since we havent yet wrote any cycpal colors to CRAM yet
  24.  
  25. NextColor:
  26.     move.w  #0,PalEntryX        ; initialize the X palcycle offset
  27.     move.w  #0,PalEntryY        ; initialize the Y palcycle offset
  28.     move.w  #0,CyPalColorMultiplier ; initialize the color multiplier (used to select the actual color for loading into CRAM)
  29.     move.w  #0,PalCycle_Frame
  30.     move.b  (d1,a0),PalEntryY+1 ; get palette row for current color
  31.     move.b  1(d1,a0),PalEntryX+1    ; get palette collumn for current color
  32.     lsl.w   #5,PalEntryY        ; multiply palette number by 32 (number of bytes in a palette row)
  33.     lsl.w   #1,PalEntryX        ; multiply color number by 2 (number of bytes in a color entry)
  34.     add.w   PalEntryY,PalEntryX ; get color offset by adding the color and palette raw offsets together
  35.     move.b  CycPalColorIndex,CyPalColorMultiplier+1 ; now we have the current color number stored away in the multiplier
  36.     lsl.w   #1,CyPalColorMultiplier ; times it by the number of bytes in a color
  37.     move.w  CycPalColorIndex(a1),PalEntryY  ; prepare to get the raw color entry offset so that we can load the color
  38.     mulu.w  PalSize,PalEntryY   ; times the frame number by the number of color entries
  39.     lsl.w   #1,PalEntryY        ; times our frame color index by the number of bytes in a color
  40.     add.w   CyPalColorMultiplier,PalEntryY ; now we have the color offset so we will load the color
  41.     move.b  CycPalColorIndex,PalCycle_Frame+1
  42.     lsl.w   #1,PalCycle_Frame
  43.     move.w  PalCycle_Frame(a1),PalCycle_Frame
  44.     lsl.w   #1,PalCycle_Frame
  45.     mulu.w  PalSize,PalCycle_Frame
  46.     add.w   PalCycle_Frame,PalEntryY
  47.     cmpi.b  #$FF,PalEntryY(a0,d1.w) ; is our entry really an offset instruction?
  48.     bne.s   EntryIsAColor       ; if not, branch
  49.     moveq   #0,d3           ; initialize a temp space to store a pointer
  50.     moveq   #0,d4           ; initialize another temp space
  51.     move.w  d0,d3           ; store a pointer
  52.     move.w  d1,d4           ; store the other
  53.     add.w   #1,PalEntryY        ; increment the seek pointer by one
  54.     move.b  PalEntryY(a0,d1.w),d0   ; load the offset
  55.     lsl.w   #1,d0           ; set the offset to word type by multiplying it by 2
  56.     move.b  CycPalColorIndex,d1 ; now we get the current color number
  57.     lsl.w   #1,d1           ; and we multiply it by 2 so that we store the correct frame offset
  58.     move.w  d0,(a1,d1)      ; jump to palette ofset
  59.     move.w  d3,d0           ; return d0 to normal operation so that we can reload the correct color
  60.     move.w  d4,d1           ; return d1 to normal operation so that we can reload the correct color
  61.     bra.s   NextColor       ; now we want try the next entry
  62.    
  63. EntryIsAColor: 
  64.     move.w  PalEntryY(a0,d1.w),PalEntryX(a2)
  65.     add.b   #2,CycPalColorIndex
  66.     add.w   #1,CycPalColorIndex(a1)
  67.     sub.b   #1,CycPalColorIndex
  68.     dbf d2,NextColor
  69. +   rts
  70. ; End of function PalCycle_Load
Add Comment
Please, Sign In to add comment