mirror of
https://frontier.innolan.net/github/AmigaExamples.git
synced 2026-09-12 07:02:05 +00:00
Simple blit
This commit is contained in:
@@ -4,15 +4,17 @@ IMAGEDATA=out/image-copper-list.s out/image.bin
|
||||
IMAGEFILE=../assets/mission-beach.png
|
||||
TC_IMAGEDATA=out/tc.bin out/tc-mask.bin
|
||||
TC_IMAGEFILE=../assets/tc.png
|
||||
EXTRA=$(IMAGEDATA) $(TC_IMAGEDATA) out/bitblit.s
|
||||
EXTRA=$(IMAGEDATA) $(TC_IMAGEDATA)
|
||||
SHARED_PALETTE_BASE=out/shared-palette
|
||||
SHARED_PALETTE=$(SHARED_PALETTE_BASE).pal
|
||||
|
||||
include ../base.mk
|
||||
|
||||
out/bitblit.s: bitblit.c
|
||||
vc -S bitblit.c -o out/bitblit.s
|
||||
$(SHARED_PALETTE): $(IMAGEFILE) $(TC_IMAGEFILE)
|
||||
$(IMAGECON) --input $(IMAGEFILE),$(TC_IMAGEFILE) --output $(SHARED_PALETTE_BASE) --colors 32 --quantize --output-palette
|
||||
|
||||
$(IMAGEDATA): $(IMAGECON) $(IMAGEFILE)
|
||||
$(IMAGECON) --input $(IMAGEFILE) --output out/image --colors 32 --quantize
|
||||
$(IMAGEDATA): $(IMAGECON) $(IMAGEFILE) $(SHARED_PALETTE)
|
||||
$(IMAGECON) --input $(IMAGEFILE) --output out/image --output-bitplanes --output-copperlist --override-palette $(SHARED_PALETTE)
|
||||
|
||||
$(TC_IMAGEDATA): $(IMAGECON) $(TC_IMAGEFILE)
|
||||
$(IMAGECON) --input $(TC_IMAGEFILE) --output out/tc --colors 32 --quantize --output-mask
|
||||
$(TC_IMAGEDATA): $(IMAGECON) $(TC_IMAGEFILE) $(SHARED_PALETTE)
|
||||
$(IMAGECON) --input $(TC_IMAGEFILE) --output out/tc --output-bitplanes --output-mask --output-copperlist --override-palette $(SHARED_PALETTE)
|
||||
|
||||
@@ -1,15 +1,18 @@
|
||||
Display a simple image
|
||||
======================
|
||||
perform a basic blit
|
||||
=====================
|
||||
|
||||
Building on [trackdisk.device](../000.trackdisk), we now display a simple color image.
|
||||
We make some changes to [001.simple_image)(../001.simple_image):
|
||||
1. The bitplane pointers are now reset using the copper.
|
||||
2. Interrupt processing is disabled
|
||||
3. A6 is now used as the base register for CUSTOM
|
||||
|
||||
I display a 5 bitplane (32 color) low res image.
|
||||
Next we use some new features in [imagecon](../tools/imagecon) that allow us to generate a shared palette based on two PNG images.
|
||||
|
||||
The image data is prepared using a new tool I wrote called [imagecon](../tools/imagecon/imagecon.c). This takes (almost) any 320x256 PNG and using [libimagequant](https://pngquant.org/lib/) it reduces the palette to 32 colors, then dumps out the copper list and interleaved bitplane data ready to be included into [image.s](image.s).
|
||||
This means out sprite and background can share the single palette.
|
||||
|
||||
The original version of this example used [vilcans amiga-startup](https://github.com/vilcans/amiga-startup) as a starting point, however almost all of that code has been replaced as my understanding exanded.
|
||||
We then blit the sprite to the background.
|
||||
|
||||
[Download disk image](bin/image.adf?raw=true)
|
||||
[Download disk image](bin/blit.adf?raw=true)
|
||||
|
||||
Screenshot:
|
||||
|
||||
|
||||
Binary file not shown.
@@ -1,43 +0,0 @@
|
||||
#include "hardware/custom.h"
|
||||
#include "hardware/dmabits.h"
|
||||
|
||||
/*
|
||||
Scrollit:
|
||||
;; --- scroll! ---
|
||||
bltoffs =plotY*ScrBpl*3
|
||||
|
||||
blth =20
|
||||
bltw =w/16
|
||||
bltskip =0 ;modulo
|
||||
brcorner=blth*ScrBpl*3-2
|
||||
|
||||
movem.l d0-a6,-(sp)
|
||||
lea $dff000,a6
|
||||
bsr BlitWait
|
||||
|
||||
move.l #$49f00002,BLTCON0(a6)
|
||||
move.l #$ffffffff,BLTAFWM(a6)
|
||||
move.l #Screen+bltoffs+brcorner,BLTAPTH(a6)
|
||||
move.l #Screen+bltoffs+brcorner,BLTDPTH(a6)
|
||||
move.w #bltskip,BLTAMOD(a6)
|
||||
move.w #bltskip,BLTDMOD(a6)
|
||||
|
||||
move.w #blth*3*64+bltw,BLTSIZE(a6)
|
||||
movem.l (sp)+,d0-a6
|
||||
rts
|
||||
*/
|
||||
|
||||
|
||||
|
||||
extern void blitwait(void);
|
||||
|
||||
void bitblit(unsigned* src, unsigned* dest, unsigned sw, unsigned dw, unsigned dx, unsigned dy)
|
||||
{
|
||||
static struct Custom *custom = (struct Custom *)0xDFF000;
|
||||
|
||||
custom->dmacon = (DMAF_SETCLR|DMAF_COPPER|DMAF_RASTER|DMAF_MASTER);
|
||||
/*
|
||||
blitwait();
|
||||
custom->bltcon0 = 0x49f00002;
|
||||
custom->bltafwm = 0xffffffff;*/
|
||||
}
|
||||
@@ -12,8 +12,6 @@ RASTER_X_START equ $81 ; hard coded coordinates from hardware manual
|
||||
RASTER_Y_START equ $2c
|
||||
RASTER_X_STOP equ RASTER_X_START+SCREEN_WIDTH
|
||||
RASTER_Y_STOP equ RASTER_Y_START+SCREEN_HEIGHT
|
||||
|
||||
public _bitblit
|
||||
|
||||
entry:
|
||||
;; custom chip base globally in a6
|
||||
@@ -22,8 +20,7 @@ entry:
|
||||
move #$7ff,DMACON(a6) ; disable all dma
|
||||
move #$7fff,INTENA(a6) ; disable all interrupts
|
||||
|
||||
;; bsr.s resetBitplanePointers
|
||||
;; reset color registers to white
|
||||
;; reset color registers to white to prevent startup flicker
|
||||
move.l #32,d0
|
||||
lea COLOR00(a6),a0
|
||||
.loop:
|
||||
@@ -108,21 +105,21 @@ TC_WIDTH_BYTES equ TC_WIDTH/8
|
||||
TC_WIDTH_WORDS equ TC_WIDTH/16
|
||||
TC_XPOS equ 16
|
||||
TC_YPOS equ 16
|
||||
TC_XPOS_BYTES equ (TC_XPOS)/8
|
||||
|
||||
doblit:
|
||||
movem.l d0-a6,-(sp)
|
||||
lea $dff000,a6
|
||||
bsr blitWait
|
||||
move.l #$09f00000,BLTCON0(a6) ;A->D copy, no shifts, ascending mode
|
||||
move.l #$ffffffff,BLTAFWM(a6) ;no masking of first/last word
|
||||
move.w #0,BLTAMOD(a6) ;A modulo=bytes to skip between lines
|
||||
move.w #SCREEN_WIDTH_BYTES-TC_WIDTH_BYTES,BLTDMOD(a6) ;D modulo
|
||||
move.l #tc,BLTAPTH(a6) ;source graphic top left corner
|
||||
move.l #bitplanes+(TC_XPOS)/8+(SCREEN_WIDTH_BYTES*SCREEN_BIT_DEPTH*TC_YPOS),BLTDPTH(a6) ;destination top left corner
|
||||
move.w #(TC_HEIGHT*SCREEN_BIT_DEPTH)<<6|(TC_WIDTH_WORDS),BLTSIZE(a6) ;rectangle size, starts blit
|
||||
move.l #bitplanes+TC_XPOS_BYTES+(SCREEN_WIDTH_BYTES*SCREEN_BIT_DEPTH*TC_YPOS),BLTDPTH(a6) ;destination top left corner
|
||||
move.w #(TC_HEIGHT*SCREEN_BIT_DEPTH)<<6|(TC_WIDTH_WORDS),BLTSIZE(a6) ;rectangle size, starts blit
|
||||
movem.l (sp)+,d0-a6
|
||||
rts
|
||||
|
||||
include "out/bitblit.s"
|
||||
copper:
|
||||
;; bitplane pointers must be first else poking addresses will be incorrect
|
||||
dc.w BPL1PTL,0
|
||||
|
||||
Reference in New Issue
Block a user