mirror of
https://frontier.innolan.net/github/AmigaExamples.git
synced 2026-09-12 22:13:49 +00:00
test score render
This commit is contained in:
+1
-1
@@ -11,7 +11,7 @@ BASE_ADDRESS=4000
|
||||
NUM_COLORS=8
|
||||
|
||||
BOOTBLOCK_ASM=alpine_bootblock.s
|
||||
OBJS=out/init.o out/utils.o out/image.o out/blit.o out/joystick.o out/player.o out/items.o out/blittext.o out/music.o out/P6112-Play.o out/splash.o
|
||||
OBJS=out/init.o out/utils.o out/image.o out/blit.o out/joystick.o out/player.o out/items.o out/blitmtext.o out/blittext.o out/music.o out/P6112-Play.o out/splash.o
|
||||
|
||||
IMAGES=foreground.png \
|
||||
background.png \
|
||||
|
||||
@@ -4,13 +4,13 @@
|
||||
051 136 136 255
|
||||
255 238 187 255
|
||||
068 187 170 255
|
||||
170 238 238 255
|
||||
000 000 000 255
|
||||
255 221 000 255
|
||||
255 255 255 255
|
||||
255 136 000 255
|
||||
000 068 119 255
|
||||
085 221 204 255
|
||||
170 187 153 255
|
||||
170 238 238 255
|
||||
000 000 000 255
|
||||
000 000 000 255
|
||||
000 000 000 255
|
||||
255 255 204 255
|
||||
@@ -0,0 +1,155 @@
|
||||
include "includes.i"
|
||||
xdef DrawMaskedText8
|
||||
|
||||
BLIT_LF_MINTERM equ $ca ; cookie cut
|
||||
BLIT_WIDTH_WORDS equ 2 ; blit 2 words to allow shifting
|
||||
BLIT_WIDTH_BYTES equ 4
|
||||
FONT_HEIGHT equ 8
|
||||
FONT_WIDTH equ 8
|
||||
FONTMAP_WIDTH_BYTES equ 32
|
||||
_SCREEN_BIT_DEPTH equ 4
|
||||
_BITPLANE_WIDTH_BYTES equ 320/8
|
||||
MASKED_FONT equ 1
|
||||
|
||||
DrawMaskedText8:
|
||||
;; a0 - bitplane
|
||||
;; a1 - text
|
||||
;; d0 - xpos
|
||||
;; d1 - ypos
|
||||
movem.l d0-d7/a0-a4,-(sp)
|
||||
WaitBlitter
|
||||
|
||||
;; blitter config that is shared for every character
|
||||
if MASKED_FONT==1
|
||||
move.w #BC0F_SRCA|BC0F_SRCB|BC0F_SRCC|BC0F_DEST|BLIT_LF_MINTERM,d6 ; BLTCON0 value (masked version)
|
||||
move.w #FONTMAP_WIDTH_BYTES-BLIT_WIDTH_BYTES,BLTAMOD(a6) ; A modulo (only used for masked version)
|
||||
else
|
||||
move.w #BC0F_SRCB|BC0F_SRCC|BC0F_DEST|BLIT_LF_MINTERM,d6 ; BLTCON0 value
|
||||
endif
|
||||
move.w #FONTMAP_WIDTH_BYTES-BLIT_WIDTH_BYTES,BLTBMOD(a6) ; B modulo
|
||||
move.w #_BITPLANE_WIDTH_BYTES-BLIT_WIDTH_BYTES,BLTCMOD(a6) ; C modulo
|
||||
move.w #_BITPLANE_WIDTH_BYTES-BLIT_WIDTH_BYTES,BLTDMOD(a6) ; D modulo
|
||||
mulu.w #_BITPLANE_WIDTH_BYTES*_SCREEN_BIT_DEPTH,d1 ; ypos bytes
|
||||
move.w #$0000,BLTALWM(a6) ; mask out extra word used for shifting
|
||||
move.w #$ffff,BLTADAT(a6) ; preload source mask so only BLTA?WM mask is used
|
||||
move.l a1,a3 ; character pointer
|
||||
move.l #font,a5 ; font pointer
|
||||
move.l #fontMask,d7 ; font mask pointer
|
||||
move.w #FONTMAP_WIDTH_BYTES*_SCREEN_BIT_DEPTH*FONT_HEIGHT,d3 ; bytes per font line
|
||||
.loop:
|
||||
clr.l d2
|
||||
move.b (a3)+,d2 ; get next character
|
||||
cmp.b #0,d2 ; 0 terminates the string
|
||||
beq .done
|
||||
move.l a0,a4 ; bitplane pointer
|
||||
bsr DrawChar8 ; draw it
|
||||
add.l #FONT_WIDTH,d0 ; increment the x position
|
||||
bra .loop
|
||||
.done:
|
||||
movem.l (sp)+,d0-d7/a0-a4
|
||||
rts
|
||||
|
||||
DrawChar8:
|
||||
;; kills d2,d4,d5,a1,a2,a4
|
||||
;; d0 - xpos
|
||||
;; d1 - ypos bytes
|
||||
;; d2* - char
|
||||
;; d3 - bytes per font line
|
||||
;; d6 - bltcon0 value
|
||||
;; a4* - bitplane
|
||||
;; a5 - #font
|
||||
;; d7 - #fontMask
|
||||
|
||||
sub.w #' ',d2 ; index = char - '!'
|
||||
move.w d2,d5
|
||||
|
||||
lsr.w #5,d5 ; char / 32 = fontmap line
|
||||
andi.w #$1f,d2 ; char index in line (char index - start of line index)
|
||||
|
||||
add.l #1,d5 ; while we have a weird font image, ' ' starts on second line
|
||||
move.l a5,a1 ; #font
|
||||
|
||||
if 1
|
||||
mulu.w d3,d5 ; d5 *= #FONTMAP_WIDTH_BYTES*_SCREEN_BIT_DEPTH*FONT_HEIGHT
|
||||
else
|
||||
move.w d5,d3
|
||||
lsl.w #7,d3 ; d5 *= FONTMAP_WIDTH_BYTES*_SCREEN_BIT_DEPTH
|
||||
move.w d3,d5
|
||||
add.l d3,d5
|
||||
add.l d3,d5
|
||||
add.l d3,d5
|
||||
add.l d3,d5
|
||||
add.l d3,d5
|
||||
add.l d3,d5
|
||||
add.l d3,d5
|
||||
add.l d3,d5
|
||||
add.l d3,d5
|
||||
endif
|
||||
|
||||
if MASKED_FONT==1
|
||||
move.l d7,a2 ; #fontMask
|
||||
add.w d5,a2 ; add y offset in lines to fontMask address
|
||||
endif
|
||||
|
||||
add.w d5,a1 ; add y offset in lines to font address
|
||||
|
||||
add.w d2,a1 ; add offset into font
|
||||
if MASKED_FONT==1
|
||||
add.l d2,a2 ; add offset into mask
|
||||
endif
|
||||
|
||||
.blitChar8:
|
||||
;; kills a4,d2,d4,d5
|
||||
;; d0 - xpos
|
||||
;; d1 - ypos bytes
|
||||
;; d2.0 - odd character = 1, even character = 0
|
||||
;; d3 - bytes per font line
|
||||
;; d6 - bltcon0 value
|
||||
;; a4 - display
|
||||
;; a1 - object
|
||||
;; a2 - mask
|
||||
|
||||
move.l d0,d4 ; xpos
|
||||
move.l d0,d5 ; xpos
|
||||
lsr.w #3,d4 ; d4 = xpos bytes
|
||||
|
||||
WaitBlitter
|
||||
|
||||
btst #0,d2 ; check if odd or even char
|
||||
beq .evenChar ;
|
||||
.oddChar
|
||||
subq #8,d5 ; offset the x position for the odd character
|
||||
move.w #$00FF,BLTAFWM(a6) ; select the second (odd) character in the word
|
||||
subq #1,a4 ; move the destination pointer left by one byte
|
||||
bra .continue
|
||||
.evenChar:
|
||||
move.w #$FF00,BLTAFWM(a6) ; select the first character in the word
|
||||
.continue:
|
||||
|
||||
;; this shift will give us the bits to shift (bits 0-3) in bits (12-15) of d5
|
||||
swap d5 ; d5 << 12
|
||||
lsr.l #4,d5 ;
|
||||
|
||||
move.w d5,BLTCON1(A6) ; set the shift bits 12-15, bits 00-11 cleared
|
||||
|
||||
if MASKED_FONT==1
|
||||
move.l a2,BLTAPTH(a6) ; mask bitplane
|
||||
endif
|
||||
|
||||
move.l a1,BLTBPTH(a6) ; source bitplane
|
||||
or.w d6,d5 ; d5 = BLTCON0 value
|
||||
move.w d5,BLTCON0(a6) ; set minterm, dma channel and shift
|
||||
|
||||
add.l d4,a4 ; dest += XPOS_BYTES
|
||||
add.l d1,a4 ; dest += YPOS_BYTES
|
||||
|
||||
move.l a4,BLTCPTH(a6) ; background top left corner
|
||||
move.l a4,BLTDPTH(a6) ; destination top left corner
|
||||
|
||||
move.w #(FONT_HEIGHT*_SCREEN_BIT_DEPTH)<<6|(BLIT_WIDTH_WORDS),BLTSIZE(a6) ;rectangle size, starts blit
|
||||
rts
|
||||
|
||||
font:
|
||||
incbin "out/font8x8.bin"
|
||||
fontMask:
|
||||
incbin "out/font8x8-mask.bin"
|
||||
+1
-1
@@ -9,7 +9,7 @@ FONT_WIDTH equ 8
|
||||
FONTMAP_WIDTH_BYTES equ 32
|
||||
_SCREEN_BIT_DEPTH equ 4
|
||||
_BITPLANE_WIDTH_BYTES equ 320/8
|
||||
MASKED_FONT equ 1
|
||||
MASKED_FONT equ 0
|
||||
|
||||
DrawText8:
|
||||
;; a0 - bitplane
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
MPANEL_COPPER_WAIT equ $9ad1 ; controls the vertical position of the message panel
|
||||
|
||||
PLAYER_INITIAL_X equ $c0
|
||||
PLAYER_LEFT_X equ $c0
|
||||
PLAYER_INITIAL_Y equ $e4-32
|
||||
PLAYER_BOTTOM_Y equ $e4+16
|
||||
PLAYER_TOP_Y equ (PLAYER_BOTTOM_Y-(7*16))
|
||||
|
||||
+40
-6
@@ -1,6 +1,8 @@
|
||||
include "includes.i"
|
||||
|
||||
xdef BigBang
|
||||
xdef IncrementScore
|
||||
|
||||
xdef copperList
|
||||
xdef copperListBpl1Ptr
|
||||
xdef copperListBpl1Ptr2
|
||||
@@ -65,7 +67,7 @@ Entry:
|
||||
move.w #(DMAF_SPRITE|DMAF_BLITTER|DMAF_SETCLR!DMAF_COPPER!DMAF_RASTER!DMAF_MASTER),DMACON(a6)
|
||||
|
||||
|
||||
Reset:
|
||||
Reset:
|
||||
move.w #0,moving
|
||||
move.l #fade,fadePtr
|
||||
move.l #panelFade,panelFadePtr
|
||||
@@ -78,7 +80,8 @@ Reset:
|
||||
jsr Message
|
||||
jsr InstallGreyPalette
|
||||
jsr HidePlayer
|
||||
|
||||
bsr RenderScore
|
||||
|
||||
MainLoop:
|
||||
;; MOVE.W #$0024,BPLCON2(a6)
|
||||
|
||||
@@ -135,7 +138,7 @@ GameLoop:
|
||||
move.w #0,moving
|
||||
.s2:
|
||||
jsr ProcessJoystick
|
||||
|
||||
|
||||
jsr CheckPlayerMiss
|
||||
bsr Update
|
||||
bsr RenderNextForegroundFrame
|
||||
@@ -161,7 +164,7 @@ Update:
|
||||
beq .skipForegroundUpdates
|
||||
;; ---- Foreground updates ----------------------------------------
|
||||
.foregroundUpdates:
|
||||
|
||||
jsr CalculateScore
|
||||
move.l foregroundScrollX,d0
|
||||
lsr.l #FOREGROUND_SCROLL_SHIFT_CONVERT,d0 ; convert to pixels
|
||||
andi.l #$f,d0
|
||||
@@ -503,7 +506,6 @@ Level3InterruptHandler:
|
||||
movem.l (sp)+,d0-a6
|
||||
rte
|
||||
|
||||
|
||||
Message:
|
||||
;; a0 - bitplane
|
||||
;; a1 - text
|
||||
@@ -513,18 +515,50 @@ Message:
|
||||
lea message,a1
|
||||
move.w #128,d0
|
||||
move.w #11,d1
|
||||
jsr DrawText8
|
||||
jsr DrawMaskedText8
|
||||
move.w #MPANEL_COPPER_WAIT,mpanelWaitLinePtr
|
||||
rts
|
||||
|
||||
RenderScore:
|
||||
lea panel,a0
|
||||
lea scoreText,a1
|
||||
move.w #31,d0
|
||||
move.w #20,d1
|
||||
jsr DrawText8
|
||||
rts
|
||||
|
||||
|
||||
IncrementScore:
|
||||
movem.l d0-a6,-(sp)
|
||||
lea scoreText,a0
|
||||
add.l #3,a0
|
||||
.loop:
|
||||
sub.l d0,d0
|
||||
move.b (a0),d0
|
||||
addq.b #1,d0
|
||||
cmp.b #'9',d0
|
||||
ble .done
|
||||
move.b #'0',d0
|
||||
move.b d0,(a0)
|
||||
sub.l #1,a0
|
||||
bra .loop
|
||||
.done
|
||||
move.b d0,(a0)
|
||||
jsr RenderScore
|
||||
movem.l (sp)+,d0-a6
|
||||
rts
|
||||
|
||||
message:
|
||||
dc.b "LETS PLAY!"
|
||||
dc.b 0
|
||||
|
||||
align 4
|
||||
|
||||
scoreText:
|
||||
dc.b "0000"
|
||||
dc.b 0
|
||||
|
||||
align 4
|
||||
|
||||
copperList:
|
||||
panelCopperListBpl1Ptr:
|
||||
|
||||
+31
-19
@@ -7,19 +7,18 @@
|
||||
xdef HidePlayer
|
||||
xdef SetupSpriteData
|
||||
xdef ScrollSprites
|
||||
xdef deadSprite
|
||||
xdef spriteX
|
||||
xdef spriteLagX
|
||||
xdef spriteY
|
||||
xdef deadSprite ; used in items
|
||||
xdef UpdatePlayerFallingAnimation
|
||||
xdef InstallPlayerColorPalette
|
||||
xdef SelectNextPlayerSprite
|
||||
xdef CalculateScore
|
||||
|
||||
PLAYER_INSTALL_COLOR_PALETTE equ 0
|
||||
PLAYER_SPRITE_DATA equ 4
|
||||
PLAYER_SPRITE_FALLING_DATA equ 8
|
||||
|
||||
InitialisePlayer:
|
||||
move.w #0,playerMaxX
|
||||
move.l playerSpriteConfig,a0
|
||||
move.l PLAYER_SPRITE_DATA(a0),d0
|
||||
add.l #6*PLAYER_SPRITE_VERTICAL_BYTES,d0
|
||||
@@ -66,13 +65,14 @@ UpdatePlayerFallingAnimation:
|
||||
UpdatePlayer:
|
||||
move.l playerSpriteConfig,a0
|
||||
move.l PLAYER_SPRITE_DATA(a0),d0
|
||||
|
||||
;; right
|
||||
cmp.w #PLAYER_PAUSE_PIXELS,spriteR
|
||||
ble .skipRight
|
||||
add.w #PLAYER_MOVE_PIXELS,spriteX
|
||||
add.w #1,playerX
|
||||
add.l #7*PLAYER_SPRITE_VERTICAL_BYTES,d0
|
||||
move.l d0,currentSprite
|
||||
|
||||
.skipRight
|
||||
cmp.w #0,spriteR
|
||||
beq .notRight
|
||||
@@ -121,6 +121,7 @@ UpdatePlayer:
|
||||
cmp.w #PLAYER_PAUSE_PIXELS,spriteL
|
||||
ble .skipLeft
|
||||
sub.w #PLAYER_MOVE_PIXELS,spriteX
|
||||
sub.w #1,playerX
|
||||
add.l #5*PLAYER_SPRITE_VERTICAL_BYTES,d0
|
||||
move.l d0,currentSprite
|
||||
.skipLeft
|
||||
@@ -139,6 +140,17 @@ UpdatePlayer:
|
||||
rts
|
||||
|
||||
|
||||
CalculateScore:
|
||||
move.w playerX,d0
|
||||
move.w playerMaxX,d1
|
||||
lsr.w #3,d0
|
||||
cmp.w d1,d0
|
||||
ble .skip
|
||||
move.w d0,playerMaxX
|
||||
jsr IncrementScore
|
||||
.skip:
|
||||
rts
|
||||
|
||||
|
||||
ProcessJoystick:
|
||||
;; 812
|
||||
@@ -241,7 +253,6 @@ CheckPlayerMiss:
|
||||
rts
|
||||
|
||||
.check:
|
||||
|
||||
lea map,a2
|
||||
|
||||
;; calculate the a2 offset of the top right tile based on foreground scroll
|
||||
@@ -254,17 +265,22 @@ CheckPlayerMiss:
|
||||
|
||||
;; add the offset based on the sprite's x position
|
||||
move.w spriteLagX,d0
|
||||
sub.w #PLAYER_INITIAL_X,d0
|
||||
|
||||
cmpi.w #PLAYER_LEFT_X,d0
|
||||
blt .doBigBang
|
||||
|
||||
sub.w #PLAYER_LEFT_X,d0
|
||||
lsr.w #4,d0 ; x columns
|
||||
|
||||
|
||||
|
||||
move.l #(FOREGROUND_PLAYAREA_WIDTH_WORDS/2)-1,d1
|
||||
sub.w d0,d1
|
||||
move.w d0,checkXPos
|
||||
mulu.w #FOREGROUND_PLAYAREA_HEIGHT_WORDS*2,d1
|
||||
sub.l d1,a2 ; player x if y == bottom ?
|
||||
|
||||
|
||||
;; add the offset based on the sprite's y postion
|
||||
CheckY:
|
||||
move.w #PLAYER_BOTTOM_Y,d0
|
||||
sub.w spriteY,d0
|
||||
lsr.w #4,d0 ; y columns
|
||||
@@ -272,13 +288,11 @@ CheckY:
|
||||
sub.l d1,d1
|
||||
move.w #FOREGROUND_PLAYAREA_HEIGHT_WORDS-1,d1
|
||||
sub.w d0,d1
|
||||
move.w d0,checkYPos
|
||||
lsl.w #1,d1
|
||||
add.l d1,a2
|
||||
|
||||
;; a2 now points at the tile under the sprite
|
||||
move.w (a2),d0
|
||||
move.w d0,checkTile
|
||||
|
||||
;;
|
||||
cmp.w #$78e,d0
|
||||
@@ -289,13 +303,6 @@ CheckY:
|
||||
.noBigBang:
|
||||
rts
|
||||
|
||||
checkXPos:
|
||||
dc.w 0
|
||||
checkYPos:
|
||||
dc.w 0
|
||||
checkTile:
|
||||
dc.w 0
|
||||
|
||||
SelectNextPlayerSprite:
|
||||
cmp.l #pigPlayerSpriteConfig,playerSpriteConfig
|
||||
bne .s1
|
||||
@@ -345,4 +352,9 @@ spriteX:
|
||||
spriteY:
|
||||
dc.w $e4
|
||||
spriteYEnd:
|
||||
dc.w $f5
|
||||
dc.w $f5
|
||||
playerMaxX:
|
||||
dc.w 0
|
||||
playerX:
|
||||
dc.w 0
|
||||
|
||||
Reference in New Issue
Block a user