diff --git a/graphics/gr/thinking/Makefile b/graphics/gr/thinking/Makefile index 19a9d260..9e6c7bd9 100644 --- a/graphics/gr/thinking/Makefile +++ b/graphics/gr/thinking/Makefile @@ -9,11 +9,13 @@ all: thinking.dsk thinking.dsk: HELLO THINKING RAINBOW_BOX T2 THINKING_FLIP T3 THINKING_SLOW \ THINKING_ATTEMPT2 THINKING_ATTEMPT3 THINKING_ATTEMPT4 THINKING_ATTEMPT5 \ - THINKING_ATTEMPT6 CRACKING + THINKING_ATTEMPT6 CRACKING CRACKING_BOT THINKING_BOT cp $(EMPTYDISK) thinking.dsk $(DOS33) -y thinking.dsk SAVE A HELLO $(DOS33) -y thinking.dsk BSAVE -a 0x36b THINKING + $(DOS33) -y thinking.dsk BSAVE -a 0x36b THINKING_BOT $(DOS33) -y thinking.dsk BSAVE -a 0x36b CRACKING + $(DOS33) -y thinking.dsk BSAVE -a 0x36b CRACKING_BOT $(DOS33) -y thinking.dsk BSAVE -a 0xC00 THINKING_FLIP $(DOS33) -y thinking.dsk BSAVE -a 0xC00 THINKING_SLOW $(DOS33) -y thinking.dsk BSAVE -a 0xC00 THINKING_ATTEMPT2 @@ -40,12 +42,28 @@ thinking.o: thinking.s ### +THINKING_BOT: thinking_bot.o + ld65 -o THINKING_BOT thinking_bot.o -C $(LINKERSCRIPTS)/apple2_36b.inc + +thinking_bot.o: thinking_bot.s + ca65 -o thinking_bot.o thinking_bot.s -l thinking_bot.lst + +### + CRACKING: cracking.o ld65 -o CRACKING cracking.o -C $(LINKERSCRIPTS)/apple2_36b.inc cracking.o: cracking.s ca65 -o cracking.o cracking.s -l cracking.lst +### + +CRACKING_BOT: cracking_bot.o + ld65 -o CRACKING_BOT cracking_bot.o -C $(LINKERSCRIPTS)/apple2_36b.inc + +cracking_bot.o: cracking_bot.s + ca65 -o cracking_bot.o cracking_bot.s -l cracking_bot.lst + ### @@ -136,4 +154,5 @@ t3.o: t3.s clean: rm -f *~ *.o *.lst HELLO THINKING RAINBOW_BOX T2 THINKING_FLIP T3 THINKING_SLOW \ - THINKING_ATTEMPT2 THINKING_ATTEMPT3 THINKING_ATTEMPT4 THINKING_ATTEMPT5 THINKING_ATTEMPT6 CRACKING + THINKING_ATTEMPT2 THINKING_ATTEMPT3 THINKING_ATTEMPT4 THINKING_ATTEMPT5 THINKING_ATTEMPT6 CRACKING \ + THINKING_BOT diff --git a/graphics/gr/thinking/README b/graphics/gr/thinking/README new file mode 100644 index 00000000..f75779e0 --- /dev/null +++ b/graphics/gr/thinking/README @@ -0,0 +1,66 @@ +Re-implementation of the Print Shop "Thinking / Printing" animated banner. + +Was struggling to get this to fit in 141 bytes for the Apple II Basic Bot. +Managed in the end to get a version that had animated bars instead of boxes. + + +**************** +"Proper" Version +**************** + + See the thinking_flip.s / THINKING_FLIP code. + + This draws offscreen. First the boxes, cascading inward, + (using direct RAM writes to draw the boxes). + A separate loop then overwrites with the bitmap. + Page flipping is used, so it alternates PAGE1/PAGE2. + + The code is callable as a function so you can add hooks into + it from existing code as a progress indicator. + + Downsides: lots of over-writing (speed), also you need to + have the 1k of RAM at $800 free for PAGE2 use. + + Total size approaches 256 bytes + +************** +Other attempts +************** + +Various other attempts tried: + ++ Drawing the boxes using Applesoft/Monitor ROM routines for a box + (4 sides), then drawing the bitmap on top. + This is too slow and makes flicker, also the code is large. + (some preliminary attempt to this is in THINKING_ATTEMPT4) + ++ Drawing the boxes using HLINE instead of direct mem writes. + Slower, so very noticable that you're drawing things. + Still couldn't get below 153 bytes. + See thinking_slow.s / THINKING_SLOW + ++ Using box drawing code from my various box-drawing demos. + This ends up being too large + ++ RLE encoding the image. Too big + ++ Looking for the color progression in ROM (Didn't have to be exact, + just low bytes the same). Sadly not there + ++ Drawing the boxes/text offscreen and basically do a palette-shifting + type thing. This is possible (though tricky as there are 10 + boxes but only 8 colors so it's not a straight up palette shift). + This has the same limitations that page-flipping does in that + you need an offscreen area. + See t3.s / T3 for implementation. Still large (192 bytes) + ++ BOT version + Fits in 141 bytes. + + See thinking_bot.s THINKING_BOT + Only draws lines that rotate, not boxes. + Draws bitmap at same time as drawing lines, meaning there is no + overdraw so no flicker. + + + diff --git a/graphics/gr/thinking/cracking_bot.s b/graphics/gr/thinking/cracking_bot.s new file mode 100644 index 00000000..04709d49 --- /dev/null +++ b/graphics/gr/thinking/cracking_bot.s @@ -0,0 +1,175 @@ +; Print-shop Style THINKING + +; by Vince `deater` Weaver + +.include "zp.inc" +.include "hardware.inc" + +; 161 -- original with page flip removed +; 159 -- remove extraneous store to YY +; 158 -- cond jump for jmp + +; 0------------------------- +; 0 1111111111111111111111 0 +; 0 1 22222222222222222221 0 + +; if XX < YY COL++ + + +COL = $F0 +XSTART = $F1 +XSTOP = $F2 +YSTART = $F3 +YSTOP = $F4 +OFFSET = $F5 +CURRENT = $F6 +YY = $F7 +BASE = $F8 +XS = $F9 + +thinking: + + jsr SETGR ; set lo-res 40x40 mode + ; A=$D0 afterward + +big_loop: + + lda #0 + sta YY + + ldx #0 +yloop: + txa + jsr GBASCALC ; take Y-coord/2 in A, put address in GBASL/H ( a trashed, C clear) + + lda COL + and #$7 + tay + lda color_lookup,Y + sta COLOR + + ;======================= + + ldy #0 +xloop: + + +inc_pointer: + inc YY + stx XS + + ; skip if out of range + cpx #7 + bcc draw_color + cpx #14 + bcs draw_color + + + + ldx YY + lda thinking_data-1-35,X + sta CURRENT +thinking_xloop: + ror CURRENT + bcs skip_color + + +draw_color: + lda COLOR + sta (GBASL),Y +skip_color: +no_draw: + ldx XS + + iny + + cpy #40 + beq done_done + + tya + and #$7 + beq inc_pointer + bne thinking_xloop +done_done: + + + + ;======================= + + cpx #9 + beq blarch + bcc blurgh + inc COL + jmp blarch +blurgh: + dec COL +blarch: + inx + cpx #20 + bne yloop + + + ;========================== + ; done drawing rainbow box + ;========================== + + ;========================== + ; flip pages + ;========================== + + + ;=================== + ; increment color + ; after loop we are +10 + ; so -1 actually means increment 1 (because we mod 8 it) +; inc COL +; inc COL + dec COL + dec COL + + ;=================== + ; WAIT + + lda #255 + jsr WAIT ; A = 0 at end + + beq big_loop + + +;0 1 2 3 3 +;01234567|89012345|67890123|45678901|23456789 +; ** ***| *** | ** * |* * * |* *** +; * * |* * * |* * *| * ** |* * * +; * * |* * * |* * * | * ** |* * +; * ***| ***** |* ** | * * * |* * +; * * *| * * |* * * | * * *|* * ** +; * * |* * * |* * *| * * *|* * * +; ** * |* * * | ** * |* * * |* **** +; 7*5 bytes = 35 bytes + + +thinking_data: +.byte $EC,$38,$16,$15,$39 +.byte $22,$45,$91,$34,$45 +.byte $22,$45,$51,$34,$05 +.byte $E2,$7C,$31,$54,$05 +.byte $A2,$44,$51,$94,$65 +.byte $22,$45,$91,$94,$45 +.byte $2C,$45,$16,$15,$79 + +color_lookup: + ; magenta, pink, orange, yellow, lgreen, aqua, mblue, lblue +.byte $33,$BB,$99,$DD,$CC,$EE,$66,$77 + + + + + + + + + ; for apple II bot entry at $3F5 + + ; at +8A, so 36B + + jmp thinking diff --git a/graphics/gr/thinking/t3.s b/graphics/gr/thinking/t3.s index 6ad57885..ee4a77cb 100644 --- a/graphics/gr/thinking/t3.s +++ b/graphics/gr/thinking/t3.s @@ -1,5 +1,8 @@ ; Print-shop Style THINKING +; this one draws pattern and bitmap once, offscreen +; then copies/color rotates each frame + ; by Vince `deater` Weaver .include "zp.inc" @@ -115,12 +118,21 @@ no_draw: cmp #14 bne thinking_yloop + + + ;========================== - ; flip pages + ; Animate ;========================== - bit PAGE2 + + + bit PAGE2 ; always on PAGE2 forever_loop: + ; + ; Copy image from PAGE1 to PAGE2 + ; rotating colors as necessary + ldy #0 copy_loop: diff --git a/graphics/gr/thinking/thinking_bot.s b/graphics/gr/thinking/thinking_bot.s new file mode 100644 index 00000000..85672d1f --- /dev/null +++ b/graphics/gr/thinking/thinking_bot.s @@ -0,0 +1,173 @@ +; Print-shop Style THINKING + +; by Vince `deater` Weaver + +.include "zp.inc" +.include "hardware.inc" + +; 161 -- original with page flip removed +; 159 -- remove extraneous store to YY +; 158 -- cond jump for jmp + +; 0------------------------- +; 0 1111111111111111111111 0 +; 0 1 22222222222222222221 0 + +; if XX < YY COL++ + + +COL = $F0 +XSTART = $F1 +XSTOP = $F2 +YSTART = $F3 +YSTOP = $F4 +OFFSET = $F5 +CURRENT = $F6 +YY = $F7 +BASE = $F8 +XS = $F9 + +thinking: + + jsr SETGR ; set lo-res 40x40 mode + ; A=$D0 afterward + +big_loop: + + lda #0 + sta YY + + ldx #0 +yloop: + txa + jsr GBASCALC ; take Y-coord/2 in A, put address in GBASL/H ( a trashed, C clear) + + lda COL + and #$7 + tay + lda color_lookup,Y + sta COLOR + + ;======================= + + ldy #0 +xloop: + + +inc_pointer: + inc YY + stx XS + + ; skip if out of range + cpx #7 + bcc draw_color + cpx #14 + bcs draw_color + + + + ldx YY + lda thinking_data-1-35,X + sta CURRENT +thinking_xloop: + ror CURRENT + bcs skip_color + + +draw_color: + lda COLOR + sta (GBASL),Y +skip_color: +no_draw: + ldx XS + + iny + + cpy #40 + beq done_done + + tya + and #$7 + beq inc_pointer + bne thinking_xloop +done_done: + + + + ;======================= + + cpx #9 + beq blarch + bcc blurgh + inc COL + jmp blarch +blurgh: + dec COL +blarch: + inx + cpx #20 + bne yloop + + + ;========================== + ; done drawing rainbow box + ;========================== + + ;========================== + ; flip pages + ;========================== + + + ;=================== + ; increment color + ; after loop we are +10 + ; so -1 actually means increment 1 (because we mod 8 it) +; inc COL +; inc COL + dec COL + dec COL + + ;=================== + ; WAIT + + lda #255 + jsr WAIT ; A = 0 at end + + beq big_loop + + +;0 1 2 3 3 +;01234567|89012345|67890123|45678901|23456789 +; ***** *| * * * | * * |* * * |* *** +; * *| * * **| * * *| * ** |* * * +; * *| * * **| * * * | * ** |* * +; * *|*** * * |* * ** | * * * |* * +; * *| * * * | ** * * | * * *|* * ** +; * *| * * * | ** * *| * * *|* * * +; * *| * * * | * * |* * * |* **** +; +; 7*5 bytes = 35 bytes + +color_lookup: + ; magenta, pink, orange, yellow, lgreen, aqua, mblue, lblue +.byte $33,$BB,$99,$DD,$CC,$EE,$66,$77 + +thinking_data: +.byte $BE,$54,$14,$15,$39 +.byte $88,$D4,$94,$34,$45 +.byte $88,$D4,$54,$34,$05 +.byte $88,$57,$35,$54,$05 +.byte $88,$54,$56,$94,$65 +.byte $88,$54,$96,$94,$45 +.byte $88,$54,$14,$15,$79 + + + + + + + ; for apple II bot entry at $3F5 + + ; at +8A, so 36B + + jmp thinking diff --git a/graphics/gr/thinking/thinking_flip.s b/graphics/gr/thinking/thinking_flip.s index adba59bc..d3644a89 100644 --- a/graphics/gr/thinking/thinking_flip.s +++ b/graphics/gr/thinking/thinking_flip.s @@ -1,29 +1,81 @@ ; Print-shop Style THINKING +; this one uses page flipping for smoother animation + ; by Vince `deater` Weaver -.include "zp.inc" .include "hardware.inc" -COL = $F0 -XSTART = $F1 +; zero page locations + +GBASL = $26 +GBASH = $27 + +COL = $F0 ; current start color of animated boxes +XSTART = $F1 ; co-ords of current block being drawn XSTOP = $F2 YSTART = $F3 YSTOP = $F4 -OFFSET = $F5 -CURRENT = $F6 -YY = $F7 + +CURRENT = $F3 ; current bitmap block +YY = $F4 ; bitmap Y value thinking: jsr SETGR ; set lo-res 40x40 mode ; A=$D0 afterward -big_loop: + ;========================================= + ; clear Lo-res PAGE2 to " " + ; technically just need to do that for bottom 4 lines + ; but easier(?) to just do it for whole screen - ; COL value doesn't matter? + ldy #0 + lda #$A0 ; space +clear_page2_inner_loop: +cp2_smc: + sta $800,Y + iny + bne clear_page2_inner_loop + + inc cp2_smc+2 ; want $800..$C00 + ldx cp2_smc+2 + cpx #$c + bne clear_page2_inner_loop + + + ; COL value doesn't matter, can be skipped if you don't care about + ; starting place in color animation lda #0 + sta COL + + +thinking_loop: + + jsr thinking_next_frame + + ; pause a bit + + lda #255 + jsr WAIT ; A==0 at end + + beq thinking_loop + + + + ;=========================== + ; thinking next frame + ;=========================== + ; draws and displays next frame +thinking_next_frame: + + ; draw the next frame of the animation + ; draw a box from 0,0 to 40,20*2 + ; then next at 1,1*2 to 39,19*2 + ; etc + + lda #0 ; starting points sta YSTART sta XSTART @@ -37,38 +89,41 @@ box_loop: ldx YSTART yloop: txa - jsr GBASCALC ; take Y-coord/2 in A, put address in GBASL/H ( a trashed, C clear) - lda GBASH + jsr GBASCALC ; take Y-coord/2 in A, put address in GBASL/H ( a trashed, C clear) + ; would be faster with lookup table + + lda GBASH ; adjust for PAGE1/PAGE2 draw_page_smc: adc #0 sta GBASH - lda COL + lda COL ; take start color, wrap, lookup in table and #$7 tay lda color_lookup,Y - ldy XSTART + ldy XSTART ; draw horizontal line xloop: sta (GBASL),Y iny cpy XSTOP bne xloop - inx + inx ; move to next Y, repeat until done cpx YSTOP bne yloop - inc COL + inc COL ; move to next color - inc XSTART + inc XSTART ; adjust boundaries for next box dec XSTOP inc YSTART dec YSTOP lda YSTOP - cmp #10 + + cmp #10 ; see if reached middle bne box_loop ;========================== @@ -79,16 +134,22 @@ xloop: ; write THINKING ;========================== -thinking_loop: - lda #7 +thinking_bitmap_loop: + lda #7 ; text is from lines 7 to 14 sta YY - ldx #0 + ldx #0 ; X is offset into the bitmap thinking_yloop: lda YY jsr GBASCALC ; take Y-coord/2 in A, put address in GBASL/H ( a trashed, C clear) - ldy #0 + + lda GBASH ; adjust for PAGE1/PAGE2 +draw_bitmap_smc: + adc #$0 + sta GBASH + + ldy #0 ; bump to next part of bitmap each 8 pixels inc_pointer: inx lda thinking_data-1,X @@ -97,16 +158,20 @@ thinking_xloop: ror CURRENT bcc no_draw - lda #$00 + lda #$00 ; draw black if bit set, otherwise skip sta (GBASL),Y no_draw: iny - tya - and #$7 - beq inc_pointer - cpy #39 - bne thinking_xloop + cpy #40 ; if it's been 40 bits, next line + beq done_line + + tya + and #$7 ; if it's been 8 bits, move on + beq inc_pointer + bne thinking_xloop ; otherwise, keep drawing + +done_line: inc YY lda YY @@ -128,11 +193,10 @@ done_page: eor #$4 ; flip draw page between $400/$800 sta draw_page_smc+1 ; DRAW_PAGE + sta draw_bitmap_smc+1 - lda #255 - jsr WAIT ;=================== ; increment color @@ -140,7 +204,7 @@ done_page: ; so -1 actually means increment 1 (because we mod 8 it) dec COL - jmp big_loop + rts ;0 1 2 3 3 @@ -170,7 +234,3 @@ color_lookup: ; magenta, pink, orange, yellow, lgreen, aqua, mblue, lblue .byte $33,$BB,$99,$DD,$CC,$EE,$66,$77 - - ; for apple II bot entry at $3F5 - - jmp thinking diff --git a/graphics/gr/thinking/thinking_slow.s b/graphics/gr/thinking/thinking_slow.s index b135bbfc..03089d42 100644 --- a/graphics/gr/thinking/thinking_slow.s +++ b/graphics/gr/thinking/thinking_slow.s @@ -1,5 +1,8 @@ ; Print-shop Style THINKING +; this one tries to save space by using HLIN instead of open-coded hline routine +; ends up being really slow but also not small enough + ; by Vince `deater` Weaver .include "zp.inc"