Compare commits

..

1 Commits

Author SHA1 Message Date
John Bintz 16bc75fc73 start to try and precalculate more stuff 2024-09-22 08:12:10 -04:00
23 changed files with 1996 additions and 632 deletions

BIN
32x50

Binary file not shown.

View File

@ -1,90 +0,0 @@
/**
* What do we need
* * [ ] screen setup
*/
#include <hardware/custom.h>
#include <hardware/cia.h>
#include <clib/graphics_protos.h>
#include "system/system.h"
#include "system/copper.h"
#include "system/blitter.h"
#include "screen.h"
extern struct Custom far custom;
extern struct CIA far ciaa;
uint16_t custom_color = (uint16_t)offsetof(Custom, color);
uint16_t custom_sprite = (uint16_t)offsetof(Custom, sprpt);
uint16_t custom_sprite_control = (uint16_t)offsetof(Custom, spr);
extern unsigned char chip coolbun[];
int main(void) {
struct ScreenDefinition screenDefinition;
struct ActiveScreenBufferDetails activeScreenBufferDetails;
uint16_t *copperlist, *currentCopperlist;
void *copperlistBitplanePointers[8][2];
int i, plane;
allocateDoubleBufferedScreenMemory(
&screenDefinition,
&activeScreenBufferDetails,
320,
256,
2
);
copperlist = prepareNewCopperlist(300);
currentCopperlist = addDisplayToCopperlist(
copperlist,
&screenDefinition,
&activeScreenBufferDetails,
&copperlistBitplanePointers
);
COPPERLIST_MOVE(currentCopperlist, custom_color, 0x3a6);
COPPERLIST_MOVE(currentCopperlist, custom_color + 2, 0x000);
COPPERLIST_MOVE(currentCopperlist, custom_color + 4, 0xfff);
currentCopperlist = setUpEmptySpritesInCopperlist(currentCopperlist);
endCopperlist(currentCopperlist);
takeOverSystem();
setCopperlist(copperlist);
setUpDisplay((uint32_t)screenDefinition.bitplanes);
// Render a bun at 32x50
for (plane = 0; plane < 2; ++plane) {
custom.bltcon0 = BLTCON0(0xf0, 1, 0, 0, 1, 0);
custom.bltcon1 = BLTCON1(BLITTER_ASCENDING, 0);
custom.bltapt = coolbun + (plane * 4 * 32);
custom.bltdpt = activeScreenBufferDetails.planes[plane] + (50 * 320 / 8) + 32 / 8;
custom.bltafwm = 0xffff;
custom.bltalwm = 0xffff;
custom.bltamod = 0;
custom.bltdmod = 40 - 4;
custom.bltsize = 2 + (32 << 6);
WaitBlit();
}
while (1) {
if ((ciaa.ciapra >> 6) != 3) break;
}
giveBackSystem();
freeCopperlist(copperlist);
teardownScreen(&screenDefinition);
}

BIN
33x50

Binary file not shown.

View File

@ -1,127 +0,0 @@
/**
* What do we need
* * [ ] screen setup
*/
#include <hardware/custom.h>
#include <hardware/cia.h>
#include <clib/graphics_protos.h>
#include "system/system.h"
#include "system/copper.h"
#include "system/blitter.h"
#include "screen.h"
extern struct Custom far custom;
extern struct CIA far ciaa;
uint16_t custom_color = (uint16_t)offsetof(Custom, color);
uint16_t custom_sprite = (uint16_t)offsetof(Custom, sprpt);
uint16_t custom_sprite_control = (uint16_t)offsetof(Custom, spr);
extern unsigned char chip coolbun[];
int main(void) {
struct ScreenDefinition screenDefinition;
struct ActiveScreenBufferDetails activeScreenBufferDetails;
uint16_t *copperlist, *currentCopperlist;
void *copperlistBitplanePointers[8][2];
int i, plane, x, y, dirX, dirY, shift, byteX;
allocateDoubleBufferedScreenMemory(
&screenDefinition,
&activeScreenBufferDetails,
320,
256,
2
);
copperlist = prepareNewCopperlist(300);
currentCopperlist = addDisplayToCopperlist(
copperlist,
&screenDefinition,
&activeScreenBufferDetails,
&copperlistBitplanePointers
);
COPPERLIST_MOVE(currentCopperlist, custom_color, 0x3a6);
COPPERLIST_MOVE(currentCopperlist, custom_color + 2, 0x000);
COPPERLIST_MOVE(currentCopperlist, custom_color + 4, 0xfff);
currentCopperlist = setUpEmptySpritesInCopperlist(currentCopperlist);
endCopperlist(currentCopperlist);
takeOverSystem();
setCopperlist(copperlist);
setUpDisplay((uint32_t)screenDefinition.bitplanes);
// Render a bun at 32x50
x = 32;
y = 50;
dirX = 1;
dirY = 1;
while (1) {
WaitTOF();
swapCurrentScreenBuffer(&screenDefinition, &activeScreenBufferDetails);
shift = x & 15;
byteX = (x >> 4 * 2);
for (plane = 0; plane < 2; ++plane) {
custom.bltcon0 = BLTCON0(0xf0, 1, 0, 0, 1, shift);
custom.bltcon1 = BLTCON1(BLITTER_ASCENDING, 0);
custom.bltapt = coolbun + (plane * 4 * 32);
custom.bltdpt = activeScreenBufferDetails.planes[plane] + (y * 320 / 8) + byteX;
custom.bltafwm = 0xffff;
if (shift == 0) {
custom.bltalwm = 0xffff;;
} else {
custom.bltalwm = 0x0000;
}
custom.bltamod = shift ? -2 : 0;
custom.bltdmod = 40 - (shift ? 6 : 4);
custom.bltsize = (shift ? 3 : 2) + (32 << 6);
WaitBlit();
}
x += dirX;
if (x == 320 - 32) {
x -= 1;
dirX = -dirX;
}
if (x < 0) {
x = 0;
dirX = -dirX;
}
y += dirY;
if (y == 256 - 32) {
y -= 1;
dirY = -dirY;
}
if (y > 0) {
y = 0;
dirY -= dirY;
}
if ((ciaa.ciapra >> 6) != 3) break;
}
giveBackSystem();
freeCopperlist(copperlist);
teardownScreen(&screenDefinition);
}

1
NOTES.md Normal file
View File

@ -0,0 +1 @@
* [ ] Move bun calculation to separate file for CuTest and vamos

View File

@ -1,50 +0,0 @@
## Cool Bun Demo
![demo](./demo.gif)
Built for [The Obligatory Amiga Blitter Video](https://makertube.net/w/eV545ku522sRq8CTcxDuFZ).
Uses a bunch of C and Assembler code to drive the blitter, sprites, and copper
to display high color Topaz art overtop of flying cool bun logos.
## Running
Click the mouse to escape any demo.
* `main`: Main demo
* `32x50`, `33x50`, `left_side`, `right_side`: Rendering Cool Bun in various
locations on screen.
* `any_position`: Cool Bun flies around like a DVD player pause screen.
* `keyboard_interrupt`: Tests using `input.device` to access the keyboard.
* `blitter_speed_test`: Get the speed of blitter vs. CPU memory operations
* `bun_test`: Run some unit tests (yes, really!)
This will get 50 fps on an 020, and 25 or lower on an 68EC020 and below.
## Building
### Vamos
You'll want [Vamos](https://github.com/cnvogelg/amitools/blob/master/docs/vamos.md),
and [SAS/C](https://www.amigaclub.be/blog/steffest/2/amiga-c%20compilers)
&amp; [GenAm from DevPac](https://archive.org/details/Devpac_v3.14_1994-12-16_HiSoft)
on Vamos's path:
```
# main
ruby ./image_converter.rb && touch images.s && vamos -- smake
# any others
vamos -- smake <other>
```
The image converter requires Ruby 3.2.4 and RMagick installed.
## Performance
The best way I can think of to make this way faster is for a script in
Ruby or Python to calculate every blitter register for every frame of data
for bun renders and clears, store that in a list of words, and rip through
those lists in Assembler, shotgunning the values directly into the registers
without the C code needing to track bun positions and bun clears. That's a
project for another day.

BIN
agnus.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

View File

@ -1,144 +0,0 @@
/**
* What do we need
* * [ ] screen setup
*/
#include <hardware/custom.h>
#include <hardware/cia.h>
#include <clib/graphics_protos.h>
#include "system/system.h"
#include "system/copper.h"
#include "system/blitter.h"
#include "screen.h"
extern struct Custom far custom;
extern struct CIA far ciaa;
uint16_t custom_color = (uint16_t)offsetof(Custom, color);
uint16_t custom_sprite = (uint16_t)offsetof(Custom, sprpt);
uint16_t custom_sprite_control = (uint16_t)offsetof(Custom, spr);
extern unsigned char chip coolbun[];
int main(void) {
struct ScreenDefinition screenDefinition;
struct ActiveScreenBufferDetails activeScreenBufferDetails;
uint16_t *copperlist, *currentCopperlist;
void *copperlistBitplanePointers[8][2];
int i, plane, x, y, dirX, dirY, shift, byteX, clearY;
allocateDoubleBufferedScreenMemory(
&screenDefinition,
&activeScreenBufferDetails,
320,
256,
2
);
copperlist = prepareNewCopperlist(300);
currentCopperlist = addDisplayToCopperlist(
copperlist,
&screenDefinition,
&activeScreenBufferDetails,
&copperlistBitplanePointers
);
COPPERLIST_MOVE(currentCopperlist, custom_color, 0x3a6);
COPPERLIST_MOVE(currentCopperlist, custom_color + 2, 0x000);
COPPERLIST_MOVE(currentCopperlist, custom_color + 4, 0xfff);
currentCopperlist = setUpEmptySpritesInCopperlist(currentCopperlist);
endCopperlist(currentCopperlist);
takeOverSystem();
setCopperlist(copperlist);
setUpDisplay((uint32_t)screenDefinition.bitplanes);
// Render a bun at 32x50
x = 32;
y = 50;
dirX = 1;
dirY = 1;
while (1) {
WaitTOF();
swapCurrentScreenBuffer(&screenDefinition, &activeScreenBufferDetails);
shift = x & 15;
byteX = ((x >> 4) * 2);
clearY = y - 4;
if (clearY < 0) clearY = 0;
if (clearY + 40 > 255) clearY = 255 - 40;
for (plane = 0; plane < 2; ++plane) {
custom.bltcon0 = BLTCON0(0xc0, 0, 0, 0, 1, 0);
custom.bltcon1 = 0;
custom.bltadat = 0x0000;
custom.bltdpt = activeScreenBufferDetails.planes[plane] + (clearY * 320 / 8);
custom.bltafwm = 0xffff;
custom.bltalwm = 0xffff;
custom.bltsize = BLTSIZE(20, 40);
custom.bltdmod = 0;
WaitBlit();
}
for (plane = 0; plane < 2; ++plane) {
custom.bltcon0 = BLTCON0(0xf0, 1, 0, 0, 1, shift);
custom.bltcon1 = BLTCON1(BLITTER_ASCENDING, 0);
custom.bltapt = coolbun + (plane * 4 * 32);
custom.bltdpt = activeScreenBufferDetails.planes[plane] + (y * 320 / 8) + byteX;
custom.bltafwm = 0xffff;
if (shift == 0) {
custom.bltalwm = 0xffff;;
} else {
custom.bltalwm = 0x0000;
}
custom.bltamod = shift ? -2 : 0;
custom.bltdmod = 40 - (shift ? 6 : 4);
custom.bltsize = (shift ? 3 : 2) + (32 << 6);
WaitBlit();
}
x += dirX;
if (x == 320 - 32) {
x -= 1;
dirX = -dirX;
}
if (x < 0) {
x = 0;
dirX = -dirX;
}
y += dirY;
if (y == 256 - 32) {
y -= 1;
dirY = -dirY;
}
if (y < 0) {
y = 0;
dirY = -dirY;
}
if ((ciaa.ciapra >> 6) != 3) break;
}
giveBackSystem();
freeCopperlist(copperlist);
teardownScreen(&screenDefinition);
}

BIN
basics Executable file

Binary file not shown.

172
basics.s Normal file
View File

@ -0,0 +1,172 @@
XREF _custom
; write this from scratch and get it working
; then plug it into C
FUNC_CNT SET -30
FUNCDEF MACRO
_LVO\1 EQU FUNC_CNT
FUNC_CNT SET FUNC_CNT-6
ENDM
INCDIR "include_i_39:"
INCDIR "extra_lvos_39:"
INCLUDE "exec/exec_lib.i"
INCLUDE "exec/types.i"
INCLUDE "exec/execbase.i"
INCLUDE "exec/libraries.i" # get the CALLLIB macro
INCLUDE "graphics/gfxbase.i"
INCLUDE "graphics_lvo.i"
INCLUDE "hardware/custom.i"
INCLUDE "hardware/dmabits.i"
START:
BSR _takeOverSystem
BSR _giveBackSystem
MOVE.L #0,D0
RTS
OpenGraphicsLibrary MACRO
LEA GraphicsLibrary,A1
MOVEQ #0,D0
CALLLIB _LVOOpenLibrary
MOVE.L D0,GraphicsBase
ENDM
TakeOverView MACRO
MOVE.L GraphicsBase,A6
MOVE.L gb_ActiView(A6),OldView
MOVEQ #0,D0
CALLLIB _LVOLoadView
CALLLIB _LVOWaitTOF
CALLLIB _LVOWaitTOF
ENDM
PreserveOldCopper MACRO
MOVE.L $26(A6),OldCopper1
MOVE.L $32(A6),OldCopper2
ENDM
GetVBRPointer MACRO
BSR getVBR
MOVE.L D0,VBRPtr
ENDM
PreserveOldRegisters MACRO
LEA _custom,A6
MOVE.W adkconr(A6),Oldadkcon
MOVE.W intenar(A6),Oldintena
MOVE.W dmaconr(A6),Olddmacon
ENDM
ClearRegisters MACRO
MOVE.W #$7FFF,D0
BSR waitRaster
MOVE.W D0,intena(A6)
MOVE.W D0,dmacon(A6)
MOVE.W D0,intreq(A6)
ENDM
SetRegisters MACRO
MOVE.W #$C000,intena(A6) ; enable master interrupt
MOVE.W #$3FFF,intena(A6) ; disable every other interrupt
MOVE.W #DMAF_SETCLR|DMAF_COPPER|DMAF_RASTER|DMAF_BLITTER,dmacon(A6)
MOVE.W #DMAF_AUDIO|DMAF_DISK|DMAF_SPRITE,dmacon(A6)
ENDM
_takeOverSystem:
MOVEM.L A6,-(SP)
CLR.W $100
MOVE.L $4,A6
CALLLIB _LVOForbid
OpenGraphicsLibrary
PreserveOldCopper
CALLLIB _LVOOwnBlitter
CALLLIB _LVOWaitBlit
PreserveOldRegisters
SetRegisters
TakeOverView
MOVEM.L (SP)+,A6
RTS
waitRaster:
MOVE.L D0,-(SP)
.loop:
MOVE.L $DFF004,D0
AND.L #$1FF00,D0
CMP.L #303<<8,D0
BNE .loop
MOVE.L (SP)+,D0
RTS
_giveBackSystem:
CLR.W $100
MOVEM.L A6,-(SP)
LEA _custom,A6
MOVE.W #$8000,d0
OR.W D0,Olddmacon
OR.W D0,Oldintena
OR.W D0,Oldadkcon
SUBQ #1,D0
;ClearRegisters
MOVE.L OldCopper1,cop1lc(A6)
MOVE.L OldCopper2,cop2lc(A6)
MOVE.W #1,copjmp1(A6)
MOVE.W Olddmacon,intena(A6)
MOVE.W Olddmacon,dmacon(A6)
MOVE.W Oldadkcon,adkcon(A6)
MOVE.L OldView,A1
MOVE.L GraphicsBase,A6
CALLLIB _LVOLoadView
CALLLIB _LVOWaitTOF
CALLLIB _LVOWaitTOF
MOVE.L $4,A6
MOVE.L GraphicsBase,D0
MOVE.L D0,A1
CALLLIB _LVOCloseLibrary
CALLLIB _LVOPermit
MOVEM.L (SP)+,A6
RTS
getVBR:
MOVE.L A5,-(SP)
MOVEQ #0,D0
MOVE.L $4,A6
BTST #0,AttnFlags+1(A6)
BEQ .is68K
LEA .get010VBR(pc),A5
CALLLIB _LVOSupervisor
.is68K:
MOVE.L (SP)+,A5
RTS
.get010VBR:
dc.l $4E7A0801 ; movec vcr,d0
RTE
CNOP 0,4
GraphicsLibrary dc.b 'graphics.library',0
CNOP 0,4
GraphicsBase dc.l 1
OldView dc.l 1
OldCopper1 dc.l 1
OldCopper2 dc.l 1
VBRPtr dc.l 1
Oldadkcon dc.w 0
Oldintena dc.w 0
Olddmacon dc.w 0

BIN
better_startup Executable file

Binary file not shown.

98
better_startup.c Normal file
View File

@ -0,0 +1,98 @@
#include <clib/exec_protos.h>
#include <clib/intuition_protos.h>
#include <clib/graphics_protos.h>
#include <exec/memory.h>
#include <graphics/gfxbase.h>
#include <hardware/custom.h>
#include <hardware/dmabits.h>
#include <exec/types.h>
extern struct GfxBase *GfxBase;
extern far struct Custom custom;
int main(void) {
UWORD OldDMACON,OldINTENA,OldINTREQ,OldADKCON;
struct View *OldView = ((struct GfxBase *)GfxBase)->ActiView;
ULONG OldCopper = custom.cop1lc;
ULONG OldCopper2 = custom.cop2lc;
UWORD *copperlist = AllocMem(10000, MEMF_CHIP | MEMF_CLEAR);
UWORD *currentCopperlist;
UBYTE *bitplanes = AllocMem(320 * 256, MEMF_CHIP | MEMF_CLEAR);
int i;
LoadView(0);
WaitTOF();
WaitTOF();
OwnBlitter();
WaitBlit();
Forbid();
OldDMACON = custom.dmaconr | 0x8000;
OldINTENA = custom.intenar | 0x8000;
//OldINTREQ = custom.intreqr | 0x8000;
OldADKCON = custom.adkconr | 0x8000;
custom.intreq = 0x7fff;
custom.cmacon = 0x7fff;
custom.cmacon = 0x7fff;
// enable
custom.dmacon = DMAF_SETCLR | DMAF_COPPER | DMAF_RASTER | DMAF_BLITTER;
// disable
custom.dmacon = DMAF_AUDIO | DMAF_DISK | DMAF_SPRITE;
custom.bplcon0 = (1 << 9) + (1 << 12);
custom.bplcon1 = 0;
custom.bplcon2 = 0;
custom.bpl1mod = 0;
custom.bpl2mod = 0;
custom.diwstrt = 0x2c21;
custom.diwstop = 0x2cc1;
custom.ddfstrt = 0x0038;
custom.ddfstop = 0x00d0;
currentCopperlist = copperlist;
*(currentCopperlist++) = 0x0050;
*(currentCopperlist++) = ((ULONG)bitplanes >> 16);
*(currentCopperlist++) = 0x0020;
*(currentCopperlist++) = ((ULONG)bitplanes && 16);
*(currentCopperlist++) = 0xffff;
*(currentCopperlist++) = 0xfffe;
custom.cop1lc = copperlist;
for (i = 0; i < 200; ++i) {
WaitTOF();
}
custom.dmacon = 0x7FFF;
custom.dmacon = OldDMACON;
custom.intena = 0x7FFF;
custom.intena = OldINTENA;
/*
custom.intreq = 0x7FFF;
custom.intreq = OldINTREQ;
*/
custom.adkcon = 0x7FFF;
custom.adkcon = OldADKCON;
custom.cop1lc = OldCopper;
custom.cop2lc = OldCopper1;
LoadView(OldView);
WaitTOF();
WaitTOF();
WaitBlit();
DisownBlitter();
Permit();
FreeMem(copperlist, 10000);
FreeMem(bitplanes, 320 * 256);
}

0
blitter_speed_test.q Normal file
View File

142
bun.c
View File

@ -14,6 +14,7 @@
#include "bun.h"
#include "system/system.h"
#include "system/blitter.h"
#include "types.h"
#define COOL_BUN_WIDTH (32)
#define COOL_BUN_WIDTH_BYTES (COOL_BUN_WIDTH / 8)
@ -83,21 +84,34 @@ void precalculateBunBLTALWM() {
}
}
struct PrecalcBunInfo {
uint32_t memoryStartOffsetBytes;
uint16_t bltcon0;
uint16_t bltcon1;
uint16_t bltdmod;
};
struct PrecalcBunInfo precalcBunInfo[FRAMES_FOR_SCREEN][BUN_COUNT];
void bun_offRightSide(
int plusXValue,
int y,
struct ScreenDefinition *screenDefinition,
struct ActiveScreenBufferDetails *activeScreenBufferDetails,
struct BunClear *bunClear
struct BunClear *bunClear,
struct PrecalcBunInfo *precalcBunInfo
) {
uint8_t i, plane = 0;
uint8_t shift = plusXValue & 15;
uint8_t wordShift = (plusXValue >> 4);
uint16_t bltalwm, bltcon0, bltcon1, bltdmod, bltsize;
/*
bunClear->memoryStartOffsetBytes = (y * screenDefinition->byteWidth) +
screenDefinition->byteWidth - COOL_BUN_WIDTH_BYTES +
wordShift * 2;
*/
bunClear->memoryStartOffsetBytes = precalcBunInfo->memoryStartOffsetBytes;
bunClear->heightRows = COOL_BUN_HEIGHT;
bunClear->widthWords = 2 - wordShift;
bunClear->direction = BLITTER_ASCENDING;
@ -111,11 +125,14 @@ void bun_offRightSide(
}
*/
bltcon0 = BLTCON0(0xf0, 1, 0, 0, 1, shift);
bltcon1 = BLTCON1(bunClear->direction, shift);
//bltcon0 = BLTCON0(0xf0, 1, 0, 0, 1, shift);
//bltcon1 = BLTCON1(bunClear->direction, shift);
//bltdmod = screenDefinition->byteWidth - COOL_BUN_WIDTH_BYTES +
// wordShift * 2;
bltdmod = screenDefinition->byteWidth - COOL_BUN_WIDTH_BYTES +
wordShift * 2;
bltcon0 = precalcBunInfo->bltcon0;
bltcon1 = precalcBunInfo->bltcon1;
bltdmod = precalcBunInfo->bltdmod;
bltsize = bunClear->widthWords + (bunClear->heightRows << 6);
@ -144,7 +161,8 @@ void bun_offLeftSide(
int y,
struct ScreenDefinition *screenDefinition,
struct ActiveScreenBufferDetails *activeScreenBufferDetails,
struct BunClear *bunClear
struct BunClear *bunClear,
struct PrecalcBunInfo *precalcBunInfo
) {
unsigned char plane;
uint8_t shift = minusXValue & 15;
@ -155,8 +173,11 @@ void bun_offLeftSide(
// y can't be 0 otherwise we will corrupt memory for now
if (y == 0) return;
/*
bunClear->memoryStartOffsetBytes = (screenDefinition->byteWidth * (y + COOL_BUN_LAST_ROW)) +
2 - wordShift * 2;
*/
bunClear->memoryStartOffsetBytes = precalcBunInfo->memoryStartOffsetBytes;
bunClear->heightRows = COOL_BUN_HEIGHT;
bunClear->widthWords = 2 - wordShift;
bunClear->direction = BLITTER_DESCENDING;
@ -170,9 +191,12 @@ void bun_offLeftSide(
}
*/
bltcon0 = BLTCON0(0xf0, 1, 0, 0, 1, shift);
bltcon1 = BLTCON1(bunClear->direction, shift);
bltdmod = screenDefinition->byteWidth - 4 + wordShift * 2;
//bltcon0 = BLTCON0(0xf0, 1, 0, 0, 1, shift);
//bltcon1 = BLTCON1(bunClear->direction, shift);
//bltdmod = screenDefinition->byteWidth - 4 + wordShift * 2;
bltcon0 = precalcBunInfo->bltcon0;
bltcon1 = precalcBunInfo->bltcon1;
bltdmod = precalcBunInfo->bltdmod;
bltsize = bunClear->widthWords + (bunClear->heightRows << 6);
@ -204,22 +228,29 @@ void bun_anywhere(
int y,
struct ScreenDefinition *screenDefinition,
struct ActiveScreenBufferDetails *activeScreenBufferDetails,
struct BunClear *bunClear
struct BunClear *bunClear,
struct PrecalcBunInfo *precalcBunInfo
) {
uint8_t plane;
uint8_t shift = x & 15;
uint8_t needsExtraWord = shift != 0;
uint16_t bltcon0, bltcon1, bltalwm, bltamod, bltdmod, bltsize;
bunClear->memoryStartOffsetBytes = WORD_ALIGNED_BYTE_POSITION(screenDefinition->width, x, y);
//bunClear->memoryStartOffsetBytes = WORD_ALIGNED_BYTE_POSITION(screenDefinition->width, x, y);
bunClear->memoryStartOffsetBytes = precalcBunInfo->memoryStartOffsetBytes;
bunClear->heightRows = COOL_BUN_HEIGHT;
bunClear->widthWords = 2 + needsExtraWord;
bunClear->direction = BLITTER_ASCENDING;
// buns will never interfere with a background so they don't need a mask
bltcon0 = BLTCON0(0xf0, 1, 0, 0, 1, shift);
bltcon1 = BLTCON1(bunClear->direction, shift);
//bltcon0 = BLTCON0(0xf0, 1, 0, 0, 1, shift);
//bltcon1 = BLTCON1(bunClear->direction, shift);
//bltdmod = screenDefinition->byteWidth - COOL_BUN_WIDTH_BYTES - (needsExtraWord * 2);
bltcon0 = precalcBunInfo->bltcon0;
bltcon1 = precalcBunInfo->bltcon1;
bltdmod = precalcBunInfo->bltdmod;
if (needsExtraWord) {
bltalwm = 0x0000;
@ -228,7 +259,6 @@ void bun_anywhere(
}
bltamod = -(needsExtraWord * 2);
bltdmod = screenDefinition->byteWidth - COOL_BUN_WIDTH_BYTES - (needsExtraWord * 2);
bltsize = bunClear->widthWords + (bunClear->heightRows << 6);
for (plane = 0; plane < 2; ++plane) {
@ -252,12 +282,15 @@ void bun_anywhere(
#define ENABLE_RENDER_BUN_CHECKING (0)
uint16_t screenDefCoolBunWidthCheck;
void renderBun(
int x,
int y,
struct ScreenDefinition *screenDefinition,
struct ActiveScreenBufferDetails *activeScreenBufferDetails,
struct BunClear *bunClear
struct BunClear *bunClear,
struct PrecalcBunInfo *precalcBunInfo
) {
/**
* Conditions that will cause the program to crash if met. If your bun
@ -279,15 +312,19 @@ void renderBun(
y,
screenDefinition,
activeScreenBufferDetails,
bunClear
bunClear,
precalcBunInfo
);
} else if (x > screenDefinition->width - COOL_BUN_WIDTH) {
//} else if (x > screenDefinition->width - COOL_BUN_WIDTH) {
} else if (x > screenDefCoolBunWidthCheck) {
bun_offRightSide(
x - (screenDefinition->width - COOL_BUN_WIDTH),
//x - (screenDefinition->width - COOL_BUN_WIDTH),
x - screenDefCoolBunWidthCheck,
y,
screenDefinition,
activeScreenBufferDetails,
bunClear
bunClear,
precalcBunInfo
);
} else {
bun_anywhere(
@ -295,7 +332,8 @@ void renderBun(
y,
screenDefinition,
activeScreenBufferDetails,
bunClear
bunClear,
precalcBunInfo
);
}
}
@ -341,6 +379,66 @@ void calculateBunPositions(
short int allBunPositionsByFrame[FRAMES_FOR_SCREEN][BUN_COUNT][2];
void precalculateBunInfoForFrames(
struct ScreenDefinition *screenDefinition
) {
int frame, bun;
int x, y;
uint8_t wordShift, shift, needsExtraWord;
screenDefCoolBunWidthCheck = screenDefinition->width - COOL_BUN_WIDTH;
for (frame = 0; frame < FRAMES_FOR_SCREEN; ++frame) {
for (bun = 0; bun < BUN_COUNT; ++bun) {
x = allBunPositionsByFrame[frame][bun][0];
y = allBunPositionsByFrame[frame][bun][1];
// off left
if (x < 0) {
x = -x;
shift = x & 15;
wordShift = x >> 4;
precalcBunInfo[frame][bun].memoryStartOffsetBytes =
(screenDefinition->byteWidth * (y + COOL_BUN_LAST_ROW)) +
2 - wordShift * 2;
precalcBunInfo[frame][bun].bltcon0 = BLTCON0(0xf0, 1, 0, 0, 1, shift);
precalcBunInfo[frame][bun].bltcon1 = BLTCON1(BLITTER_DESCENDING, shift);
precalcBunInfo[frame][bun].bltdmod =
screenDefinition->byteWidth - 4 +
wordShift * 2;
// off right
} else if (x > screenDefinition->width - COOL_BUN_WIDTH) {
x = x - (screenDefinition->width - COOL_BUN_WIDTH),
wordShift = x >> 4;
shift = x & 15;
precalcBunInfo[frame][bun].memoryStartOffsetBytes =
(y * screenDefinition->byteWidth) +
screenDefinition->byteWidth - COOL_BUN_WIDTH_BYTES +
wordShift * 2;
precalcBunInfo[frame][bun].bltcon0 = BLTCON0(0xf0, 1, 0, 0, 1, shift);
precalcBunInfo[frame][bun].bltcon1 = BLTCON1(BLITTER_ASCENDING, shift);
precalcBunInfo[frame][bun].bltdmod =
screenDefinition->byteWidth - COOL_BUN_WIDTH_BYTES +
wordShift * 2;
// anywhere
} else {
shift = x & 15;
needsExtraWord = shift != 0;
precalcBunInfo[frame][bun].memoryStartOffsetBytes =
WORD_ALIGNED_BYTE_POSITION(screenDefinition->width, x, y);
precalcBunInfo[frame][bun].bltcon0 = BLTCON0(0xf0, 1, 0, 0, 1, shift);
precalcBunInfo[frame][bun].bltcon1 = BLTCON1(BLITTER_ASCENDING, shift);
precalcBunInfo[frame][bun].bltdmod =
screenDefinition->byteWidth - COOL_BUN_WIDTH_BYTES - (needsExtraWord * 2);
}
}
}
}
void calculateAllBunPositions(
struct ScreenDefinition *screenDefinition
) {
@ -389,6 +487,7 @@ void setupBunRenderer(
calculateAllBunPositions(screenDefinition);
precalculateBunRenderInfo();
precalculateBunBLTALWM();
precalculateBunInfoForFrames(screenDefinition);
}
/**
@ -446,7 +545,8 @@ void renderBunFrame(
allBunPositionsByFrame[frame][bun][1],
bunRenderer->screenDefinition,
bunRenderer->activeScreenBufferDetails,
&bunClearForScreen[bunRenderer->activeScreenBufferDetails->currentBuffer][bun]
&bunClearForScreen[bunRenderer->activeScreenBufferDetails->currentBuffer][bun],
&precalcBunInfo[frame][bun]
);
}

BIN
demo.gif

Binary file not shown.

Before

Width:  |  Height:  |  Size: 892 KiB

BIN
left_side

Binary file not shown.

View File

@ -1,90 +0,0 @@
/**
* What do we need
* * [ ] screen setup
*/
#include <hardware/custom.h>
#include <hardware/cia.h>
#include <clib/graphics_protos.h>
#include "system/system.h"
#include "system/copper.h"
#include "system/blitter.h"
#include "screen.h"
extern struct Custom far custom;
extern struct CIA far ciaa;
uint16_t custom_color = (uint16_t)offsetof(Custom, color);
uint16_t custom_sprite = (uint16_t)offsetof(Custom, sprpt);
uint16_t custom_sprite_control = (uint16_t)offsetof(Custom, spr);
extern unsigned char chip coolbun[];
int main(void) {
struct ScreenDefinition screenDefinition;
struct ActiveScreenBufferDetails activeScreenBufferDetails;
uint16_t *copperlist, *currentCopperlist;
void *copperlistBitplanePointers[8][2];
int i, plane;
allocateDoubleBufferedScreenMemory(
&screenDefinition,
&activeScreenBufferDetails,
320,
256,
2
);
copperlist = prepareNewCopperlist(300);
currentCopperlist = addDisplayToCopperlist(
copperlist,
&screenDefinition,
&activeScreenBufferDetails,
&copperlistBitplanePointers
);
COPPERLIST_MOVE(currentCopperlist, custom_color, 0x3a6);
COPPERLIST_MOVE(currentCopperlist, custom_color + 2, 0x000);
COPPERLIST_MOVE(currentCopperlist, custom_color + 4, 0xfff);
currentCopperlist = setUpEmptySpritesInCopperlist(currentCopperlist);
endCopperlist(currentCopperlist);
takeOverSystem();
setCopperlist(copperlist);
setUpDisplay((uint32_t)screenDefinition.bitplanes);
// Render a cut off bun at -8x50
for (plane = 0; plane < 2; ++plane) {
custom.bltcon0 = BLTCON0(0xf0, 1, 0, 0, 1, 8);
custom.bltcon1 = BLTCON1(BLITTER_DESCENDING, 8);
custom.bltapt = coolbun + (plane * 4 * 32) + (31 * 4) + 2;
custom.bltdpt = activeScreenBufferDetails.planes[plane] + ((50 + 31) * 320 / 8) + 2;
custom.bltafwm = 0xffff;
custom.bltalwm = 0x00ff;
custom.bltamod = 0;
custom.bltdmod = 40 - 4;
custom.bltsize = 2 + (32 << 6);
WaitBlit();
}
while (1) {
if ((ciaa.ciapra >> 6) != 3) break;
}
giveBackSystem();
freeCopperlist(copperlist);
teardownScreen(&screenDefinition);
}

1604
marquee.svg Normal file

File diff suppressed because it is too large Load Diff

After

Width:  |  Height:  |  Size: 62 KiB

Binary file not shown.

View File

@ -1,90 +0,0 @@
/**
* What do we need
* * [ ] screen setup
*/
#include <hardware/custom.h>
#include <hardware/cia.h>
#include <clib/graphics_protos.h>
#include "system/system.h"
#include "system/copper.h"
#include "system/blitter.h"
#include "screen.h"
extern struct Custom far custom;
extern struct CIA far ciaa;
uint16_t custom_color = (uint16_t)offsetof(Custom, color);
uint16_t custom_sprite = (uint16_t)offsetof(Custom, sprpt);
uint16_t custom_sprite_control = (uint16_t)offsetof(Custom, spr);
extern unsigned char chip coolbun[];
int main(void) {
struct ScreenDefinition screenDefinition;
struct ActiveScreenBufferDetails activeScreenBufferDetails;
uint16_t *copperlist, *currentCopperlist;
void *copperlistBitplanePointers[8][2];
int i, plane;
allocateDoubleBufferedScreenMemory(
&screenDefinition,
&activeScreenBufferDetails,
320,
256,
2
);
copperlist = prepareNewCopperlist(300);
currentCopperlist = addDisplayToCopperlist(
copperlist,
&screenDefinition,
&activeScreenBufferDetails,
&copperlistBitplanePointers
);
COPPERLIST_MOVE(currentCopperlist, custom_color, 0x3a6);
COPPERLIST_MOVE(currentCopperlist, custom_color + 2, 0x000);
COPPERLIST_MOVE(currentCopperlist, custom_color + 4, 0xfff);
currentCopperlist = setUpEmptySpritesInCopperlist(currentCopperlist);
endCopperlist(currentCopperlist);
takeOverSystem();
setCopperlist(copperlist);
setUpDisplay((uint32_t)screenDefinition.bitplanes);
// Render a cut off bun at -8x50
for (plane = 0; plane < 2; ++plane) {
custom.bltcon0 = BLTCON0(0xf0, 1, 0, 0, 1, 8);
custom.bltcon1 = BLTCON1(BLITTER_ASCENDING, 8);
custom.bltapt = coolbun + (plane * 4 * 32);
custom.bltdpt = activeScreenBufferDetails.planes[plane] + (50 * 320 / 8) + (40 - 4);
custom.bltafwm = 0xffff;
custom.bltalwm = 0xff00;
custom.bltamod = 0;
custom.bltdmod = 40 - 4;
custom.bltsize = 2 + (32 << 6);
WaitBlit();
}
while (1) {
if ((ciaa.ciapra >> 6) != 3) break;
}
giveBackSystem();
freeCopperlist(copperlist);
teardownScreen(&screenDefinition);
}

View File

@ -1,9 +1,4 @@
MAIN_OBJS = main.o images.o system.lib screen.o bun.o
32_objs = 32x50_bun.o system.lib screen.o images.o
33_objs = 33x50_bun.o system.lib screen.o images.o
left_side_objs = left_side.o system.lib screen.o images.o
right_side_objs = right_side.o system.lib screen.o images.o
any_position = any_position.o system.lib screen.o images.o
all: main
@ -19,21 +14,6 @@ system.lib: system/system.o system/copper.o system/blitter.o system/debug.o
main: $(MAIN_OBJS)
sc link to main math=standard $(MAIN_OBJS)
32x50: $(32_objs)
sc link to 32x50 $(32_objs)
33x50: $(33_objs)
sc link to 33x50 $(33_objs)
left_side: $(left_side_objs)
sc link to left_side $(left_side_objs)
right_side: $(right_side_objs)
sc link to right_side $(right_side_objs)
any_position: $(any_position)
sc link to any_position $(any_position)
test: bun_test.o bun.o
sc link to bun_test identifierlength=32 math=standard bun_test.o bun.o cutest/CuTest.c

BIN
topaz2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB