AppleIIbot 280 char Applesoft Demos -- Part 5


Hi-res Moving Waves


link

Unlike the previous ones that are just effectively doing fake palette shifting, this one the sinewave pattern is actually actively moving around. This ends up being a bit slower.

1FORI=0TO139:POKE1013+I,4*PEEK(2126+I)-204+(PEEK(2266+I/3)-35)/4^(I-INT(I/3)*3):NEXT
2&"/foL:Be;569e7W4>qM5\bO4=Q2EqY3KegilrZb;3o\a[EA@ln\a/JVA4[<9YDp]b3KQ3KDhE22]aM4DU<[C4ARVC4U-hdbZkbrgZZle;g+SbAaEBRl]\;O^rW[;(14)36/6879:,7::;SW$@#@;#;*#,04M533&&D$$HP(I04&KI0I$DAGK]MOTD+\&
Link to machine code source: moving.s

Ocean Scene (LOGO)


link

I was working on the Demosplash LOGO demo so was doing a lot of experimenting with compact LOGO code. This scene is similar to one in the final version. LOGO sizecoding is a bit different than the BASIC and 6502 variants.

{L}
SETPC 4 SETPOS[90 80] CLEAN REPEAT 36[RT 5 FD 2 RT 5]
REPEAT 9[RT 40 PU SETPOS[100 80] FD 25 PD BK 10]
SETPC 5 PU HOME PD
RT 180 FD 119 RT 90 FD 280 RT 90 FD 119
RT 45 REPEAT 20[FD 10 RT 90 FD 10 LT 90]
FILL BK 50
SETPC 1 REPEAT 40[FD 1 RT 3] RT 90
REPEAT 40[FD 1 RT 3] HT

Thick Sine


link

Was trying to draw some circles but ended up making this cool looking sine pattern. Eventually got a different version that nearly fits in 64 bytes. Getting sines in a small space is difficult. The Applesoft BASIC ROM does have a cosine table for shape tables but it's missing a term and it's not really much smaller to use it rather than just including the proper table that we want.

1FORI=0TO102:POKE1013+I,4*PEEK(2126+I)-204+(PEEK(2229+I/3)-35)/4^(I-INT(I/3)*3):NEXT
2&"/foL:Be;569e7W4>qM5\bE4=S3EqM3Y3KYdjS1Tr[3Ip\qb3C75EI\r[38Hpbpljeml94Vq=5bBa3\_BrTlF943-35/5768959:+7:;SW$@#@;&3*$SE%O)CD&/MF-<Z;W$$>?+5a#
Link to machine code source: thick_sine.s

Turkey Time


link

I've done a few holidays before with the lo-res block drawing code, this time I made one for Thanksgiving.

0REM/ G O-(>-?!$C<@)%B5:)*-'.),/-4):=&.)8;-4!07%,(16*0(3414(,;5G(*=7D(()EG(>?EG)//GL)88GL).0LL)79LL 25!' 07()/25*, 25,,(34*,)34.0)25..(25&'-45&'
1DEFFNP(X)=PEEK(2054+I*5+X)-32:GR:POKE49234,0:FORI=0TO27:COLOR=FNP(0):FORY=FNP(3)TOFNP(4):HLINFNP(1),FNP(2)ATY:NEXTY,I:GETA

Hi-res Doom Fire


link

This is the "Doom Fire" effect once again, but trying to do it for hi-res mode. Trickier than you might think. Partly because there aren't good colors, partly because of the non-linear hi-res memory layout. Also generating random numbers compactly is a challenge as well. In the end it uses a large lookup table for colors, and uses the ROM contents for "randomness".

1FORI=0TO139:POKE1013+I,4*PEEK(2126+I)-192+(PEEK(2266+I/3)-35)/4^(I-INT(I/3)*3):NEXT
2&"*el,cl;E`Q8Z2WdEb4`U_N74dW9M8Y4P9QfbN74aU9[0h01[80B3R<0\9Vk0\QT7k8)b2j81_0Z_R81R4dYhfUd]R80lY8Q9R8BCP9Q8\3Y_H0T9R4kYhjh`bglU0QOOTXbfdeoblodo[S#A*.]5G4:E5S$347'5=-C)77#++,4)@7?=4#,#+&7GH:2
Link to machine code source: flame.s

Hi-res Screen Wipe


link

I was working on a hi-res screen wipe for the Peasant's Quest demake and this was an unintended side effect. It goes a bit too fast but I couldn't find the bytes needed to add a delay.

1FORI=0TO138:POKE1013+I,4*PEEK(2126+I)-204+(PEEK(2265+I/3)-35)/4^(I-INT(I/3)*3):NEXT
2&"/foT5XleggbqcmdcX<Qq[5Srcr;52le8=2lr8=4aq;93e6gmGkF0ffVq=-\`nTq\nTgjrQn535;3o\7SpW4\cQ<Vo]IU<Y<9I3T:egk8\im6FoTgbqi7dim7`g\kKqModjm4cro'daKSA.NIV/3)FU+/16#]3<>(4LP-4:5X;J04.5C<I;F?:@C(U#
Link to machine code source: rectangle.s

Christmas Scene (BASIC)


link

I guess this ended up being my Christmas Demo for 2021. All in BASIC. It was tricky getting a decent looking tree as well as an OK looking house. Snow was a pain too. If you let this run forever it will completely cover the screen in snow.

0Q=38:GR:FORI=0TO9:X(I)=RND(1)*Q:Y(I)=I:COLOR=1:VLIN33,QAT16+I:COLOR=4:HLIN9-I/2,9+I/2AT28+I:COLOR=8:VLIN29,33AT16+I:NEXT:VLIN36,QAT20:HLIN0,QAT39:PLOT9,Q
3FORI=0TO9:V=X(I):W=Y(I):COLOR=15:PLOTV,W:PLOTV,W+1:COLOR=0:IFSCRN(V,W+2)>0THENX(I)=RND(1)*Q:W=0
6PLOTV,W:Y(I)=W+1:NEXT:GOTO3

Edgarware Intro (BASIC)


link

Another lo-res boxdrawing, this one because I was re-watching some old Homestar Runner stuff. This one got a lot of views because someone told Strongbad about it. Drop a train on them, Edgar!

0REM&*<DG&,:@C&-9??&/7=>/6:DF 78BC 88BE!::BC%33@A%33DE+15(=+/61:+.715(66(.(15''(/3(*(/1+,(/0-.%/6//'/600//113/4613#2366/159:/35;<
1GR:?"  PROGRAMMED IN EDGAR'S MOM'S BASEMENT":DEFFNP(X)=PEEK(2054+I*5+X)-32
2FORI=0TO24:COLOR=FNP(0):FORY=FNP(3)TOFNP(4):HLINFNP(1),FNP(2)ATY:NEXTY,I

Cosine Wave Effect 3


link

When trying to get the Thick Sine demo down to 64-bytes for Lovebyte I ran into a lot of interesting failure modes. This half-height almost greyscale effect was an interesting one.

1FORI=0TO68:POKE1013+I,4*PEEK(2125+I)-204+(PEEK(2194+I/3)-35)/4^(I-INT(I/3)*3):NEXT
2&"/foT5aXnEDMKYS3TNEn@M2Y[2XW]3eYll5kmapU9rO&BrPk\e:B\aO3[38Hpap\kmgbljSAJ)$46''$U+Q/Y4Z'#/Q#S
Link to machine code source: oops3_cos.s

Cosine Wave Effect 4


link

Yet another cosine mistake when working on Thick Sine for Lovebyte. Note that these are so short they break the encoder I have (it assumes an offset to start of data with a 3-digit length in the FOR loop), I really need to fix the code to handle small code properly.

1FORI=0TO68:POKE1013+I,4*PEEK(2125+I)-204+(PEEK(2194+I/3)-35)/4^(I-INT(I/3)*3):NEXT
2&"/foT5aXnEDYS2XOBrAI2YW2XV]3ceom7l_irI9rI2EqTlUq=>\aK2MK[38Hpap\kmginjSAJ)'043'+$[U;*@63#/Q#5
Link to machine code source: oops4_cos.s

Orb Horror


link

This one was an outtake when working on the Orb demo for Lovebyte. Was shaving bytes off and went a few bytes too far.

1FORI=0TO134:POKE1013+I,4*PEEK(2126+I)-204+(PEEK(2261+I/3)-35)/4^(I-INT(I/3)*3):NEXT
2&"/fo]UTjTrY2TjSqZ3AhqleQq_8lcYpY4<e<4cqAkq[1Sr359GqLdQqUoEqTqhp\dBrJoldZ3No\k43;1]]S9En]Vo]G8Pp[38HpVo=*C3P]p5[3[3;6ndh5gWpdp_Z\rm3mp:o3S%+4>04WCZ+V)(5-8Z@*5XLY<9L$P=3&/<IY%%GE8&%CS
Link to machine code source: horror.s

Lemmings (BASIC)


link

It was the 30th anniversary of Lemmings and I was watching a documentary and I realized the animation can fit in Apple II hires colors. I thought I'd try a variation of the box drawing, just in hi-res.

It was a huge pain getting this to fit, there was just one block too many in the animation. Also there was the problem of having a delay between the page flipping so it wouldn't happen simultaenously. In the end the solution was to start page flipping immediately (though this led to the weird flashing stripes for the first 9 frames as un-initialized RAM is shown until we call HGR2 to clear page2). We also draw the last box over and over again and it acts as the delay loop.

In a bonus, someone pointed one of the original authors of Lemmings to this and they "liked" it.
1HGR:DEFFNP(X)=7*PEEK(2185+I*5+X)-224
4HCOLOR=FNP(0)/7:FORY=FNP(3)TOFNP(4)-1:HPLOTFNP(1),YTOFNP(2)-1,Y:NEXTY:IFI=9THENHGR2
7P=NOTP:POKE49236+P,0:IFI<21THENI=I+1
8GOTO4
9"&-/*/&,0./'+,.0'.0/0'-.*,'./,-!,0(*!-/'(#./()#-0)*!,/')!-.&'!/0&'&-/*.&,../',./0'/0./'01,.',-+-'-.*+#./()#-0)*

Rainbow Cosine


link

Was going through code when updating this page and realized I had never posted this one, the original mistake when doing Thick Sine.

1FORI=0TO82:POKE1013+I,4*PEEK(2125+I)-204+(PEEK(2208+I/3)-35)/4^(I-INT(I/3)*3):NEXT
2&"/foT5aXnE?DYO2XBBr@M3Y[3TV]+ceom7iTl[3Tp[3Nq\e:B\`O4MKYr['8Hfjrirgcl:,:rA3\_BrTlF94SAJ=3W'$4C#.#.=Y))1SK1LC;W$$
Link to machine code source: oops_cos.s

Particle Effects


lo-res link hi-res link

This code came about when I was working on particle effect code for the Lemmings Demake.

The lo-res version was way more popular than I would have expected, in the end Tim Sweeney re-tweeted it.

1FORI=0TO139:POKE876+I,4*PEEK(2125+I)-204+(PEEK(2265+I/3)-35)/4^(I-INT(I/3)*3):NEXT
2&"-ho<Gc<Hc]L;YqZ/3Z.3Z-3Z(2ebnb/:R,:Z3;?7eGU5r/;b.:R/;Z2;?3eKR9]<Z35DZ.:]5Z3/8k2eSLZ3/8k2Z3;b3;;Loj3;?ib3;A\b*9E;3qeg]iV\9C<<U3A_TBDD65m5KFK3[++$337;O73?#)K373''7';7*U*)V*'%+%$5G#%;NC4*@#/
1FORI=0TO138:POKE877+I,4*PEEK(2125+I)-204+(PEEK(2264+I/3)-35)/4^(I-INT(I/3)*3):NEXT
2&"-ho/foWB]2TlQCb/:a2;['8HpM]S\a3;9E0;Y3;r3<]2;8Q3;Y3.bbS:]RY3:]LU2;V5Y1;;d2eMLY0;;d25nY3:j3/liVqTlYEb3;]2;[3;HpM]U7T>WTBE9CW2E`PCD6:6@m5GEN3[S3'C3'S#;#T$%4''X3''4@+A;/A'+U@#%4#D1)4Z'3&
Link to machine code source: lores particle_bot.s
Hires particle_hgr_bot.s

Lunar Lander


link

Had some ideas that maybe I could do some more interesting things with shape tables. Turns out doing lunar lander is just a bit too complex.

Using beeps for delays again, sorry for anyone trying this on a real machine.

2POKE232,20:POKE233,8
5REM#%%-...
6HGR:X=128:HPLOT0,XTO50,110TO113,XTO144,XTO217,94TO253,112
7ROT=0:SCALE=2:XDRAW1ATX,Y:H%=127-Y:VTAB22:?CHR$(7)"ALT="H%" ":XDRAW1ATX,Y:Y=Y+A:A=A+1/4:IFA=4THENSCALE=1:XDRAW1ATX+2,Y+4:A=1
8IFH%>0THEN7
9FORI=2TO16:SCALE=I/2:ROT=I*4:XDRAW1ATX,Y:NEXT

Lo-res Background Scroller


diamond link ][ link

This came out of some prep work I was doing for a demo. Trying to see if I could scroll a lo-res background while superimposing some text in the foreground.

The diamond case is scrolling a 16x8 lores pattern, but only enough room left to put a single line floating on top. The Apple II case has enough for a 16x8 bitmap, at the expense of the background being random noise (in this case, ROM memory from $F000). Also it's slightly smaller to pseudo-scroll right rather than properly scrolling down.

The sizes of things being drawn here are important, as we are abusing the weird lo-res bitmap interleave when copying the pattern, which saves a whole bunch of pointer math.

1FORI=0TO140:POKE875+I,4*PEEK(2125+I)-204+(PEEK(2266+I/3)-35)/4^(I-INT(I/3)*3):NEXT
2&"/@q<GcY3VM2](QrPNU:4]Te3Z34Y4o.a38^T2MSJQ3L1nI1drgjR4[7Z?2egm:d*\O2E6HL3JY3?D=-\bDb]e;]ro^4]S2M5dpg.\hIP3K4CgFhC4CgF4?3FhChC4C4ChB3FhChF4C7J3S+4@WQ0X$UW'*TOP&P(+5J*\T=<3##7*(9X#'#'3###4#$_
1FORI=0TO140:POKE875+I,4*PEEK(2125+I)-204+(PEEK(2266+I/3)-35)/4^(I-INT(I/3)*3):NEXT
2&"/fo<HcPqTh35I3Tq]e;]rXPY22]b3oWrU7p9OQ3I4=-ST/8\qMSTrWeKrOq=+ehP2U8Dq8M@N;\h35E;T0X6Uk3D]3Ei3Ek3Q2]iU<I4ma6h_Q3Rp]bHcD3F@0rfpqdhr$oTKWZQr37J3S+4M4(#/P$$#`4Z6'$98FQ/'<M@VX)YY;JS5aL#(b8X_b2_
Link to machine code source: diamond_bot.s
random_bot.s
On to Part 6
Back to Part 4
Back to main Apple II bot page