Advertisement
Green_Snake

S3K's slow water line H-int function

Feb 9th, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. HInt3:
  2.         tst.w   HInt_Flag.w     ; branch if h-ints were not enabled
  3.         beq.s   .rte            ; (makes sure this does not again after we're done)
  4.         move.w  #0,HInt_Flag.w      ; disable the flag...
  5.         movem.l d0-d1/a0-a2,-(sp)   ; push some regs out of the way
  6.  
  7.         lea VDP_data_port,a1
  8.         move.w  #$8AFF,4(a1)        ; reset H-int counter
  9.     stopZ80                 ; might be a good idea in order to stop Z80 from stealing the 68k bus and breaking timing!
  10.         movea.l HInt_Water_Data.w,a2    ; get water data in a2
  11.         moveq   #13-1,d0        ; number of loops to do in place to delay for next h-int (NSTC)
  12. ;       moveq   #28-1,d0        ; number of loops to do in place to delay for next h-int (PAL)
  13.         dbf d0,offset(*)        ; wait a little here
  14.  
  15.         move.w  (a2)+,d1        ; total number of color groups to write
  16.         move.b  Hint_Counter_Reserve+1.w,d0; get the vertical line we are on
  17.         subi.b  #200,d0
  18.         bcs.s   .moveColors     ; if scanlines is less than 200, we are OK here
  19.         sub.b   d0,d1           ; sub the remaining number of scanlines from color group count
  20.         bcs.s   .skiptransfer       ; if remaining line count would be negative, skip
  21.     ; this code seems to start clipping the amount of transfer we do a little bit too early unless the color group count is exactly 24
  22.     ; For the record the number of color groups is 16-20, so it should not be all that noticeable.
  23.  
  24. .moveColors move.w  (a2)+,d0        ; get offset of colour
  25.         lea Water_Pal.w,a0      ; get water palette
  26.         adda.w  d0,a0           ; add to water palette off
  27.  
  28.         addi.w  #$C000,d0       ; set CRAM write mode
  29.         swap    d0          ; swap words
  30.         move.l  d0,4(a1)        ; DMA to VDP
  31.         move.l  (a0)+,(a1)
  32.         move.w  (a0)+,(a1)      ; move all of the 3 colors in one group
  33.  
  34.         nop
  35.         nop             ; only one nop in PAL
  36. ;       moveq   #52-1,d0        ; number of loops to do in place to delay for next h-int (PAL)
  37.         moveq   #37-1,d0        ; number of loops to do in place to delay for next h-int (NSTC)
  38.         dbf d0,offset(*)        ; delay a little
  39.         dbf d1,.moveColors      ; loop for all groups
  40.  
  41. .skiptransfer   startZ80            ; start z80
  42.         movem.l (sp)+,d0-d1/a0-a2   ; pop stack contents
  43.         tst.b   Water_Fullscrn_Flag+1.w ; seems to be same in princible as $F64F in Sonic 1, but not update sound driver
  44.         bne.s   .doUpdates      ; if we want to do updates, branch
  45.  
  46. .rte        rte
  47.  
  48. .doUpdates  clr.b   Water_Fullscrn_Flag+1.w ; disable flag
  49.         movem.l d0-a6,-(sp)     ; push
  50.         jsr VInt_UpdateHUD      ; update HUD
  51.         movem.l (sp)+,d0-a6     ; pop
  52.         rte
  53. ; ---------------------------------------------------------------------------
  54. ; example Hint_Water_Data
  55.  
  56. word_74E0:  dc.w 16-1
  57.         dc.w 2, $68, $62, $42
  58.         dc.w $48, $4E, $54, 8
  59.         dc.w $E, $14, $1A, $34
  60.         dc.w $22, $3A, $2E, $28
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement