Commit 18c53676 authored by Scott Duensing's avatar Scott Duensing

First working installable version?

parent 69b4aa53
......@@ -22,17 +22,16 @@ 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/IIgs/ntconverter.php *.mod
php ${JOEY}/sdks/IIgs/ntconverter/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/scripts/build-IIgs.helper.sh ${JOEY}/dist/IIgs/.
if [ ! -z $1 ]; then
CADIUS=${JOEY}/sdks/IIgs/cadius-git/bin/release/cadius
CADIUS=${JOEY}/sdks/IIgs/cadius/cadius
IMPORT=/tmp/IIgs/import.po
VOL=Import
......@@ -55,7 +54,7 @@ if [ ! -z $1 ]; then
${CADIUS} addfile ${IMPORT} ${VOL}/data ${OUT}/music.w#060000 > /dev/null
pushd ${JOEY}/sdks/IIgs/gsplus
./gsplus -resizeable -config IIgsTest.cfg || true
./GSplus -resizeable -config IIgsTest.cfg || true
popd
echo ""
${CADIUS} extractfile ${IMPORT} ${VOL}/JLSTATS /tmp/IIgs/. > /dev/null
......
......@@ -26,7 +26,7 @@ function doBuild() {
ar x ${INSTALLED}/libSDL2.a
ar x ${INSTALLED}/libSDL2_mixer.a
ar x ${INSTALLED}/libmodplug.a
ar rcs ${DIST}/libjoeylib.a *.o
popd
......@@ -56,8 +56,8 @@ if [ "${ARCH}x" == "allx" ] || [ "${ARCH}x" == "linux32x" ]; then
CC="gcc"
CFLAGS="-m32"
LDFLAGS=""
DIST="${JOEY}/dist/linux/x86"
INSTALLED="${JOEY}/SDL2/installed/linux/x86/lib"
DIST="${JOEY}/dist/linux/i386"
INSTALLED="${JOEY}/SDL2/installed/linux/i386/lib"
doBuild
fi
......@@ -74,8 +74,8 @@ if [ "${ARCH}x" == "allx" ] || [ "${ARCH}x" == "windows32x" ]; then
CC="i686-w64-mingw32-gcc"
CFLAGS=""
LDFLAGS=""
DIST="${JOEY}/dist/windows/x86"
INSTALLED="${JOEY}/SDL2/installed/windows/x86/lib"
DIST="${JOEY}/dist/windows/i386"
INSTALLED="${JOEY}/SDL2/installed/windows/i386/lib"
doBuild
fi
......@@ -83,8 +83,8 @@ if [ "${ARCH}x" == "allx" ] || [ "${ARCH}x" == "macos32x" ]; then
CC="o32-clang"
CFLAGS=""
LDFLAGS=""
DIST="${JOEY}/dist/macos/x86"
INSTALLED="${JOEY}/SDL2/installed/macos/x86/lib"
DIST="${JOEY}/dist/macos/i386"
INSTALLED="${JOEY}/SDL2/installed/macos/i386/lib"
doBuild
fi
......
......@@ -422,6 +422,528 @@ drawTop phy ; Keep Y for later
jreturn
end
;===============================================================================================
;
; Arc3D line-drawing code
; By Andy McFadden
; Adapted from code by the FTA.
;
; Draws from (clpx0,clpy0) to (clpx1,clpy1) (output of a clipping routine).
;
asmDrawLine start
x0 equ 1
y0 equ 3
x1 equ 5
y1 equ 7
offset equ 9
deltax equ 11
deltay equ 13
diff equ 15
even_c equ 17
odd_c equ 19
jsubroutine (4:p,2:penColor,2:clpx0,2:clpy0,2:clpx1,2:clpy1),20
; Say p = $012000...
lda #<p ; Should be $2000
sta __e0 ; set "even" addresses
sta __e1
sta __e2
sta __e3
sta __e4
sta __e5
sta __e6
sta __e7
sta __e8
sta __e9
sta __e10
sta __e11
sta __e12
sta __e13
dea ; Should be $1fff
sta __o0 ; set "odd" addresses
sta __o1
sta __o2
sta __o3
sta __o4
sta __o5
sta __o6
sta __o7
sta __o8
sta __o9
sta __o10
sta __o11
sta __o12
sta __o13
phb ; keep original bank
lda #>p ; Should be $0120
pha ; switch to bank we're pointing into
plb ; B is now $20 - bad!
plb ; B is now $01 - good!
DoDrawLine anop
lda <clpy1 ; 4 is y1 < y0?
cmp <clpy0 ; 4
blt in_order ; 2/3 yes, so leave alone
; lda <clpy1 ; we want y0 to be the largest,
sta y0 ; so switch
lda <clpx1
sta x0
lda <clpy0
sta y1
lda <clpx0
sta x1
bra copy_done
in_order anop
; lda <clpy1
sta y1
lda <clpx1
sta x1
lda <clpy0
sta y0
lda <clpx0
sta x0
; 39/41 cycles to here
; setup offset and deltas
copy_done anop
lda y1
asl A
asl A
adc y1
asl A
asl A
asl A
asl A
asl A
asl A
adc x1
sta offset ; 16+16=32
; penColor must be between 0 and 15
lda <penColor ; setup pixel images
sta even_c ; 0x000f
xba
asl A
asl A
asl A
asl A
and #$f000
sta odd_c ; 0xf000
lda y0
sec
sbc y1
sta deltay ; we know y0 is larger...
beq Horizontal ; +2 do as special case
lda x1
cmp x0
beq Vertical ; +2 do as special case
; bcc Rev ; x1 is smaller; go other way
bcs Forw
brl Rev
Forw sbc x0
sta deltax
cmp deltay
bcc Forw_bigy_j
brl Forw_bigx
Forw_bigy_j anop
brl Forw_bigy
;
; Handle special cases (horizontal/vertical/point)
;
; handle vertical (deltax=0) lines
Vertical lda deltay
tay ; count down
lda offset
lsr A
tax
bcc vf_odd2
clc
; bra vf_even2
; loop below
vf_even2 lda $dead,x
__e0 equ *-2
and #$fff0
ora even_c
sta $dead,x
__e1 equ *-2
txa
adc #160
tax
dey
bpl vf_even2
bra vf_done
vf_odd2 lda $beef,x
__o0 equ *-2
and #$0fff
ora odd_c
sta $beef,x
__o1 equ *-2
txa
adc #160
tax
dey
bpl vf_odd2
; bra vf_done
vf_done brl Exit
; handle horizontal (deltay=0) lines
Horizontal anop
lda x1
cmp x0
bcc h_rev ; x1 is smaller; go other way
sbc x0
sta deltax
; horizontal, moving forward
h_forw lda deltax
tay ; count down
lda offset
lsr A
tax
bcc hf_odd2
clc
; bra hf_even2
; loop below
hf_even2 lda $dead,x
__e2 equ *-2
and #$fff0
ora even_c
sta $dead,x
__e3 equ *-2
dey
bmi hf_done
hf_odd2 lda $beef,x
__o2 equ *-2
and #$0fff
ora odd_c
sta $beef,x
__o3 equ *-2
dex
dey
bpl hf_even2
hf_done brl Exit
; horizontal, reverse direction
h_rev sec
lda x0
sbc x1
sta deltax
lda deltax
tay ; count down
lda offset
lsr A
tax
bcc hr_odd2
clc
; bra hr_even2
; loop below
hr_even2 lda $dead,x
__e4 equ *-2
and #$fff0
ora even_c
sta $dead,x
__e5 equ *-2
dey
bmi hr_done
inx
hr_odd2 lda $beef,x
__o4 equ *-2
and #$0fff
ora odd_c
sta $beef,x
__o5 equ *-2
dey
bpl hr_even2
; bra hr_done
hr_done brl Exit
;
; Standard cases
;
; forward direction, deltay is bigger than deltax
Forw_bigy anop
lda deltay
tay ; count down
lsr A
eor #$ffff
inc A
sta diff
lda offset
lsr A
tax
bcc fy_odd2
clc
bra fy_even2
; loop below
fy_even1 sta diff
fy_even2 lda $dead,x
__e6 equ *-2
and #$fff0
ora even_c
sta $dead,x
__e7 equ *-2
dey
bmi fy_done
txa
adc #160
tax
lda deltax
adc diff
bmi fy_even1
sbc deltay
fy_odd1 sta diff
fy_odd2 lda $beef,x
__o6 equ *-2
and #$0fff
ora odd_c
sta $beef,x
__o7 equ *-2
dey
bmi fy_done
txa
adc #160
tax
lda deltax
adc diff
bmi fy_odd1
sbc deltay
dex
bra fy_even1
fy_done brl Exit
; reverse direction
Rev sec
lda x0
sbc x1
sta deltax
cmp deltay
bcs Rev_bigx
; reverse direction, deltay is bigger than deltax
Rev_bigy lda deltay
tay ; count down
inc A
lsr A
eor #$ffff
inc A
sta diff
lda offset
lsr A
tax
bcc ry_odd2
clc
bra ry_even2
; loop below
ry_even1 sta diff
ry_even2 lda $dead,x
__e8 equ *-2
and #$fff0
ora even_c
sta $dead,x
__e9 equ *-2
dey
bmi ry_done
txa
adc #160
tax
lda deltax
adc diff
bmi ry_even1
sbc deltay
inx
ry_odd1 sta diff
ry_odd2 lda $beef,x
__o8 equ *-2
and #$0fff
ora odd_c
sta $beef,x
__o9 equ *-2
dey
bmi ry_done
txa
adc #160
tax
lda deltax
adc diff
bmi ry_odd1
sbc deltay
bra ry_even1
ry_done brl Exit
; reverse direction, deltax is bigger than deltay
Rev_bigx lda deltax
tay ; count down
lsr A
eor #$ffff
inc A
sta diff
lda offset
lsr A
tax
bcc rx_odd2
clc
bra rx_even2
; loop below
rx_even1 sta diff
rx_even2 lda $dead,x
__e10 equ *-2
and #$fff0
ora even_c
sta $dead,x
__e11 equ *-2
dey
bmi rx_done
inx
lda deltay
adc diff
bmi rx_odd1
sbc deltax
sta diff
txa
adc #160
tax
bra rx_odd2
rx_odd1 sta diff
rx_odd2 lda $beef,x
__o10 equ *-2
and #$0fff
ora odd_c
; sta $beef,x
__o11 equ *-2
dey
bmi rx_done
lda deltay
adc diff
bmi rx_even1
sbc deltax
sta diff
txa
adc #160
tax
bra rx_even2
rx_done brl Exit
; forward direction, deltax is bigger than deltay
Forw_bigx anop
lda deltax
tay ; count down
lsr A
eor #$ffff
inc A
sta diff
lda offset
lsr A
tax
bcc fx_odd2
clc
bra fx_even2
; loop below
fx_even1 sta diff
fx_even2 lda $dead,x
__e12 equ *-2
and #$fff0
ora even_c
sta $dead,x
__e13 equ *-2
dey
bmi fx_done
lda deltay
adc diff
bmi fx_odd1
sbc deltax
sta diff
txa
adc #160
tax
bra fx_odd2
fx_odd1 sta diff
fx_odd2 lda $beef,x
__o12 equ *-2
and #$0fff
ora odd_c
sta $beef,x
__o13 equ *-2
dey
bmi fx_done
dex
lda deltay
adc diff
bmi fx_even1
sbc deltax
sta diff
txa
adc #160
tax
bra fx_even2
fx_done brl Exit
;
; common exit point
;
Exit plb ; return to original bank
jreturn
end
;----------------------------------------
; Returns the color of a given point
;
......@@ -955,4 +1477,3 @@ VblCount dc i2'1' ; How many VBLs between calls (1 only on initial call)
short m,i
rtl
end
......@@ -249,9 +249,7 @@ void jlDrawCircle(jint16 x0, jint16 y0, jint16 radius) {
y++;
err += dy;
dy += 2;
}
if (err > 0) {
} else {
x--;
dx += 2;
err += dx - (radius << 1);
......
......@@ -284,6 +284,7 @@ bool _jlVecLoad(jlVecT **vec, char *filename);
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 asmDrawBM(jint16 startX, jint16 startY, jint16 width, jint16 height, byte *mapData, juint16 stride, byte *sta);
//extern void asmDrawLine(byte *p, jint16 color, jint16 x1, jint16 y1, jint16 x2, jint16 y2);
extern jint16 asmGetPoint(jint16 x, jint16 y);
extern juint16 asmGetVbl(void);
extern void asmNSwap(byte *mem, jint16 count, jint16 old, jint16 new);
......@@ -295,6 +296,7 @@ extern void asmPoint(jint16 color, jint16 x, jint16 y);
#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 jlDrawLine(x1, y1, x2, y2) asmDrawLine((byte *)0x012000L, _jlDrawColor, x1, y1, x2, y2)
#define jlUtilNibbleSwap(mem, count, old, new) asmNSwap(mem, count, (jint16)old, (jint16)new)
#define jlUtilTimer asmGetVbl
......
......@@ -60,6 +60,8 @@ int main(void) {
jlStaT *kanga = NULL;
jlStaT *font = NULL;
jint16 y;
jint16 y2 = 0;
jint16 dy = 1;
jint16 color = 15;
jint16 nextColor = 1;
......@@ -70,9 +72,9 @@ int main(void) {
jlStaDisplay(kanga);
jlDrawColor(1);
jlDrawBox(0, 0, 319, 199);
//jlDrawBox(0, 0, 319, 199);
jlSoundMusicPlay("music");
//jlSoundMusicPlay("music");
jlPaletteSet(15, 15, 15, 15);
printAt(font, 1, 16, "X");
......@@ -81,8 +83,14 @@ int main(void) {
printAt(font, 1, y++, "X = %d ", jlGameGetAxis(0));
printAt(font, 1, y++, "Y = %d ", jlGameGetAxis(1));
printAt(font, 1, y++, "T = %d ", jlUtilTimer());
jlDrawColor((byte)color);
_jlDebugBorder(BORDER_GREEN);
jlDrawLine(0, y2, 319, 199-y2);
_jlDebugBorder(BORDER_BROWN);
y2 += dy;
if (y2 == 199 || y2 == 0) dy = -dy;
jlDisplayPresent();
jlUtilNibbleSwap((byte *)font->pixels, 32000, (byte)(color), (byte)(nextColor));
//jlUtilNibbleSwap((byte *)font->pixels, 32000, (byte)(color), (byte)(nextColor));
color = nextColor;
nextColor++;
if (nextColor > 15) nextColor = 1;
......
......@@ -3,7 +3,7 @@
function buildIIgs() {
TARGET=${JOEY}/sdks/IIgs/ORCA/out/${PROJECT}
GSTARGET=31:/out/${PROJECT}
CADIUS=${JOEY}/sdks/IIgs/cadius-git/bin/release/cadius
CADIUS=${JOEY}/sdks/IIgs/cadius/cadius
VOL=Import
WORK=/tmp/IIgs
IMPORT=${WORK}/import.po
......@@ -53,11 +53,12 @@ function buildIIgs() {
# Be sure our work directories exists
mkdir -p ${WORK}/{data,source}
# Create disk image, setting known file types
${CADIUS} createvolume ${IMPORT} ${VOL} 32MB > /dev/null
${CADIUS} createfolder ${IMPORT} ${VOL}/data > /dev/null
${CADIUS} addfile ${IMPORT} ${VOL} ${TARGET}/${PROJECT}#b30000 > /dev/null
${CADIUS} addfile ${IMPORT} ${VOL} ${TARGET}/${PROJECT}#b30000 > /dev/null
${CADIUS} addfile ${IMPORT} ${VOL} ${JOEY}/dist/IIgs/Tool221#ba0000 > /dev/null
for F in "${DATA[@]}"; do
N=${WORK}/data/`basename ${F}`#060000
cp -f ${F} ${N}
......@@ -81,9 +82,9 @@ function buildIIgs() {
if [ ! -z $1 ]; then
# Launch GSPlus
pushd ${JOEY}/sdks/IIgs/gsplus
./gsplus -resizeable -config IIgsTest.cfg || true
./GSplus -resizeable -config IIgsTest.cfg || true
popd
# Extract and display the results of the run
${CADIUS} extractfile ${IMPORT} ${VOL}/JLSTATS ${WORK}/. > /dev/null
if [ -e ${WORK}/JLSTATS#040000 ]; then
......
......@@ -16,7 +16,7 @@ function doPCBuild() {
echo '-------------------------------------------------------------------------------'
echo "Building ${OSNAME} ${OSARCH}"
echo '-------------------------------------------------------------------------------'
# Clean up target and working directories
if [ -d ${DEST} ]; then
rm -rf ${DEST}
......@@ -26,7 +26,7 @@ function doPCBuild() {
rm -rf ${WORK}
fi
mkdir -p ${WORK}
# Make a list of files to compile, iterate over them
CFILES=($(ls -1 *.c))
OFILES=""
......@@ -36,10 +36,10 @@ function doPCBuild() {
echo "Compiling ${F}..."
${CC} ${CFLAGS} ${G_CFLAGS} -c ${F} -o ${WORK}/${O}.o
done
# Link source & JoeyLib
${CC} -o ${DEST}/${PROJECT}${EXT} ${OFILES} ${JOEY}/dist/${OSNAME}/${OSARCH}/libjoeylib.a ${LDFLAGS}
${CC} -o ${DEST}/${PROJECT}${EXT} ${OFILES} ${JOEY}/dist/${OSNAME}/${OSARCH}/libjoeylib.a ${LDFLAGS}
# Copy game data
mkdir -p ${DEST}/data
for F in "${DATA[@]}"; do
......@@ -52,7 +52,7 @@ function buildLinux32() {
CC="gcc"
CFLAGS="-m32"
LDFLAGS="-m32 -lstdc++ -lm -ldl -lpthread"
doPCBuild linux x86 ''
doPCBuild linux i386 ''
}
......@@ -68,7 +68,7 @@ function buildWindows32() {
CC="i686-w64-mingw32-gcc"
CFLAGS=""
LDFLAGS="-lgdi32 -lwinmm -limm32 -lversion -lole32 -loleaut32 -lsetupapi -static -lstdc++"
doPCBuild windows x86 '.exe'
doPCBuild windows i386 '.exe'
}
......@@ -84,7 +84,7 @@ function buildmacOS32() {
CC="o32-clang"
CFLAGS=""
LDFLAGS=""
doPCBuild macos x86 ''
doPCBuild macos i386 ''
}
......