Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; ===========================================================================
- ; ---------------------------------------------------------------------------
- ; Reset the tile map queue linked lists
- ; ---------------------------------------------------------------------------
- InitMapQueues:
- moveq #0,d0
- lea r_DMAMapRows_Head.w,a0
- lea $08(a0),a1
- lea $00FF4202.l,a2 ; this shouldn't be hard-coded here
- movem.l d0/a0,(a0)
- movem.l d0/a1/a2,(a1)
- rts
- ; ===========================================================================
- ; ---------------------------------------------------------------------------
- ; Add a tile row queue
- ; ---------------------------------------------------------------------------
- ; INPUTS:
- ; d0.w = number of rows to draw (-1 for loop)
- ; d1.w = length of row (in tiles)
- ; d2.w = VRAM address
- ;
- ; USAGE:
- ; moveq #XX-1,d0
- ; moveq #XX,d1
- ; jsr AddMapRowQueue
- ; ---------------------------------------------------------------------------
- AddMapRowQueue:
- move.l r_NextFreeMapQueue.w,a0 ; 16 ; load next free map queue
- move.l r_DMAMapRows_Tail.w,a1 ; 16 ; load last added queue
- move.l a0,r_DMAMapRows_Tail.w ; 16 ; update pointer to last added queue
- bra.s AddMapQueue ; 10
- ; ---------------------------------------------------------------------------
- ; Add a tile column queue
- ; ---------------------------------------------------------------------------
- ; INPUTS:
- ; d0.w = number of rows to draw (-1 for loop)
- ; d1.w = length of row (in tiles)
- ; d2.w = VRAM address
- ;
- ; USAGE:
- ; moveq #XX-1,d0
- ; moveq #XX,d1
- ; jsr AddMapRowQueue
- ; ---------------------------------------------------------------------------
- AddMapColumnQueue:
- move.l r_NextFreeMapQueue.w,a0 ; 16 ; load next free map queue
- move.l r_DMAMapColumns_Tail.w,a1 ; 16 ; load last added queue
- move.l a0,r_DMAMapColumns_Tail.w ; 16 ; update pointer to last added queue
- ; ---------------------------------------------------------------------------
- ; INPUTS:
- ; a0 = queue space
- ; a1 = previous queue
- ; ---------------------------------------------------------------------------
- ; OUTPUTS:
- ; a0 = buffer for nametables
- ; a1 =
- ; ---------------------------------------------------------------------------
- AddMapQueue:
- move.l a0,(a1) ; 12 ; link current queue into previous one
- moveq #0,d3 ; 4 ; clear "next queue" link
- move.l d3,(a0)+ ; 12 ; ''
- move.b d0,(a0)+ ; 8 ; set number of rows for this queue
- move.b d1,(a0)+ ; 8 ; set length of row (bytes/2; number of nametables to dump)
- move.w d2,(a0)+ ; 8 ; set VRAM address
- add.w d1,d1 ; 4 ; double row/column length (get number of bytes)
- move.w d0,d3 ; 4
- addq.w #1,d3 ; 4 ; fuck
- mulu.w d1,d3 ; ? ; >->
- lea (a0,d3.w),a1 ; 12
- move.l a1,r_NextFreeMapQueue.w ; 16
- rts ; 16
- ; ---------------------------------------------------------------------------
- DMA_RowQueues:
- lea r_DMAMapRows_Head.w,a0
- move.l #$00800000,-(sp)
- bra.s DMA_MapQueue
- DMA_ColumnQueues:
- lea r_DMAMapColumns_Head.w,a0
- pea .Return(pc)
- move.l #$00020000,-(sp)
- move.w #$8F80,$C00004.l
- bra.s DMA_MapQueue
- .Return:
- move.w #$8F02,(a6)
- rts
- ; ---------------------------------------------------------------------------
- ; (a0).w =
- ; (sp).l =
- DMA_MapQueue:
- lea $C00000.l,a5
- lea 4(a5),a6
- move.l #$94009300,d6
- move.l #$00009500,d5
- move.l #$00009600,d4
- move.l #$00009700,d3
- move.l #$C0003FFF,d2
- .Loop:
- move.l (a0),d0 ; get link to next queue
- beq.s .Return ; if null, return (this is the last in the list)
- move.l d0,a0 ; load queue
- lea 4(a0),a1 ; ''
- moveq #0,d7 ; get repeat times for rows
- move.b (a1)+,d7 ; ''
- move.b (a1)+,d6 ; get length
- move.l d2,d0 ; generate VDP command for VRAM address
- and.w (a1),d0 ; ''
- addi.w #$4000,d0 ; ''
- swap d0 ; ''
- and.w (a1)+,d0
- rol.w #2,d0
- bset #7,d0
- .GetSource:
- move.l a1,d1 ; copy buffer position to d1 (source)
- lsr.l #1,d1
- move.b d1,d5
- ror.w #8,d1
- move.b d1,d4
- swap d1
- move.b d1,d3
- move.l d6,(a6)
- move.w d5,(a6)
- move.w d4,(a6)
- move.w d3,(a6)
- move.l d0,-(sp)
- move.w (sp)+,(a6)
- move.w (sp)+,(a6)
- dbf d7,.Next
- bra.s .Loop
- .Next:
- add.l (sp),d0
- moveq #0,d1
- move.b d6,d1
- add.w d1,d1
- lea (a1,d1.w),a1
- bra.s .GetSource
- .Return:
- clr.l r_DMAMapRows_Head.w
- addq.w #4,sp
- rts
Add Comment
Please, Sign In to add comment