diff --git a/basic/appleiibot/convert_tgreene.c b/basic/appleiibot/convert_tgreene.c index bec02c0d..0ef5c54f 100644 --- a/basic/appleiibot/convert_tgreene.c +++ b/basic/appleiibot/convert_tgreene.c @@ -1,16 +1,34 @@ -/* code by qkumba */ +/* Based on code by qkumba */ +/* TGreene improved the algorithm to be a bit smaller */ #include #include +#include +/* ASCII offset */ #define OFFSET 35 #define OFFSET2 35 -//#define OFFSET 35 +/* We are jumping into the decoded code using the & operator */ +/* This just does a jmp to $3F5 */ +/* Easiest is to just load our code there */ +/* The problem is this loads most of the code to the 1st text/lo-res page */ +/* For text/lo-res programs instead load code so it ends at $3F8, */ +/* usually you have a 3-byte jmp to the start of your code at $3F5 */ #define END_AT_3F5 0 #define BEGIN_AT_3F5 1 +static int print_help(char *name) { + + printf("\n"); + printf("Usage: %s [-e] [-h]\n",name); + printf("\t-e : ends program at 3F5 (useful for lo-res programs)\n"); + printf("\t default is to start program at 3F5\n"); + printf("\n"); + + return 0; +} int main(int argc, char **argv) { @@ -28,6 +46,10 @@ int main(int argc, char **argv) { if (argv[1][1]=='e') { mode=END_AT_3F5; } + if (argv[1][1]=='h') { + print_help(argv[0]); + exit(1); + } } } diff --git a/graphics/gr/sprite/Makefile b/graphics/gr/sprite/Makefile index 26e0c764..3645be42 100644 --- a/graphics/gr/sprite/Makefile +++ b/graphics/gr/sprite/Makefile @@ -12,11 +12,12 @@ all: star.dsk $(DOS33): cd ../../../utils/dos33fs-utils && make -star.dsk: $(DOS33) HELLO STAR STARS +star.dsk: $(DOS33) HELLO STAR STARS STARS_BOT cp $(EMPTY_DISK)/empty.dsk star.dsk $(DOS33) -y star.dsk SAVE A HELLO $(DOS33) -y star.dsk BSAVE -a 0xc00 STAR $(DOS33) -y star.dsk BSAVE -a 0xc00 STARS + $(DOS33) -y star.dsk BSAVE -a 0xc00 STARS_BOT ### @@ -42,14 +43,14 @@ stars.o: stars.s ### -STAR_BOT: star_bot.o - ld65 -o STAR_BOT star_bot.o -C $(LINKERSCRIPTS)/apple2_36b.inc +STARS_BOT: stars_bot.o + ld65 -o STARS_BOT stars_bot.o -C $(LINKERSCRIPTS)/apple2_c00.inc -star_bot.o: star_bot.s - ca65 -o star_bot.o star_bot.s -l star_bot.lst +stars_bot.o: stars_bot.s + ca65 -o stars_bot.o stars_bot.s -l stars_bot.lst ### clean: - rm -f *~ *.o *.lst HELLO STAR STAR_BOT + rm -f *~ *.o *.lst HELLO STAR STARS STARS_BOT diff --git a/graphics/gr/sprite/stars.s b/graphics/gr/sprite/stars.s index e534330c..c184a438 100644 --- a/graphics/gr/sprite/stars.s +++ b/graphics/gr/sprite/stars.s @@ -8,6 +8,7 @@ ; 140 bytes -- 0 is already in X ; 143 bytes -- stars move independently ; 140 bytes -- optimize XPOS in multiple calls to draw_stars +; 145 bytes -- color changing background SPEAKER = $C030 SET_GR = $C050 @@ -33,7 +34,7 @@ XPOS = $77 FRAME = $6D PAGE = $6E -LINE = $6F + ;.zeropage ;.globalzp pattern_smc @@ -62,7 +63,11 @@ main_loop: jsr WAIT inc FRAME ; increment frame # + bne no_cs + inc bg_smc+1 + +no_cs: ;================================= ; clear lo-res screen, page1/page2 ;================================= @@ -71,6 +76,7 @@ main_loop: ldx #4 ; lores is 1k, so 4 pages full_loop: ldy #$00 ; clear whole page +bg_smc: lda #$55 ; color inner_loop: sta (OUTL),Y diff --git a/graphics/gr/sprite/stars_bot.s b/graphics/gr/sprite/stars_bot.s index 834e7a31..68865657 100644 --- a/graphics/gr/sprite/stars_bot.s +++ b/graphics/gr/sprite/stars_bot.s @@ -13,6 +13,8 @@ ; 143 bytes -- speed up the color transition ; 144 bytes -- tried to share adjust_page in subroutine, backfired ; 143 bytes -- revert last change +; 142 bytes -- draw stars right to left +; 141 bytes -- assume GBASCALC always leaves C set to 0 SPEAKER = $C030 SET_GR = $C050 @@ -24,7 +26,7 @@ LORES = $C056 ; Enable LORES graphics HGR2 = $F3D8 PLOT = $F800 ; PLOT AT Y,A (A colors output, Y preserved) -GBASCALC = $F847 ; Y in A, put addr in GBASL/GBASH +GBASCALC = $F847 ; Y in A, put addr in GBASL/GBASH (what is C?) SETGR = $FB40 WAIT = $FCA8 ; delay 1/2(26+27A+5A^2) us @@ -33,6 +35,7 @@ GBASH = $27 YPOS = $76 XPOS = $77 +PO = $78 FRAME = $6D PAGE = $6E @@ -55,7 +58,7 @@ main_loop: asl ; make OUTH $4 or $8 depending on value in PAGE ; which we have in A above or at end of loop - asl ; C is 0 + asl ; (this also sets C to 0) adc #4 sta GBASH @@ -63,11 +66,11 @@ main_loop: inc FRAME ; increment frame # lda FRAME and #$1f ; cycle colors ever 32 frames - bne no_cs + bne no_color_cycle inc bg_smc+1 -no_cs: +no_color_cycle: lda #100 ; pause a bit jsr WAIT @@ -79,10 +82,10 @@ no_cs: ; clear lo-res screen, page1/page2 ;================================= ; proper with avoiding screen holes is ~25 instructions + ; this is more like 16 + ; assume GBASL/GBASH already points to proper $400 or $800 ldx #4 ; lores is 1k, so 4 pages -; stx GBASH -; jsr adjust_page full_loop: ldy #$00 ; clear whole page bg_smc: @@ -96,12 +99,15 @@ inner_loop: dex bne full_loop + ; X=0 + ; Y=0 + ; A=color ;==================== ; draw the stars ;==================== - txa ; X is zero here + lda #32 ; start from right to save a byte ;====================== ; draw 8x8 bitmap star @@ -112,7 +118,6 @@ draw_star: ; calculate YPOS sta XPOS -; lda XPOS lsr ; make middle star offset+4 from others lsr @@ -130,17 +135,15 @@ boxloop: adc YPOS jsr GBASCALC ; calc address of line in X (Y-coord) - ; GBASL is in A at this point + ; is C always 0? - clc +; clc adc XPOS ; adjust to X-coord sta GBASL ; adjust for proper page -; jsr adjust_page - lda PAGE ; want to add 0 or 4 (not 0 or 1) asl asl ; this sets C to 0 @@ -172,23 +175,22 @@ its_transparent: dex bpl boxloop - lda XPOS - clc - adc #16 - - cmp #48 - bne draw_star + lda XPOS ; move to next position + ; going right to left saves 2 bytes for cmp + sec + sbc #16 + bpl draw_star ; X is $FF here ; Y is $FF here - ; A is 48 here + ; A is -16 here ;====================== ; flip page ;====================== - lda PAGE + lda PAGE ; 0 or 1 tax ldy PAGE1,X ; flip page @@ -198,19 +200,10 @@ its_transparent: bpl main_loop ; bra - ; GBASL in A -;adjust_page: -; sta GBASL -; lda PAGE ; want to add 0 or 4 (not 0 or 1) -; asl -; asl ; this sets C to 0 -; adc GBASH -; sta GBASH -; rts - - +;================= ; star bitmap +;================= ;012|456| ; @ ;