From 78b904dba3a9c433ab4fa3d6389569d3a1f58b7b Mon Sep 17 00:00:00 2001 From: alpine9000 Date: Sun, 27 Mar 2016 13:09:57 +1100 Subject: [PATCH] Some small optimisations --- 024.simple_text/Makefile | 2 +- 024.simple_text/blit.s | 9 ++-- 024.simple_text/blittext.s | 89 +++++++++++++++++------------------ 024.simple_text/simple_text.s | 9 ++-- 4 files changed, 56 insertions(+), 53 deletions(-) diff --git a/024.simple_text/Makefile b/024.simple_text/Makefile index 0eb5802..59a9d64 100644 --- a/024.simple_text/Makefile +++ b/024.simple_text/Makefile @@ -11,7 +11,7 @@ IMAGES=font.png IMAGEDATA=$(addprefix out/, $(IMAGES:.png=.bin)) VASM_EXTRA_ARGS= -SYMBOL_INFO=-M +#SYMBOL_INFO=-M LINK_COMMANDLINE=vlink -T link.script.x -brawbin1 $< $(OBJS) $(SYMBOL_INFO) -o out/main.bin include ../shared/base.mk diff --git a/024.simple_text/blit.s b/024.simple_text/blit.s index 0bebadd..9211826 100644 --- a/024.simple_text/blit.s +++ b/024.simple_text/blit.s @@ -5,12 +5,14 @@ BLIT_LF_MINTERM equ $ff BlitFillColor: + ;; kills a0,d2,d3,d5,d5 ;; a0 - bitplane ;; d0 - color# ;; d1 - height ;; d2 - ypos - movem.l d0-a6,-(sp) + ;; movem.l d0-d5/a0,-(sp) + ;; movem.l a0,-(sp) mulu.w #SCREEN_WIDTH_BYTES*SCREEN_BIT_DEPTH,d2 add.l d2,a0 move.b #0,d3 ; bitplane # @@ -37,6 +39,7 @@ BlitFillColor: add.w #SCREEN_WIDTH_BYTES,a0 cmp.b #SCREEN_BIT_DEPTH,d3 ; all planes for a single line done ? bne .loop ; no ? do the next plane - jsr WaitBlitter - movem.l (sp)+,d0-a6 + ;; jsr WaitBlitter + ;; movem.l (sp)+,d0-d5/a0 + ;; movem.l (sp)+,a0 rts diff --git a/024.simple_text/blittext.s b/024.simple_text/blittext.s index 6de042b..b7134c1 100644 --- a/024.simple_text/blittext.s +++ b/024.simple_text/blittext.s @@ -12,32 +12,35 @@ DrawText8: ;; a1 - text ;; d0 - xpos ;; d1 - ypos - movem.l d0/d2/a1,-(sp) + movem.l d0-d5/a0-a2,-(sp) + jsr WaitBlitter ;; blitter config that is shared for every character - move.w #SCREEN_WIDTH_BYTES-BLIT_WIDTH_BYTES,BLTAMOD(a6) ;A modulo - move.w #SCREEN_WIDTH_BYTES-BLIT_WIDTH_BYTES,BLTBMOD(a6) ;B modulo - move.w #SCREEN_WIDTH_BYTES-BLIT_WIDTH_BYTES,BLTCMOD(a6) ;C modulo - move.w #SCREEN_WIDTH_BYTES-BLIT_WIDTH_BYTES,BLTDMOD(a6) ;D modulo - + move.w #SCREEN_WIDTH_BYTES-BLIT_WIDTH_BYTES,BLTAMOD(a6) ; A modulo + move.w #SCREEN_WIDTH_BYTES-BLIT_WIDTH_BYTES,BLTBMOD(a6) ; B modulo + move.w #SCREEN_WIDTH_BYTES-BLIT_WIDTH_BYTES,BLTCMOD(a6) ; C modulo + move.w #SCREEN_WIDTH_BYTES-BLIT_WIDTH_BYTES,BLTDMOD(a6) ; D modulo + mulu.w #SCREEN_WIDTH_BYTES*SCREEN_BIT_DEPTH,d1 ; ypos bytes + move.l a1,a5 .loop: - move.b (a1)+,d2 ; get next character + clr.l d2 + move.b (a5)+,d2 ; get next character cmp.b #0,d2 ; 0 terminates the string beq .done - jsr DrawChar8 ; draw it + bsr DrawChar8 ; draw it add.w #FONT_WIDTH,d0 ; increment the x position bra .loop .done: - movem.l (sp)+,d0/d2/a1 + movem.l (sp)+,d0-d5/a0-a2 rts DrawChar8: + ;; kills d2,d3,d4,d5,a1,a2 ;; d0 - xpos - ;; d1 - ypos + ;; d1 - ypos bytes ;; d2 - char ;; a0 - bitplane - movem.l d0-d5/a0-a2,-(sp) - move.w #'!',d4 ; fontmap offset - sub.w d4,d2 ; index = char - '!' + movem.l a0,-(sp) + sub.w #'!',d2 ; index = char - '!' move.w d2,d5 lsr.w #5,d5 ; fontmap y offset @@ -46,7 +49,7 @@ DrawChar8: sub.w d4,d2 ; add.w #1,d5 ; while we have a weird font image, '!' starts on second line - lea font,a1 + lea font(pc),a1 lea fontMask,a2 mulu.w #SCREEN_WIDTH_BYTES*SCREEN_BIT_DEPTH*FONT_HEIGHT,d5 add.w d5,a2 @@ -55,41 +58,37 @@ DrawChar8: btst #0,d2 ; blitter does words only, so we need to know if its an odd or even character beq .even ; then shift it into position with the blitter shift .odd: - move.b #1,d3 + moveq #1,d3 bra .c1 .even: - move.b #0,d3 + moveq #0,d3 .c1 add.w d2,a1 add.w d2,a2 - jsr BlitChar8 - movem.l (sp)+,d0-d5/a0-a2 + bsr BlitChar8 + movem.l (sp)+,a0 rts - + BlitChar8: - ;; kills a0,d0,d3 + ;; kills a0,d2,d4 ;; d0 - xpos - ;; d1 - ypos + ;; d1 - ypos bytes ;; d3 - odd character = 1, even character = 0 ;; a0 - display ;; a1 - object ;; a2 - mask + move.l d0,d4 ; d4 = XPOS + move.l d0,d2 + lsr.w #3,d4 ; d4 = XPOS_BYTES + jsr WaitBlitter - ;; d0 = XPOS - ;; d1 = YPOS - ;; d3 = odd character - ;; d4 = XPOS_BYTES - - move.l d0,d4 ; d4 = XPOS - lsr.w #3,d4 ; d4 = XPOS_BYTES - - cmp.b #1,d3 - bne .evenChar + btst #0,d3 + beq .evenChar .oddChar - sub.w #8,d0 + sub.w #8,d2 move.w #$00FF,BLTAFWM(a6) ; no mask for first word move.w #$0000,BLTALWM(a6) ; mask out last word subq #1,a0 @@ -99,26 +98,24 @@ BlitChar8: move.w #$0000,BLTALWM(a6) ; mask out last word .continue: - ;; this shift will give us the bits to shift (bits 0-3) in bits (12-15) of d0 - lsl.w #8,d0 ; BLIT_SOURCE_SHIFT<