IIgs nibble swap working.
This commit is contained in:
parent
b3931a6446
commit
bdd7fe6971
8 changed files with 92 additions and 16 deletions
|
@ -6,6 +6,7 @@ SRC="${JOEY}/joeylib/joeylib/src"
|
|||
|
||||
|
||||
function doBuild() {
|
||||
echo "*** Starting ${DIST}"
|
||||
if [ -d "${BUILD}" ]; then
|
||||
rm -rf "${BUILD}"
|
||||
fi
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
;----------------------------------------
|
||||
; JoeyLib
|
||||
; Copyright (C) 2018 Scott Duensing <scott@kangaroopunch.com>
|
||||
; Copyright (C) 2018-2019 Scott Duensing <scott@kangaroopunch.com>
|
||||
;
|
||||
; This software is provided 'as-is', without any express or implied
|
||||
; warranty. In no event will the authors be held liable for any damages
|
||||
|
@ -370,6 +370,61 @@ gotpdl0 xba ; 3c
|
|||
jreturn 2:pret0
|
||||
end
|
||||
|
||||
;----------------------------------------
|
||||
; Swaps nibble values
|
||||
;
|
||||
; Psychotically commented to help learn ASM :-)
|
||||
;----------------------------------------
|
||||
asmNSwap start
|
||||
|
||||
hnibo equ 1 ; High nibble old color value
|
||||
hnibn equ 2 ; High nibble new color value
|
||||
|
||||
jsubroutine (4:P,2:C,2:O,2:N),2
|
||||
|
||||
short m ; Use 8 bit accumulator
|
||||
lda N ; Load new color to use
|
||||
asl a ; Shift it up a nibble
|
||||
asl a
|
||||
asl a
|
||||
asl a
|
||||
sta hnibn ; Store it for later
|
||||
lda O ; Load old color to use (16 bit argument)
|
||||
asl a ; Shift it up a nibble
|
||||
asl a
|
||||
asl a
|
||||
asl a
|
||||
sta hnibo ; Store it for later
|
||||
|
||||
ldy #0 ; Load Y (our counter) with 0
|
||||
|
||||
NSLow lda [P],y ; Get byte to check
|
||||
and #$0F ; Isolate low nibble
|
||||
cmp O ; Compare to old value
|
||||
bne NSHigh ; Not equal, skip to high nibble
|
||||
lda [P],y ; Get byte to modify
|
||||
and #$F0 ; Clear low nibble
|
||||
ora N ; Set low nibble to new color
|
||||
sta [P],y ; Store it back
|
||||
|
||||
NSHigh lda [P],y ; Get byte to check
|
||||
and #$F0 ; Isolate high nibble
|
||||
cmp hnibo ; Compare to old color
|
||||
bne NSEnd ; Not equal, skip to next byte
|
||||
lda [P],y ; Get byte to modify
|
||||
and #$0F ; Clear high nibble
|
||||
ora hnibn ; Set high nibble to new color
|
||||
sta [P],y ; Store it back
|
||||
|
||||
NSEnd iny ; Increment Y
|
||||
clc ; Clear carry
|
||||
cpy C ; Compare Y to number of bytes to modify
|
||||
bcc NSLow ; Keep going
|
||||
|
||||
long m ; Back to 16 bit accumulator
|
||||
jreturn
|
||||
end
|
||||
|
||||
;----------------------------------------
|
||||
; Plots a point in a given color
|
||||
;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* JoeyLib
|
||||
* Copyright (C) 2018 Scott Duensing <scott@kangaroopunch.com>
|
||||
* Copyright (C) 2018-2019 Scott Duensing <scott@kangaroopunch.com>
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
;----------------------------------------
|
||||
; JoeyLib
|
||||
; Copyright (C) 2018 Scott Duensing <scott@kangaroopunch.com>
|
||||
; Copyright (C) 2018-2019 Scott Duensing <scott@kangaroopunch.com>
|
||||
;
|
||||
; This software is provided 'as-is', without any express or implied
|
||||
; warranty. In no event will the authors be held liable for any damages
|
||||
|
@ -26,7 +26,6 @@
|
|||
MACRO
|
||||
&lab jsubroutine &parms,&work
|
||||
&lab anop
|
||||
using savedDBR ; ADDED
|
||||
aif c:&work,.a
|
||||
lclc &work
|
||||
&work setc 0
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* JoeyLib
|
||||
* Copyright (C) 2018 Scott Duensing <scott@kangaroopunch.com>
|
||||
* Copyright (C) 2018-2019 Scott Duensing <scott@kangaroopunch.com>
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
|
@ -460,6 +460,17 @@ bool jlUtilMustExit(void) {
|
|||
}
|
||||
|
||||
|
||||
void jlUtilNibbleSwap(byte *mem, jint16 count, byte old, byte new) {
|
||||
int x;
|
||||
jlPixelPairT *b;
|
||||
for (x=0; x<count; x++) {
|
||||
b = (jlPixelPairT *)&mem[x];
|
||||
if (b->l == old) b->l = new;
|
||||
if (b->r == old) b->r = new;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void jlUtilShutdown(void) {
|
||||
int x;
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* JoeyLib
|
||||
* Copyright (C) 2018 Scott Duensing <scott@kangaroopunch.com>
|
||||
* Copyright (C) 2018-2019 Scott Duensing <scott@kangaroopunch.com>
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* JoeyLib
|
||||
* Copyright (C) 2018 Scott Duensing <scott@kangaroopunch.com>
|
||||
* Copyright (C) 2018-2019 Scott Duensing <scott@kangaroopunch.com>
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
|
@ -255,6 +255,7 @@ void jlUtilIdle(void);
|
|||
#define jlUtilIsOdd(x) (((x & 1) == 1) ? true : false)
|
||||
char *jlUtilMakePathname(char *filename, char *extension);
|
||||
bool jlUtilMustExit(void);
|
||||
void jlUtilNibbleSwap(byte *mem, jint16 count, byte old, byte new);
|
||||
void jlUtilShutdown(void) __attribute__((noreturn));
|
||||
#define jlUtilStackPop(stack) _jlUtilStackPop((jlStackT **)&(stack)) // Syntatic Sugar
|
||||
void *_jlUtilStackPop(jlStackT **stack);
|
||||
|
@ -276,12 +277,14 @@ extern void asmB88(byte *p, jint16 cx1, jint16 cy1, jint16 cx2, jint16 cy2);
|
|||
extern void asmPoint(jint16 color, jint16 x, jint16 y);
|
||||
extern jint16 asmGetPoint(jint16 x, jint16 y);
|
||||
extern juint16 asmGetVbl(void);
|
||||
extern void asmNSwap(byte *mem, jint16 count, jint16 old, jint16 new);
|
||||
|
||||
// Inlined functions
|
||||
#define jlDrawBlit8x8(sta, cx1, cy1, cx2, cy2) asmB88((byte *)sta->pixels, cx1, cy1, cx2, cy2);
|
||||
#define jlDrawGetPixel(x, y) asmGetPoint(x, y)
|
||||
#define jlDrawPoint(x, y) asmPoint(_jlDrawColorNibbles, x, y)
|
||||
#define jlUtilTimer asmGetVbl
|
||||
#define jlDrawBlit8x8(sta, cx1, cy1, cx2, cy2) asmB88((byte *)sta->pixels, cx1, cy1, cx2, cy2)
|
||||
#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);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* JoeyLib
|
||||
* Copyright (C) 2018 Scott Duensing <scott@kangaroopunch.com>
|
||||
* Copyright (C) 2018-2019 Scott Duensing <scott@kangaroopunch.com>
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
|
@ -59,29 +59,36 @@ int main(void) {
|
|||
jlStaT *kanga = NULL;
|
||||
jlStaT *font = NULL;
|
||||
jint16 y;
|
||||
jint16 color = 15;
|
||||
jint16 nextColor = 1;
|
||||
|
||||
jlUtilStartup("JoeyLib Test");
|
||||
|
||||
jlStaLoad(kanga, "kanga");
|
||||
jlStaLoad(font, "font");
|
||||
if (!jlStaLoad(kanga, "kanga")) jlUtilDie("Unable to load kanga.sta!");
|
||||
if (!jlStaLoad(font, "font")) jlUtilDie("Unable to load font.sta!");
|
||||
|
||||
jlStaDisplay(kanga);
|
||||
jlDrawColor(1);
|
||||
jlDrawBox(0, 0, 319, 199);
|
||||
|
||||
jlSoundMusicPlay("music");
|
||||
//jlSoundMusicPlay("music");
|
||||
|
||||
jlPaletteSet(15, 15, 15, 15);
|
||||
printAt(font, 1, 16, "X");
|
||||
while (!jlKeyPressed()) {
|
||||
y = 17;
|
||||
printAt(font, 1, y++, "X = %d ", jlGameGetAxis(0));
|
||||
printAt(font, 1, y++, "Y = %d ", jlGameGetAxis(1));
|
||||
printAt(font, 1, y++, "T = %d ", jlUtilTimer());
|
||||
jlDisplayPresent();
|
||||
jlUtilNibbleSwap((byte *)font->pixels, 32000, (byte)(color), (byte)(nextColor));
|
||||
color = nextColor;
|
||||
nextColor++;
|
||||
if (nextColor > 15) nextColor = 1;
|
||||
}
|
||||
jlKeyRead();
|
||||
|
||||
jlSoundMusicStop();
|
||||
//jlSoundMusicStop();
|
||||
|
||||
jlStaFree(font);
|
||||
jlStaFree(kanga);
|
||||
|
|
Loading…
Add table
Reference in a new issue