Blitters updated to allow arbitrary source locations. IIgs stencil blitter broken. BlitterMap broken.
This commit is contained in:
parent
9ac1b105e2
commit
84fc548775
7 changed files with 105 additions and 46 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -48,16 +48,13 @@ yc equ 9 ; Y Counter
|
||||||
using GlobalData
|
using GlobalData
|
||||||
|
|
||||||
; Find offset into tile memory
|
; Find offset into tile memory
|
||||||
lda sx ; Multiply sx by 4 to get offset (two pixels per byte)
|
; Divide source horizontal position by two since there are two pixels per byte
|
||||||
asl a
|
lda sx ; Load X source position into accumulator
|
||||||
asl a
|
lsr a
|
||||||
sta t
|
sta t
|
||||||
clc
|
clc
|
||||||
lda sy ; Multiply sy by 16 to get index into scanline table
|
lda sy ; Load sy to get index into scanline table
|
||||||
asl a
|
asl a ; Multiply by two to get offset into scanline table (two bytes per entry in table)
|
||||||
asl a
|
|
||||||
asl a
|
|
||||||
asl a ; y screen location is now in the accumulator
|
|
||||||
tay
|
tay
|
||||||
clc
|
clc
|
||||||
lda ScTable,y ; Load byte offset of y position from table
|
lda ScTable,y ; Load byte offset of y position from table
|
||||||
|
@ -141,16 +138,13 @@ stenB equ 13 ; Stencil bit pattern
|
||||||
using GlobalData
|
using GlobalData
|
||||||
|
|
||||||
; Find offset into tile memory
|
; Find offset into tile memory
|
||||||
lda sx ; Multiply sx by 4 to get offset (two pixels per byte)
|
; Divide source horizontal position by two since there are two pixels per byte
|
||||||
asl a
|
lda sx ; Load X source position into accumulator
|
||||||
asl a
|
lsr a ; Shift Right - divide by 2
|
||||||
sta t
|
sta t
|
||||||
clc
|
clc
|
||||||
lda sy ; Multiply sy by 16 to get index into scanline table
|
lda sy ; Load sy to get index into scanline table
|
||||||
asl a
|
asl a ; Multiply by two to get offset into scanline table (two bytes per entry in table)
|
||||||
asl a
|
|
||||||
asl a
|
|
||||||
asl a ; y screen location is now in the accumulator
|
|
||||||
tay
|
tay
|
||||||
clc
|
clc
|
||||||
lda ScTable,y ; Load byte offset of y position from table
|
lda ScTable,y ; Load byte offset of y position from table
|
||||||
|
@ -172,6 +166,7 @@ stenB equ 13 ; Stencil bit pattern
|
||||||
sta target ; Offset to start of target pixels
|
sta target ; Offset to start of target pixels
|
||||||
|
|
||||||
; Find starting stencil byte
|
; Find starting stencil byte
|
||||||
|
;***FIX*** Does not handle non-byte boundaries!
|
||||||
clc
|
clc
|
||||||
lda sy ; Vertical cell position
|
lda sy ; Vertical cell position
|
||||||
asl a ; Multiply by two to get offset into stencil table (two bytes per entry in table)
|
asl a ; Multiply by two to get offset into stencil table (two bytes per entry in table)
|
||||||
|
@ -272,6 +267,9 @@ asmBorder start
|
||||||
|
|
||||||
;----------------------------------------
|
;----------------------------------------
|
||||||
; Draw a block of tiles from a region of tile data
|
; Draw a block of tiles from a region of tile data
|
||||||
|
;
|
||||||
|
; ***FIX*** This no longer does what we want since
|
||||||
|
; blitting source addresses are now in pixels. Fix!
|
||||||
;----------------------------------------
|
;----------------------------------------
|
||||||
asmDrawBM start
|
asmDrawBM start
|
||||||
|
|
||||||
|
|
|
@ -162,8 +162,9 @@ void jlDrawBlit8x8(jlSurfaceT source, jint16 sx, jint16 sy, jint16 tx, jint16 ty
|
||||||
jlPixelPairT *pixels = (jlPixelPairT *)source;
|
jlPixelPairT *pixels = (jlPixelPairT *)source;
|
||||||
jlPixelPairT *target = (jlPixelPairT *)_jlDrawTargetActual;
|
jlPixelPairT *target = (jlPixelPairT *)_jlDrawTargetActual;
|
||||||
|
|
||||||
// We mask off unused bits in the source tile location so they can be used to hold other data.
|
if (jlUtilIsOdd(sx)) sx--; // sx must be even because there are two pixels per byte
|
||||||
o1 = ((sy & 0x1f) * 8 * 160) + ((sx & 0x3f) * 4); // This is in tiles
|
o1 = sy * 160 + (int)(sx * 0.5); // This is in pixels...
|
||||||
|
|
||||||
if (jlUtilIsOdd(tx)) tx--; // tx must be even because there are two pixels per byte
|
if (jlUtilIsOdd(tx)) tx--; // tx must be even because there are two pixels per byte
|
||||||
o2 = ty * 160 + (int)(tx * 0.5); // This is in pixels...
|
o2 = ty * 160 + (int)(tx * 0.5); // This is in pixels...
|
||||||
|
|
||||||
|
@ -178,47 +179,61 @@ void jlDrawBlit8x8(jlSurfaceT source, jint16 sx, jint16 sy, jint16 tx, jint16 ty
|
||||||
|
|
||||||
|
|
||||||
void jlDrawBlit8x8a(jlSurfaceT source, jlStnT *stencil, jint16 sx, jint16 sy, jint16 tx, jint16 ty) {
|
void jlDrawBlit8x8a(jlSurfaceT source, jlStnT *stencil, jint16 sx, jint16 sy, jint16 tx, jint16 ty) {
|
||||||
int mo; // Mask offset
|
|
||||||
int so; // Source Pixel Offset
|
int so; // Source Pixel Offset
|
||||||
int to; // Target Pixel Offset
|
int to; // Target Pixel Offset
|
||||||
|
int i;
|
||||||
int x;
|
int x;
|
||||||
int y;
|
int y;
|
||||||
byte b; // Mask bit index
|
int pos;
|
||||||
jlPixelPairT s; // Source Pixel
|
jlPixelPairT s; // Source Pixel
|
||||||
jlPixelPairT t; // Target Pixel
|
jlPixelPairT t; // Target Pixel
|
||||||
jlPixelPairT *pixels = (jlPixelPairT *)source;
|
jlPixelPairT *pixels = (jlPixelPairT *)source;
|
||||||
jlPixelPairT *target = (jlPixelPairT *)_jlDrawTargetActual;
|
jlPixelPairT *target = (jlPixelPairT *)_jlDrawTargetActual;
|
||||||
|
|
||||||
// We mask off unused bits in the source tile location so they can be used to hold other data.
|
if (jlUtilIsOdd(sx)) sx--; // sx must be even because there are two pixels per byte
|
||||||
mo = ((sy & 0x1f) * 8 * 40) + (sx & 0x3f); // This is in tiles
|
so = sy * 160 + (int)(sx * 0.5); // This is in pixels...
|
||||||
so = ((sy & 0x1f) * 8 * 160) + ((sx & 0x3f) * 4); // This is in tiles
|
|
||||||
if (jlUtilIsOdd(tx)) tx--; // tx must be even because there are two pixels per byte
|
if (jlUtilIsOdd(tx)) tx--; // tx must be even because there are two pixels per byte
|
||||||
to = ty * 160 + (int)(tx * 0.5); // This is in pixels...
|
to = ty * 160 + (int)(tx * 0.5); // This is in pixels...
|
||||||
|
|
||||||
|
// Color = <-- 40 tiles, 80 bytes, 160 pixels -->
|
||||||
|
// Stencil = <-- 20 bytes, 160 bits -->
|
||||||
|
|
||||||
|
i = so / 8;
|
||||||
|
pos = 7 - (so % 8);
|
||||||
|
|
||||||
for (y=0; y<8; y++) {
|
for (y=0; y<8; y++) {
|
||||||
b = 7;
|
|
||||||
for (x=0; x<4; x++) {
|
for (x=0; x<4; x++) {
|
||||||
|
|
||||||
t = target[to];
|
t = target[to];
|
||||||
s = pixels[so++];
|
s = pixels[so++];
|
||||||
|
|
||||||
|
i = ((sy + y) * 320 + (sx + x * 2));
|
||||||
|
pos = 7 - (i % 8);
|
||||||
|
i /= 8;
|
||||||
|
|
||||||
//***FIX*** Another endian order issue. Left & Right are swapped.
|
//***FIX*** Another endian order issue. Left & Right are swapped.
|
||||||
if ((stencil->pixels[mo] & (1 << b--)) != 0) {
|
if ((stencil->pixels[i] & (1 << pos)) != 0) {
|
||||||
t.r = s.r;
|
t.r = s.r;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((stencil->pixels[mo] & (1 << b--)) != 0) {
|
i = ((sy + y) * 320 + (sx + x * 2 + 1));
|
||||||
|
pos = 7 - (i % 8);
|
||||||
|
i /= 8;
|
||||||
|
|
||||||
|
if ((stencil->pixels[i] & (1 << pos)) != 0) {
|
||||||
t.l = s.l;
|
t.l = s.l;
|
||||||
}
|
}
|
||||||
|
|
||||||
target[to++] = t;
|
target[to++] = t;
|
||||||
}
|
}
|
||||||
mo += 40;
|
|
||||||
so += 156;
|
so += 156;
|
||||||
to += 156;
|
to += 156;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//***FIX*** This no longer does what we want since blitting source addresses are now in pixels. Fix!
|
||||||
void jlDrawBlitMap(jint16 startX, jint16 startY, jint16 width, jint16 height, byte *mapData, juint16 stride, jlSurfaceT source) {
|
void jlDrawBlitMap(jint16 startX, jint16 startY, jint16 width, jint16 height, byte *mapData, juint16 stride, jlSurfaceT source) {
|
||||||
// startX = start tile for drawing - in pixels
|
// startX = start tile for drawing - in pixels
|
||||||
// startY = start tile for drawing - in pixels
|
// startY = start tile for drawing - in pixels
|
||||||
|
|
Binary file not shown.
|
@ -88,8 +88,8 @@ void printAt(jlImgT *font, jlStnT *stencil, jint16 cx, jint16 cy, const char *wh
|
||||||
ty = cy * 8;
|
ty = cy * 8;
|
||||||
|
|
||||||
for (counter=0; counter<(int)strlen(msg); counter++) {
|
for (counter=0; counter<(int)strlen(msg); counter++) {
|
||||||
x = msg[counter] % 40;
|
x = (msg[counter] % 40) * 8;
|
||||||
y = msg[counter] / 40;
|
y = (msg[counter] / 40) * 8;
|
||||||
if (stencil) {
|
if (stencil) {
|
||||||
#ifdef JOEY_PC
|
#ifdef JOEY_PC
|
||||||
help(jlImgSurfaceGet(font), stencil, x, y, tx, ty);
|
help(jlImgSurfaceGet(font), stencil, x, y, tx, ty);
|
||||||
|
@ -109,9 +109,8 @@ void blitTest(void) {
|
||||||
jlStnT *stencil = NULL;
|
jlStnT *stencil = NULL;
|
||||||
jint16 y;
|
jint16 y;
|
||||||
jint16 x;
|
jint16 x;
|
||||||
bool doOnce = true;
|
|
||||||
|
|
||||||
if (!jlImgLoad(font, "font")) jlUtilDie("Unable to load font.sta!");
|
if (!jlImgLoad(font, "font")) jlUtilDie("Unable to load font.img!");
|
||||||
if (!jlStnLoad(stencil, "font")) jlUtilDie("Unable to load font.stn!");
|
if (!jlStnLoad(stencil, "font")) jlUtilDie("Unable to load font.stn!");
|
||||||
|
|
||||||
jlImgDisplay(font);
|
jlImgDisplay(font);
|
||||||
|
@ -127,19 +126,11 @@ void blitTest(void) {
|
||||||
jlDisplayPresent();
|
jlDisplayPresent();
|
||||||
jlKeyWaitForAny();
|
jlKeyWaitForAny();
|
||||||
|
|
||||||
/*
|
|
||||||
y = 91;
|
y = 91;
|
||||||
while (!jlKeyPressed()) {
|
while (!jlKeyPressed()) {
|
||||||
for (x=0; x<319-8; x++) {
|
for (x=0; x<319-8; x++) {
|
||||||
|
jlDrawBlit8x8(jlImgSurfaceGet(font), 8, 0, x, y);
|
||||||
if (doOnce) {
|
printAt(font, NULL, 1, 6, "Drawing at %d x %d ", x, y);
|
||||||
jlDrawBlit8x8a(jlImgSurfaceGet(font), stencil, 0, 2, 24, 24);
|
|
||||||
jlDrawBlit8x8(jlImgSurfaceGet(font), 0, 2, 40, 24);
|
|
||||||
doOnce = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
jlDrawBlit8x8(jlImgSurfaceGet(font), 1, 0, x, y);
|
|
||||||
printAt(font, NULL, 1, 1, "Drawing at %d x %d ", x, y);
|
|
||||||
jlDisplayPresent();
|
jlDisplayPresent();
|
||||||
jlDrawBlit8x8(jlImgSurfaceGet(font), 0, 0, x, y);
|
jlDrawBlit8x8(jlImgSurfaceGet(font), 0, 0, x, y);
|
||||||
jlUtilSleep(1);
|
jlUtilSleep(1);
|
||||||
|
@ -149,7 +140,6 @@ void blitTest(void) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
jlKeyRead();
|
jlKeyRead();
|
||||||
*/
|
|
||||||
|
|
||||||
jlStnFree(stencil);
|
jlStnFree(stencil);
|
||||||
jlImgFree(font);
|
jlImgFree(font);
|
||||||
|
@ -204,8 +194,8 @@ void lineTest(void) {
|
||||||
jint16 nextColor = 1;
|
jint16 nextColor = 1;
|
||||||
char what[32];
|
char what[32];
|
||||||
|
|
||||||
if (!jlImgLoad(kanga, "kanga")) jlUtilDie("Unable to load kanga.sta!");
|
if (!jlImgLoad(kanga, "kanga")) jlUtilDie("Unable to load kanga.img!");
|
||||||
if (!jlImgLoad(font, "font")) jlUtilDie("Unable to load font.sta!");
|
if (!jlImgLoad(font, "font")) jlUtilDie("Unable to load font.img!");
|
||||||
|
|
||||||
jlImgDisplay(kanga);
|
jlImgDisplay(kanga);
|
||||||
jlDrawColorSet(1);
|
jlDrawColorSet(1);
|
||||||
|
@ -292,13 +282,69 @@ void lineTest(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void showStencil(void) {
|
||||||
|
jlStnT *stencil = NULL;
|
||||||
|
jint16 y;
|
||||||
|
jint16 x;
|
||||||
|
jint16 count;
|
||||||
|
juint16 index;
|
||||||
|
byte bit;
|
||||||
|
|
||||||
|
if (!jlStnLoad(stencil, "font")) jlUtilDie("Unable to load font.stn!");
|
||||||
|
|
||||||
|
jlDrawColorSet(0);
|
||||||
|
jlDrawClear();
|
||||||
|
jlDrawColorSet(15);
|
||||||
|
|
||||||
|
// Draw stencil to screen linerally
|
||||||
|
index = -1;
|
||||||
|
count = 0;
|
||||||
|
for (y=0; y<200; y++) {
|
||||||
|
for (x=0; x<320; x++) {
|
||||||
|
count--;
|
||||||
|
if (count < 0) {
|
||||||
|
count = 7;
|
||||||
|
index++;
|
||||||
|
bit = stencil->pixels[index];
|
||||||
|
}
|
||||||
|
if (bit & (1 << count)) {
|
||||||
|
jlDrawPixelSet(x, y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
jlDisplayPresent();
|
||||||
|
}
|
||||||
|
jlKeyWaitForAny();
|
||||||
|
|
||||||
|
jlDrawColorSet(0);
|
||||||
|
jlDrawClear();
|
||||||
|
jlDrawColorSet(15);
|
||||||
|
|
||||||
|
// Draw stencil by pixel location
|
||||||
|
for (y=0; y<200; y++) {
|
||||||
|
for (x=0; x<320; x++) {
|
||||||
|
index = (y * 320 + x);
|
||||||
|
count = 7 - (index % 8);
|
||||||
|
index /= 8;
|
||||||
|
bit = stencil->pixels[index];
|
||||||
|
if (bit & (1 << count)) {
|
||||||
|
jlDrawPixelSet(x, y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
jlDisplayPresent();
|
||||||
|
}
|
||||||
|
jlKeyWaitForAny();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
jlUtilStartup("JoeyLib Test");
|
jlUtilStartup("JoeyLib Test");
|
||||||
|
|
||||||
//blitTest();
|
blitTest();
|
||||||
exerciseAPI();
|
//exerciseAPI();
|
||||||
//grid();
|
//grid();
|
||||||
//lineTest();
|
//lineTest();
|
||||||
|
//showStencil();
|
||||||
|
|
||||||
jlUtilShutdown();
|
jlUtilShutdown();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue