mirror of
https://frontier.innolan.net/github/AmigaExamples.git
synced 2026-09-13 20:01:18 +00:00
Refactoring...
This commit is contained in:
+81
-42
@@ -49,45 +49,104 @@ Reset:
|
||||
move.l #0,bg_xpos
|
||||
move.l #0,bg_shift ; shift counter (d2)
|
||||
move.l #0,bg_tileIndex ; tile index (d3)
|
||||
move.l #1,bg_delay
|
||||
|
||||
jsr BlueFill
|
||||
|
||||
MainLoop:
|
||||
add.l #1,fg_xpos
|
||||
|
||||
cmp.l #1,bg_delay
|
||||
bne .s1
|
||||
move.l bg_delay,d6
|
||||
btst #0,d6
|
||||
beq .s1
|
||||
add.l #1,bg_xpos
|
||||
.s1:
|
||||
|
||||
jsr WaitVerticalBlank
|
||||
|
||||
jsr WaitVerticalBlank
|
||||
|
||||
bsr RenderNextFrame
|
||||
jsr UpdateShiftCounter
|
||||
jsr UpdateBackgroundXpos
|
||||
bsr.s HoriScrollPlayfield
|
||||
bsr.s RenderNextForegroundFrame
|
||||
bsr.s RenderNextBackgroundFrame
|
||||
|
||||
jsr SwitchBuffers ; takes bitplane pointer offset in d0
|
||||
|
||||
jsr WaitVerticalBlank
|
||||
|
||||
bsr.s RenderNextForegroundFrame
|
||||
bsr.s RenderNextBackgroundFrame
|
||||
|
||||
add.l #2,fg_tileIndex ; increment foreground tile index
|
||||
|
||||
btst #0,d6
|
||||
beq .skipBackgroundUpdates
|
||||
|
||||
;; Background updates
|
||||
add.l #2,bg_tileIndex ; increment tile index
|
||||
bsr UpdateBackgroundShiftCounter
|
||||
|
||||
.skipBackgroundUpdates:
|
||||
|
||||
bsr UpdateShiftCounter
|
||||
|
||||
|
||||
add.l #1,bg_delay
|
||||
|
||||
;; d0 - fg bitplane pointer offset
|
||||
;; d1 - bg bitplane pointer offset
|
||||
|
||||
jsr SwitchBuffers ; takes bitplane pointer offset in d0
|
||||
|
||||
|
||||
bra MainLoop
|
||||
|
||||
HoriScrollPlayfield:
|
||||
;; d0 - fg x position in pixels
|
||||
;; d1 - bg x position in pixels
|
||||
;; movem.l d0-d6,-(sp)
|
||||
|
||||
RenderNextFrame:
|
||||
move.l fg_xpos,d0 ; fg x position in pixels
|
||||
move.l bg_xpos,d1 ; bg x position in pixels
|
||||
move.l bg_xpos,d0
|
||||
|
||||
move.w d0,d2
|
||||
lsr.w #3,d0 ; bytes to scroll
|
||||
and.w #$F,d2 ; pixels = 0xf - (hpos - (hpos_bytes*8))
|
||||
move.w #$F,d0
|
||||
sub.w d2,d0 ; bits to delay
|
||||
move.w d0,d5 ; d5 == bg bits to delay
|
||||
|
||||
move.l fg_xpos,d0
|
||||
move.w d0,d2
|
||||
lsr.w #3,d0 ; bytes to scroll
|
||||
and.w #$F,d2 ; pixels = 0xf - (hpos - (hpos_bytes*8))
|
||||
move.w #$F,d0
|
||||
sub.w d2,d0 ; bits to delay
|
||||
|
||||
lsl.w #4,d5
|
||||
or.w d5,d0
|
||||
|
||||
move.w d0,BPLCON1(a6)
|
||||
|
||||
;; movem.l (sp)+,d0-d6
|
||||
rts
|
||||
|
||||
|
||||
|
||||
RenderNextBackgroundFrame:
|
||||
btst #0,d6
|
||||
beq .s1
|
||||
lea backgroundMap,a2
|
||||
add.l bg_tileIndex,a2
|
||||
bsr RenderBackgroundTile
|
||||
.s1:
|
||||
rts
|
||||
|
||||
RenderNextForegroundFrame:
|
||||
lea map,a2
|
||||
add.l fg_tileIndex,a2
|
||||
cmp.w #$FFFF,20(a2)
|
||||
bne .skip
|
||||
bra Reset
|
||||
.skip:
|
||||
|
||||
jsr HoriScrollPlayfield
|
||||
bsr RenderForegroundTile
|
||||
|
||||
add.l #2,fg_tileIndex ; increment tile index
|
||||
rts
|
||||
|
||||
RenderForegroundTile:
|
||||
@@ -95,17 +154,20 @@ RenderForegroundTile:
|
||||
;; movem.l a4,-(sp)
|
||||
move.l fg_xpos,d0
|
||||
lsr.w #3,d0 ; bytes to scroll
|
||||
move.l onscreen,a0
|
||||
move.l offscreen,a0
|
||||
add.l d0,a0
|
||||
lea tilemap,a1
|
||||
add.l #BITPLANE_WIDTH_BYTES-2,a0 ; dest
|
||||
add.w (a2),a1 ; source tile
|
||||
move.l fg_shift,d2
|
||||
jsr BlitTile
|
||||
|
||||
if 0
|
||||
move.l offscreen,a0
|
||||
add.l d0,a0
|
||||
add.l #BITPLANE_WIDTH_BYTES-2,a0 ; dest
|
||||
jsr BlitTile
|
||||
endif
|
||||
|
||||
;; movem.l (sp)+,a4
|
||||
rts
|
||||
@@ -116,17 +178,20 @@ RenderBackgroundTile:
|
||||
;; movem.l a1,-(sp)
|
||||
move.l bg_xpos,d0
|
||||
lsr.w #3,d0 ; bytes to scroll
|
||||
move.l backgroundOnscreen,a0
|
||||
move.l backgroundOffscreen,a0
|
||||
add.l d0,a0
|
||||
lea backgroundTilemap,a1
|
||||
add.l #BITPLANE_WIDTH_BYTES-2,a0 ; dest
|
||||
add.w (a2),a1 ; source tile
|
||||
move.l bg_shift,d2
|
||||
jsr BlitTile
|
||||
|
||||
if 0
|
||||
move.l backgroundOffscreen,a0
|
||||
add.l d0,a0
|
||||
add.l #BITPLANE_WIDTH_BYTES-2,a0 ; dest
|
||||
jsr BlitTile
|
||||
endif
|
||||
;; movem.l (sp)+,a4
|
||||
rts
|
||||
|
||||
@@ -149,32 +214,6 @@ UpdateBackgroundShiftCounter:
|
||||
add.l #1,bg_shift
|
||||
.s2:
|
||||
rts
|
||||
|
||||
UpdateBackgroundXpos:
|
||||
;; movem.l d0-a6,-(sp)
|
||||
cmp.l #1,bg_delay
|
||||
bne .s1
|
||||
move.l #0,bg_delay
|
||||
|
||||
|
||||
lea backgroundMap,a2
|
||||
add.l bg_tileIndex,a2
|
||||
bsr RenderBackgroundTile
|
||||
add.l #2,bg_tileIndex ; increment tile index
|
||||
|
||||
cmp.l #15,bg_shift
|
||||
bne .s01
|
||||
move.l #0,bg_shift
|
||||
bra .s02
|
||||
.s01:
|
||||
add.l #1,bg_shift
|
||||
.s02:
|
||||
bra .s2
|
||||
.s1:
|
||||
add.l #1,bg_delay
|
||||
.s2:
|
||||
;; movem.l (sp)+,d0-a6
|
||||
rts
|
||||
|
||||
Level3InterruptHandler:
|
||||
movem.l d0-a6,-(sp)
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
include "includes.i"
|
||||
|
||||
xdef HoriScrollPlayfield
|
||||
|
||||
HoriScrollPlayfield:
|
||||
;; d0 - fg x position in pixels
|
||||
;; d1 - bg x position in pixels
|
||||
;; movem.l d0-d6,-(sp)
|
||||
|
||||
move.w d0,d3
|
||||
move.w d1,d0
|
||||
|
||||
move.w d1,d2
|
||||
lsr.w #3,d0 ; bytes to scroll
|
||||
and.w #$F,d2 ; pixels = 0xf - (hpos - (hpos_bytes*8))
|
||||
move.w #$F,d0
|
||||
sub.w d2,d0 ; bits to delay
|
||||
move.w d0,d5 ; d5 == bg bits to delay
|
||||
|
||||
move.w d3,d0
|
||||
move.w d0,d2
|
||||
lsr.w #3,d0 ; bytes to scroll
|
||||
and.w #$F,d2 ; pixels = 0xf - (hpos - (hpos_bytes*8))
|
||||
move.w #$F,d0
|
||||
sub.w d2,d0 ; bits to delay
|
||||
|
||||
lsl.w #4,d5
|
||||
or.w d5,d0
|
||||
|
||||
move.w d0,BPLCON1(a6)
|
||||
|
||||
;; movem.l (sp)+,d0-d6
|
||||
rts
|
||||
|
||||
|
||||
Reference in New Issue
Block a user