diff --git a/graphics/gr/tunnel/t.s b/graphics/gr/tunnel/t.s index 9ec46e02..d4751e72 100644 --- a/graphics/gr/tunnel/t.s +++ b/graphics/gr/tunnel/t.s @@ -1,7 +1,18 @@ +; 186 bytes -- original +; 178 bytes -- not using line 7 of lookup table +; 168 bytes -- color can wrap +; 167 bytes -- unnecessary clc +; 163 bytes -- no need to init color at beginning +; 154 bytes -- optimize some calculations + H2 = $2C V2 = $2D COLOR = $30 +QL = $F5 +QH = $F6 +VL = $F7 +VH = $F8 P = $F9 Q = $FA J = $FB @@ -22,10 +33,47 @@ tunnel: ; 1 GR:N=23 jsr SETGR -; bit FULLGR - lda #23 - sta NEWCOLOR +.if 0 +make_table: + lda #$2 + sta VH + lda #$0 + tay + sta VL +bigloop: + lda #0 + sta QL + sta QH + tax +qqloop: + clc + lda VL + adc QL + sta QL + lda VH + adc QH + sta QH + inx + cmp #$28 + bcc qqloop + + txa + sta lookup,Y + iny + + clc + lda VL + adc #$24 + sta VL + lda #0 + adc VH + sta VH + + cmp #$A + bne bigloop +.endif + forq: @@ -40,7 +88,8 @@ qloop: ; 3 FOR I=0 TO 19:IF 20-I>A(P,Q) THEN 7 fori: - ldx #0 + tax ; X is 0 + iloop: lda Q asl @@ -60,25 +109,23 @@ iloop: inc P - txa - eor #$ff - sec - adc #39 + ; A is already 20-I at this point, carry is clear + adc #19 sta Z - sta H2 - sta V2 - dec H2 - dec V2 + tay + dey + sty H2 + sty V2 - txa - clc - adc #1 - sta J + stx J + inc J ; 6 COLOR=N+P:HLIN J,W AT I:HLIN J,W AT Z:VLIN J,W AT I:VLIN J,W AT Z + ; c always 0? + lda P - clc +; clc adc NEWCOLOR jsr SETCOL @@ -117,19 +164,13 @@ skip: inx cpx #19 bne iloop - +blah: dec Q bpl qloop inc NEWCOLOR - lda NEWCOLOR - cmp #32 - bne blah - - lda #16 - sta NEWCOLOR -blah: + ; wrapping 255 to 0 is OK end: ; 8 GOTO 2 @@ -139,14 +180,37 @@ end: ; 0 DIM A(9,9):FOR I=0 TO 8:FOR J=0 TO 8:A(I,J)=40/(2+I+J/7):NEXTJ,I lookup: - .byte 20,13,10,8,6,5,5,4 - .byte 18,12, 9,7,6,5,4,4 - .byte 17,12, 9,7,6,5,4,4 - .byte 16,11, 9,7,6,5,4,4 - .byte 15,11, 8,7,6,5,4,4 - .byte 14,10, 8,7,5,5,4,4 - .byte 14,10, 8,6,5,5,4,4 - .byte 13,10, 8,6,5,5,4,4 + + + +.byte 20,13,10,8,7,6,5,4 ; 2.0 3.0 4,0 5,0 6.0 7.0 8.0 9.0 +.byte 19,13,10,8,7,6,5,4 ; 2.1 3.1 4.1 5.1 6.1 7.1 8.1 9.1 +.byte 18,12,9,8,6,5,5,4 +.byte 17,12,9,7,6,5,5,4 +.byte 16,11,9,7,6,5,5,4 +.byte 15,11,9,7,6,5,5,4 +.byte 14,10,8,7,6,5,5,4 + + + + +; (P*7)+Q +; .byte 20,18,17,16,15,14,14 +; .byte 13,12,12,11,11,10,10 +; .byte 10, 9, 9, 9, 8, 8, 8 +; .byte 8, 7, 7, 7, 7, 7, 6 +; .byte 6, 6, 6, 6, 6, 5, 5 +; .byte 5, 4, 4, 4, 4, 4, 4 +; .byte 4, 4, 4, 4, 4, 4, 4 + +; (Q<<8)|P Q 6..0 P 0..6 +; .byte 20,13,10,8,6,5,5,4 ; 0 +; .byte 18,12, 9,7,6,5,4,4 ; 1 +; .byte 17,12, 9,7,6,5,4,4 ; 2 +; .byte 16,11, 9,7,6,5,4,4 ; 3 +; .byte 15,11, 8,7,6,5,4,4 ; 4 +; .byte 14,10, 8,7,5,5,4,4 ; 5 +; .byte 14,10, 8,6,5,5,4,4 ; 6 ; need for bot diff --git a/graphics/gr/tunnel/table.c b/graphics/gr/tunnel/table.c index b7a0e361..07d74f6b 100644 --- a/graphics/gr/tunnel/table.c +++ b/graphics/gr/tunnel/table.c @@ -4,6 +4,10 @@ int main(int argc, char **argv) { double x,y; + // 6.2 FLOAT POINT + + // 2 3 4 5 6 7 8 + // 2.1 3.1 4.1 5.1 6.1 for(y=0;y<1;y+=1.0/7.0) { printf("%.2lf: ",y); for(x=2.0+y;x<=9.0+y;x++) { @@ -22,5 +26,43 @@ int main(int argc, char **argv) { printf("\n"); } + // 6.2 FLOAT POINT + + // 2 3 4 5 6 7 8 + // 2.1 3.1 4.1 5.1 6.1 + int q; + for(y=0;y<7;y++) { + q=y*0x24; + for(x=0x200+q;x<=0x900+q;x+=0x100) { + printf("%.0lf,",0x2800/x); + } + printf("\n"); + } + + printf("\n"); + + + y=7; + q=0; +yloop: + x=0x200+q; +xloop: + printf("%02X,",(int)(0x2800/x)); + + x=x+0x100; + if (x<0xA00+q) goto xloop; + + printf("\n"); + q=q+0x24; + y=y-1; + if (y>=0) goto yloop; + + printf("\n"); + + return 0; } + +// 40/(2+I+J/7) +// 0.1 0.2 0.3 ... 0.7 +// 1.0 1.1