From 1e9d480e0f872828255592872411691f6ea903e9 Mon Sep 17 00:00:00 2001 From: alpine9000 Date: Sat, 26 Mar 2016 21:06:28 +1100 Subject: [PATCH] Use some more blitter --- 024.simple_text/Makefile | 2 +- 024.simple_text/blit2.s | 42 ++++++++++++++++++++++++ 024.simple_text/{blit.s => blittext.s} | 21 ++++-------- 024.simple_text/constants.i | 2 ++ 024.simple_text/init.s | 2 +- 024.simple_text/palette.pal | 2 +- 024.simple_text/simple_text.s | 44 ++++++++++++++------------ 024.simple_text/utils.s | 11 +++++++ 8 files changed, 89 insertions(+), 37 deletions(-) create mode 100644 024.simple_text/blit2.s rename 024.simple_text/{blit.s => blittext.s} (95%) diff --git a/024.simple_text/Makefile b/024.simple_text/Makefile index b1c8082..17c163b 100644 --- a/024.simple_text/Makefile +++ b/024.simple_text/Makefile @@ -5,7 +5,7 @@ BASE_ADDRESS=4000 # if you change this you must also change link.script.x # note: this must be high enough not to conflict with MFMbufE BOOTBLOCK_ASM=alpine_bootblock.s -OBJS=out/init.o out/utils.o out/trackloader.o out/image.o out/disk.o out/blit.o out/cpu.o +OBJS=out/init.o out/utils.o out/trackloader.o out/image.o out/disk.o out/blittext.o out/cpu.o out/blit2.o IMAGES=font.png diff --git a/024.simple_text/blit2.s b/024.simple_text/blit2.s new file mode 100644 index 0000000..612ac74 --- /dev/null +++ b/024.simple_text/blit2.s @@ -0,0 +1,42 @@ + include "includes.i" + + xdef BlitFillColor + +BLIT_LF_MINTERM equ $ff +BLIT_DEST equ $100 +BLIT_SRCC equ $200 +BLIT_SRCB equ $400 +BLIT_SRCA equ $800 + + +BlitFillColor: + ;; d0 - color# + ;; d1 - height + movem.l d0-a6,-(sp) + move.b #0,d3 ; bitplane # +.loop: + move.w d1,d4 + btst d3,d0 ; is the color's bit set in this plane? + beq .zero + move.l #BLIT_DEST|$FF,d2 ; yes ? all ones + bra .doblit +.zero + move.l #BLIT_DEST|$0,d2 ; no ? all zeros +.doblit + jsr WaitBlitter + + move.w #0,BLTCON1(A6) + move.w d2,BLTCON0(A6) + move.w #SCREEN_WIDTH_BYTES*(SCREEN_BIT_DEPTH-1),BLTDMOD(a6) + move.l a0,BLTDPTH(a6) + + lsl.w #6,d4 + ori.w #SCREEN_WIDTH_WORDS,d4 + move.w d4,BLTSIZE(a6) + add.b #1,d3 + add.l #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 + rts diff --git a/024.simple_text/blit.s b/024.simple_text/blittext.s similarity index 95% rename from 024.simple_text/blit.s rename to 024.simple_text/blittext.s index d8f8f3e..28693b7 100644 --- a/024.simple_text/blit.s +++ b/024.simple_text/blittext.s @@ -30,24 +30,18 @@ BLIT_BOB_HEIGHT equ 10 BLIT_BOB_WIDTH_BYTES equ BLIT_BOB_WIDTH/8 BLIT_BOB_WIDTH_WORDS equ BLIT_BOB_WIDTH/16 -blitWait: - tst DMACONR(a6) ;for compatibility -.waitblit: - btst #6,DMACONR(a6) - bne.s .waitblit - rts - ;; blitobject + ;; BlitText ;; d0 - xpos ;; d1 - ypos ;; d3 - odd character ;; a0 - display ;; a1 - object ;; a2 - mask -blitText: +BlitText: movem.l d0-a6,-(sp) - bsr blitWait + jsr WaitBlitter ;; d0 = XPOS ;; d1 = YPOS ;; d3 = odd character @@ -101,20 +95,19 @@ blitText: movem.l (sp)+,d0-a6 rts + DrawText: ;; a0 - bitplane ;; a1 - text ;; d0 - xpos - ;; d1 - ypos - - + ;; d1 - ypos .loop: clr.l d2 move.b (a1)+,d2 cmp.b #0,d2 beq .done jsr DrawChar - add.l #8,d0 + add.l #FONT_WIDTH,d0 bra .loop .done: rts @@ -153,7 +146,7 @@ DrawChar: add.l d2,a1 add.l d2,a2 - jsr blitText + jsr BlitText movem.l (sp)+,d0-a6 rts diff --git a/024.simple_text/constants.i b/024.simple_text/constants.i index 8eb9c09..d036b00 100644 --- a/024.simple_text/constants.i +++ b/024.simple_text/constants.i @@ -1,6 +1,8 @@ +FONT_WIDTH equ 8 SCREEN_WIDTH equ 320 SCREEN_HEIGHT equ 256 SCREEN_WIDTH_BYTES equ (SCREEN_WIDTH/8) +SCREEN_WIDTH_WORDS equ SCREEN_WIDTH_BYTES/2 SCREEN_BIT_DEPTH equ 4 SCREEN_RES equ 8 ; 8=lo resolution, 4=hi resolution RASTER_X_START equ $81 ; hard coded coordinates from hardware manual diff --git a/024.simple_text/init.s b/024.simple_text/init.s index ba47adc..0bae3fa 100644 --- a/024.simple_text/init.s +++ b/024.simple_text/init.s @@ -26,7 +26,7 @@ Init: lea copperList,a0 move.l a0,COP1LC(a6) move.w COPJMP1(a6),d0 - move.w #(DMAF_BLITTER|DMAF_SETCLR!DMAF_COPPER!DMAF_RASTER!DMAF_MASTER),DMACON(a6) + move.w #(DMAF_BLITTER|DMAF_SETCLR!DMAF_COPPER!DMAF_RASTER!DMAF_MASTER),DMACON(a6) ;; move.w #(INTF_SETCLR|INTF_VERTB|INTF_INTEN),INTENA(a6) movem.l (sp)+,d0-a6 rts \ No newline at end of file diff --git a/024.simple_text/palette.pal b/024.simple_text/palette.pal index 85de45b..a116e88 100644 --- a/024.simple_text/palette.pal +++ b/024.simple_text/palette.pal @@ -13,5 +13,5 @@ 255 255 000 255 255 255 000 255 255 255 000 255 -255 255 000 255 +255 000 000 255 diff --git a/024.simple_text/simple_text.s b/024.simple_text/simple_text.s index 1ce71de..5e781fe 100644 --- a/024.simple_text/simple_text.s +++ b/024.simple_text/simple_text.s @@ -21,29 +21,33 @@ Entry: lea Level3InterruptHandler,a3 move.l a3,LVL3_INT_VECTOR + + jsr SwitchBuffers move.w #(INTF_SETCLR|INTF_VERTB|INTF_INTEN),INTENA(a6) + move.w #(DMAF_BLITTER|DMAF_SETCLR!DMAF_MASTER),DMACON(a6) - move.l offscreen,a0 - move.l #4,d0 ; color# - jsr CpuFillColor move.l onscreen,a0 - move.l #4,d0 ; color# - jsr CpuFillColor - - jsr SwitchBuffers - - jsr Init ; enable the playfield - + move.l #4,d0 ; color# + move.w #SCREEN_HEIGHT,d1 ; height + jsr BlitFillColor + move.l offscreen,a0 + move.l #4,d0 ; color# + move.w #SCREEN_HEIGHT,d1 ; height + jsr BlitFillColor + + jsr Init ; enable the playfield + .mainLoop: move.l offscreen,a0 move.l #4,d0 ; color# - jsr CpuFillColor + move.w #25,d1 + jsr BlitFillColor move.l direction,d0 add.l d0,xpos move.l xpos,d0 - move.l #50,d1 + move.l #15,d1 move.l offscreen,a0 lea text,a1 jsr DrawText @@ -51,30 +55,30 @@ Entry: jsr WaitVerticalBlank jsr SwitchBuffers - cmp.l #320-(26*8),xpos - ble .notright + cmp.l #SCREEN_WIDTH-((endText-text)*FONT_WIDTH),xpos + ble .notRightEdge move.l direction,d0 muls.w #-1,d0 move.l d0,direction bra .mainLoop -.notright: +.notRightEdge: cmp.l #0,xpos - bne .mainLoop + bne .notLeftEdge move.l direction,d0 muls.w #-1,d0 - move.l d0,direction - + move.l d0,direction +.notLeftEdge: bra .mainLoop - text: dc.b "My first text on an Amiga!" +endText: dc.b 0 align 4 xpos: dc.l 0 direction: - dc.l 1 + dc.l 2 Level3InterruptHandler: movem.l d0-a6,-(sp) diff --git a/024.simple_text/utils.s b/024.simple_text/utils.s index e907da9..fdb30bc 100644 --- a/024.simple_text/utils.s +++ b/024.simple_text/utils.s @@ -1,6 +1,17 @@ + include "includes.i" + xdef WaitVerticalBlank xdef WaitRaster + xdef WaitBlitter xdef Depack + +WaitBlitter: + tst DMACONR(a6) ;for compatibility +.waitblit: + btst #6,DMACONR(a6) + bne.s .waitblit + rts + WaitVerticalBlank: movem.l d0,-(sp)