Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; sub_19DC:
- PalCycle_Load:
- bsr.w PalCycle_SuperSonic
- moveq #0,d0 ; clear working register 1
- moveq #0,d1 ; clear working register 2
- moveq #0,d2 ; clear working register 3
- move.b (Current_Zone).w,d0 ; we want to store the zone number as an offset
- lsl.w #1,d0 ; (multiply by element size = 2 bytes)
- lea (PalCycle).l,a0 ; load the offset to the pointer index into a0
- move.w (a0,d0.w),d0 ; load pointer to animated palettes offset index into d0
- lea (a0,d0.l),a0 ; load the actual palette offset into a0
- move.b (a0),PalSize ; setup palsize register
- lea (PalCycleTimerCue),a1 ; get the address of the palette cycle frame index
- lea (Normal_palette_line1),a2 ; guess we will load the location of the palette system into a usable register
- subq.w #1,(PalCycle_Timer).w ; decrement the palette wait time
- bpl.s + ; delay the palette if there is still time left
- move.w 1(a0),PalCycle_Timer ; set initial countdown
- 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
- lsl.w #1,d0 ; (multiply by element size = 2 bytes)
- add.w #3,d0 ; and include the offset from the setup bytes
- move.w #3,d1 ; now that we have the offset to the data, we need the offset to the palcycle offset table
- move.b PalSize,d2 ; prepare the counter register to count colors
- move.b #0,CycPalColorIndex ; reset color index to 0 since we havent yet wrote any cycpal colors to CRAM yet
- NextColor:
- move.w #0,PalEntryX ; initialize the X palcycle offset
- move.w #0,PalEntryY ; initialize the Y palcycle offset
- move.w #0,CyPalColorMultiplier ; initialize the color multiplier (used to select the actual color for loading into CRAM)
- move.w #0,PalCycle_Frame
- move.b (d1,a0),PalEntryY+1 ; get palette row for current color
- move.b 1(d1,a0),PalEntryX+1 ; get palette collumn for current color
- lsl.w #5,PalEntryY ; multiply palette number by 32 (number of bytes in a palette row)
- lsl.w #1,PalEntryX ; multiply color number by 2 (number of bytes in a color entry)
- add.w PalEntryY,PalEntryX ; get color offset by adding the color and palette raw offsets together
- move.b CycPalColorIndex,CyPalColorMultiplier+1 ; now we have the current color number stored away in the multiplier
- lsl.w #1,CyPalColorMultiplier ; times it by the number of bytes in a color
- move.w CycPalColorIndex(a1),PalEntryY ; prepare to get the raw color entry offset so that we can load the color
- mulu.w PalSize,PalEntryY ; times the frame number by the number of color entries
- lsl.w #1,PalEntryY ; times our frame color index by the number of bytes in a color
- add.w CyPalColorMultiplier,PalEntryY ; now we have the color offset so we will load the color
- move.b CycPalColorIndex,PalCycle_Frame+1
- lsl.w #1,PalCycle_Frame
- move.w PalCycle_Frame(a1),PalCycle_Frame
- lsl.w #1,PalCycle_Frame
- mulu.w PalSize,PalCycle_Frame
- add.w PalCycle_Frame,PalEntryY
- cmpi.b #$FF,PalEntryY(a0,d1.w) ; is our entry really an offset instruction?
- bne.s EntryIsAColor ; if not, branch
- moveq #0,d3 ; initialize a temp space to store a pointer
- moveq #0,d4 ; initialize another temp space
- move.w d0,d3 ; store a pointer
- move.w d1,d4 ; store the other
- add.w #1,PalEntryY ; increment the seek pointer by one
- move.b PalEntryY(a0,d1.w),d0 ; load the offset
- lsl.w #1,d0 ; set the offset to word type by multiplying it by 2
- move.b CycPalColorIndex,d1 ; now we get the current color number
- lsl.w #1,d1 ; and we multiply it by 2 so that we store the correct frame offset
- move.w d0,(a1,d1) ; jump to palette ofset
- move.w d3,d0 ; return d0 to normal operation so that we can reload the correct color
- move.w d4,d1 ; return d1 to normal operation so that we can reload the correct color
- bra.s NextColor ; now we want try the next entry
- EntryIsAColor:
- move.w PalEntryY(a0,d1.w),PalEntryX(a2)
- add.b #2,CycPalColorIndex
- add.w #1,CycPalColorIndex(a1)
- sub.b #1,CycPalColorIndex
- dbf d2,NextColor
- + rts
- ; End of function PalCycle_Load
Add Comment
Please, Sign In to add comment