From 1a68ad9e6c7e36e7818f6084d1f432bf09c4f5cf Mon Sep 17 00:00:00 2001 From: Scott Duensing Date: Sun, 23 Jun 2019 20:51:16 -0500 Subject: [PATCH] Just syncing repo with current code. --- joeylib/build-IIgs.sh | 12 +- joeylib/src/jIIgs.asm | 270 ++++++++++++++++++----------------- joeylib/src/jIIgs.c | 1 - joeylib/src/jPC.c | 66 ++++++--- joeylib/src/joey.c | 32 +---- joeylib/src/joey.h | 20 +-- scripts/build-IIgs.helper.sh | 6 +- 7 files changed, 212 insertions(+), 195 deletions(-) diff --git a/joeylib/build-IIgs.sh b/joeylib/build-IIgs.sh index 6a3259b..160e524 100755 --- a/joeylib/build-IIgs.sh +++ b/joeylib/build-IIgs.sh @@ -1,6 +1,6 @@ #!/bin/bash -e -OUT=${JOEY}/sdks/iix/IIgs/out/joey +OUT=${JOEY}/sdks/IIgs/ORCA/out/joey if [ -d ${OUT} ]; then rm -rf ${OUT} @@ -8,7 +8,7 @@ fi mkdir -p ${OUT} pushd ${JOEY}/joeylib/joeylib/src -iix assemble jIIgs.asm keep=31:/out/joey/jIIgsasm +iix assemble +L jIIgs.asm keep=31:/out/joey/jIIgsasm > jIIgs.asm.map iix compile jIIgs.c keep=31:/out/joey/jIIgsc iix compile joey.c keep=31:/out/joey/joey @@ -22,17 +22,17 @@ iix -DKeepType=S16 link +L 31:/out/joey/test 31:/out/joey/joeylib keep=31:/out/j iix dumpobj +D 31:/out/joey/test &> test.dis || true -php ${JOEY}/sdks/iix/ntconverter.php *.mod +php ${JOEY}/sdks/IIgs/ntconverter.php *.mod popd mkdir -p ${JOEY}/dist/IIgs cp -f ${JOEY}/joeylib/joeylib/lib/IIgs/Tool221#ba0000 ${JOEY}/dist/IIgs/. cp -f ${OUT}/joeylib ${JOEY}/dist/IIgs/joeylib#b20000 cp -f ${JOEY}/joeylib/joeylib/src/joey.h ${JOEY}/dist/. -cp -f ${JOEY}/joeylib/joeylib/build-IIgs.helper.sh ${JOEY}/dist/IIgs/. +cp -f ${JOEY}/joeylib/scripts/build-IIgs.helper.sh ${JOEY}/dist/IIgs/. if [ ! -z $1 ]; then - CADIUS=${JOEY}/sdks/iix/cadius-git/bin/release/cadius + CADIUS=${JOEY}/sdks/IIgs/cadius-git/bin/release/cadius IMPORT=/tmp/IIgs/import.po VOL=Import @@ -54,7 +54,7 @@ if [ ! -z $1 ]; then ${CADIUS} addfile ${IMPORT} ${VOL}/data ${OUT}/music#D50000 > /dev/null ${CADIUS} addfile ${IMPORT} ${VOL}/data ${OUT}/music.w#060000 > /dev/null - pushd ${JOEY}/sdks/iix/gsplus + pushd ${JOEY}/sdks/IIgs/gsplus ./gsplus -resizeable -config IIgsTest.cfg || true popd echo "" diff --git a/joeylib/src/jIIgs.asm b/joeylib/src/jIIgs.asm index b5cc43b..d3a5a1a 100644 --- a/joeylib/src/jIIgs.asm +++ b/joeylib/src/jIIgs.asm @@ -22,6 +22,7 @@ mcopy 13:ORCAInclude:m16.ORCA mcopy jIIgs.macro case on + gen on SHRShad gequ $012000 @@ -220,38 +221,47 @@ t equ 1 ;---------------------------------------- asmB88a start -t equ 1 +mo equ 1 ; Mask Offset +so equ 3 ; Source Pixels Offset +to equ 5 ; Target Pixels Offset +t equ 7 ; Temp +xc equ 9 ; X Counter +yc equ 11 ; Y Counter - jsubroutine (4:p,2:cx1,2:cy1,2:cx2,2:cy2,2:alpha),2 + jsubroutine (4:p,2:cx1,2:cy1,2:cx2,2:cy2,2:offset),12 using ScanTable phb ; Push our current data bank onto the stack ; ***TODO*** Mask off unused bits so they can be used for other things elsewhere ; Find offset into tile memory - clc lda cx1 ; Multiply cx1 by 4 to get offset (two pixels per byte) asl a asl a sta t - clc lda cy1 ; Multiply cy1 by 16 to get index into scanline table asl a asl a asl a asl a ; y1 is now in the accumulator - clc tax + clc lda >ScanTable,x adc t ; Add t to scanline offset - tay ; Offset to start of tile -; Find offset into shadow SHR memory + sta so ; Offset to start of source pixels + + lda offset ; Load offset + asl a ; Multiply by 4 + asl a clc + adc so ; Add to source pixel offset + sta mo ; Offset to start of mask pixels + +; Find offset into shadow SHR memory lda cx2 ; Multiply cx1 by 4 to get offset (two pixels per byte) asl a asl a sta t - clc lda cy2 ; Multiply cy1 by 16 to get index into scanline table asl a asl a @@ -261,135 +271,67 @@ t equ 1 tax lda >ScanTable,x adc t ; Add t to scanline offset - tax ; Offset to start of screen memory + sta to ; Offset to start of target pixels sei ; Disable interrupts while we change data banks pea $0101 ; Push Effective Address (our new data bank) always 16 bits plb ; Pull data bank from stack (data bank now $01) plb ; Do it twice because it's only an 8 bit operation -; Row 1 - lda [p],y ; Load 4 pixels from SHA data - sta |SHRShad,x ; Store 4 pixels into screen - inx ; Move to next pixel quad - inx - iny - iny - lda [p],y ; Load 4 pixels from SHA data - sta |SHRShad,x ; Store 4 pixels into screen -; Move to row 2 - txa - adc #158 ; Next line - tax - tya - adc #158 ; Next line - tay -; Row 2 - lda [p],y ; Load 4 pixels from SHA data - sta |SHRShad,x ; Store 4 pixels into screen - inx ; Move to next pixel quad - inx - iny - iny - lda [p],y ; Load 4 pixels from SHA data - sta |SHRShad,x ; Store 4 pixels into screen -; Move to row 3 - txa - adc #158 ; Next line - tax - tya - adc #158 ; Next line - tay -; Row 3 - lda [p],y ; Load 4 pixels from SHA data - sta |SHRShad,x ; Store 4 pixels into screen - inx ; Move to next pixel quad - inx - iny - iny - lda [p],y ; Load 4 pixels from SHA data - sta |SHRShad,x ; Store 4 pixels into screen -; Move to row 4 - txa - adc #158 ; Next line - tax - tya - adc #158 ; Next line - tay -; Row 4 - lda [p],y ; Load 4 pixels from SHA data - sta |SHRShad,x ; Store 4 pixels into screen - inx ; Move to next pixel quad - inx - iny - iny - lda [p],y ; Load 4 pixels from SHA data - sta |SHRShad,x ; Store 4 pixels into screen -; Move to row 5 - txa - adc #158 ; Next line - tax - tya - adc #158 ; Next line - tay -; Row 5 - lda [p],y ; Load 4 pixels from SHA data - sta |SHRShad,x ; Store 4 pixels into screen - inx ; Move to next pixel quad - inx - iny - iny - lda [p],y ; Load 4 pixels from SHA data - sta |SHRShad,x ; Store 4 pixels into screen -; Move to row 6 - txa - adc #158 ; Next line - tax - tya - adc #158 ; Next line - tay -; Row 6 - lda [p],y ; Load 4 pixels from SHA data - sta |SHRShad,x ; Store 4 pixels into screen - inx ; Move to next pixel quad - inx - iny - iny - lda [p],y ; Load 4 pixels from SHA data - sta |SHRShad,x ; Store 4 pixels into screen -; Move to row 7 - txa - adc #158 ; Next line - tax - tya - adc #158 ; Next line - tay -; Row 7 - lda [p],y ; Load 4 pixels from SHA data - sta |SHRShad,x ; Store 4 pixels into screen - inx ; Move to next pixel quad - inx - iny - iny - lda [p],y ; Load 4 pixels from SHA data - sta |SHRShad,x ; Store 4 pixels into screen -; Move to row 8 - txa - adc #158 ; Next line - tax - tya - adc #158 ; Next line - tay -; Row 8 - lda [p],y ; Load 4 pixels from SHA data - sta |SHRShad,x ; Store 4 pixels into screen - inx ; Move to next pixel quad - inx - iny - iny - lda [p],y ; Load 4 pixels from SHA data + lda #0 + sta xc ; Load 0 into X and Y counters + sta yc + +blitATop ldx to ; Load X and Y registers with target pixel offset + ldy to + lda SHRShad,x ; Load 4 target pixels + ldy mo ; Load Y register with pixel mask offset + and [p],y ; AND with mask + ldy so ; Load Y register with source pixel offset + ora [p],y ; OR with source pixels sta |SHRShad,x ; Store 4 pixels into screen + clc ; Increment to next pixel target quad + lda #2 + adc to + sta to + clc ; Increment to next pixel source quad + lda #2 + adc so + sta so + clc ; Increment to next pixel mask quad + lda #2 + adc mo + sta mo + + clc + lda xc ; Increment X counter + adc #1 + sta xc + cmp #2 ; End of X pixels? + bcc blitATop ; Nope! + + lda #0 ; Reset X counter + sta xc + clc ; Increment target offset + lda #156 + adc to + sta to + clc ; Increment source offset + lda #156 + adc so + sta so + clc ; Increment mask offset + lda #156 + adc mo + sta mo + clc + lda yc ; Increment Y counter + adc #1 + sta yc + cmp #8 ; End of Y pixels? + bcc blitATop ; Nope! + plb ; Pull original data bank from stack cli ; Restore interrupts @@ -410,6 +352,76 @@ asmBorder start jreturn end +;---------------------------------------- +; Draw a block of tiles from a region of tile data +;---------------------------------------- +asmDrawBM start + +tileX equ 1 +tileY equ 3 +offset equ 5 +loopX equ 7 +loopY equ 9 + + jsubroutine (2:startX,2:startY,2:width,2:height,4:mapData,2:stride,4:tiles),10 + + lda #0 ; Zero some starting values + sta offset + + clc ; Find loop ending values + lda startX + adc width + sta loopX + clc + lda startY + adc height + sta loopY + + ldx startX ; Loop counters + ldy startY + +drawTop phy ; Keep Y for later + ldy offset ; Y is now offset into map data + lda [pixels[o1++]; - t = _jlBackingStore->pixels[o2]; - if (p.l != alpha) { - t.l = p.l; - } - if (p.r != alpha) { - t.r = p.r; - } - _jlBackingStore->pixels[o2++] = t; + m = sta->pixels[mo++]; + s = sta->pixels[so++]; + t = _jlBackingStore->pixels[to]; + t.r = (t.r & m.r) | s.r; + t.l = (t.l & m.l) | s.l; + _jlBackingStore->pixels[to++] = t; } - o1 += 156; - o2 += 156; + mo += 156; + so += 156; + to += 156; + } +} + + +void jlDrawBlitMap(jint16 startX, jint16 startY, jint16 width, jint16 height, byte *mapData, juint16 stride, jlStaT *sta) { + // startX = start tile for drawing + // startY = start tile for drawing + // width = tiles to draw horizontally + // height = tiles to draw vertically + // mapData = pointer to tile x/y pairs to draw + // stride = number of tile bytes to skip in the mapData for every horizontal line + // tiles = sta to fetch tile data from + jint16 x; + jint16 y; + byte tileX; + byte tileY; + juint16 offset = 0; + + for (y=startY; y= ignoreEnd) && (jlDrawGetPixel(x, y) == _jlDrawFillColor)) { jlDrawPoint(x, y); if (regionStart < 0) regionStart = x; @@ -345,7 +323,7 @@ void _jlDrawFillAddLine(jint16 startX, jint16 endX, jint16 y, jint16 ignoreStart regionStart = -1; } } else { - // Unrolled conents to reduce comparison complexity. + // Unrolled contents to reduce comparison complexity. if ((isNextInDir || x < ignoreStart || x >= ignoreEnd) && (jlDrawGetPixel(x, y) != _jlDrawFillColor)) { jlDrawPoint(x, y); if (regionStart < 0) regionStart = x; diff --git a/joeylib/src/joey.h b/joeylib/src/joey.h index 3c3933f..8ab7f00 100644 --- a/joeylib/src/joey.h +++ b/joeylib/src/joey.h @@ -210,8 +210,8 @@ void jlDisplayBorder(jlBorderColorsE color); void jlDisplayPresent(void); void jlDrawBlit8x8(jlStaT *sta, jint16 cx1, jint16 cy1, jint16 cx2, jint16 cy2); -void jlDrawBlit8x8a(jlStaT *sta, jint16 cx1, jint16 cy1, jint16 cx2, jint16 cy2, byte alpha); -void jlDrawBlitMap(byte startX, byte startY, byte width, byte height, byte *mapData, juint16 stride, jlStaT *tiles); +void jlDrawBlit8x8a(jlStaT *sta, jint16 cx1, jint16 cy1, jint16 cx2, jint16 cy2, byte offset); +void jlDrawBlitMap(jint16 startX, jint16 startY, jint16 width, jint16 height, byte *mapData, juint16 stride, jlStaT *sta); void jlDrawBox(jint16 x1, jint16 y1, jint16 x2, jint16 y2); void jlDrawBoxFilled(jint16 x1, jint16 y1, jint16 x2, jint16 y2); void jlDrawCircle(jint16 x, jint16 y, jint16 radius); @@ -283,18 +283,20 @@ bool _jlVecLoad(jlVecT **vec, char *filename); // Inlined functions - asm code extern void asmB88(byte *p, jint16 cx1, jint16 cy1, jint16 cx2, jint16 cy2); extern void asmB88a(byte *p, jint16 cx1, jint16 cy1, jint16 cx2, jint16 cy2, byte alpha); -extern void asmPoint(jint16 color, jint16 x, jint16 y); +extern void asmDrawBM(jint16 startX, jint16 startY, jint16 width, jint16 height, byte *mapData, juint16 stride, byte *sta); extern jint16 asmGetPoint(jint16 x, jint16 y); extern juint16 asmGetVbl(void); extern void asmNSwap(byte *mem, jint16 count, jint16 old, jint16 new); +extern void asmPoint(jint16 color, jint16 x, jint16 y); // Inlined functions -#define jlDrawBlit8x8(sta, cx1, cy1, cx2, cy2) asmB88((byte *)sta->pixels, cx1, cy1, cx2, cy2) -#define jlDrawBlit8x8a(sta, cx1, cy1, cx2, cy2, alpha) asmB88a((byte *)sta->pixels, cx1, cy1, cx2, cy2, alpha) -#define jlDrawGetPixel(x, y) asmGetPoint(x, y) -#define jlDrawPoint(x, y) asmPoint(_jlDrawColorNibbles, x, y) -#define jlUtilNibbleSwap(mem, count, old, new) asmNSwap(mem, count, (jint16)old, (jint16)new) -#define jlUtilTimer asmGetVbl +#define jlDrawBlit8x8(sta, cx1, cy1, cx2, cy2) asmB88((byte *)sta->pixels, cx1, cy1, cx2, cy2) +#define jlDrawBlit8x8a(sta, cx1, cy1, cx2, cy2, offset) asmB88a((byte *)sta->pixels, cx1, cy1, cx2, cy2, offset) +#define jlDrawBlitMap(startX, startY, width, height, mapData, stride, sta) asmDrawBM(startX, startY, width, height, (byte *)mapData, stride, (byte *)sta->pixels) +#define jlDrawGetPixel(x, y) asmGetPoint(x, y) +#define jlDrawPoint(x, y) asmPoint(_jlDrawColorNibbles, x, y) +#define jlUtilNibbleSwap(mem, count, old, new) asmNSwap(mem, count, (jint16)old, (jint16)new) +#define jlUtilTimer asmGetVbl #ifdef JOEY_DEBUG void _jlDebugBorder(jlBorderColorsE color); diff --git a/scripts/build-IIgs.helper.sh b/scripts/build-IIgs.helper.sh index 2539f27..4b1fdb1 100644 --- a/scripts/build-IIgs.helper.sh +++ b/scripts/build-IIgs.helper.sh @@ -1,9 +1,9 @@ # --- HERE BE DRAGONS --- function buildIIgs() { - TARGET=${JOEY}/sdks/iix/IIgs/out/${PROJECT} + TARGET=${JOEY}/sdks/IIgs/ORCA/out/${PROJECT} GSTARGET=31:/out/${PROJECT} - CADIUS=${JOEY}/sdks/iix/cadius-git/bin/release/cadius + CADIUS=${JOEY}/sdks/IIgs/cadius-git/bin/release/cadius VOL=Import WORK=/tmp/IIgs IMPORT=${WORK}/import.po @@ -80,7 +80,7 @@ function buildIIgs() { # Did they ask for GSPlus to be executed? if [ ! -z $1 ]; then # Launch GSPlus - pushd ${JOEY}/sdks/iix/gsplus + pushd ${JOEY}/sdks/IIgs/gsplus ./gsplus -resizeable -config IIgsTest.cfg || true popd