Jump to content
IGNORED

Valentine's Day Programming Project


BoatofCar

Recommended Posts

Also, you should move line 640 that clears out the player/missile positions up to just after line 390. If the program is stopped and run again GTIA shows vertical bands of changing data at the players' last locations. The loop in line 640 (moved to the start of initialization) will move the players off screen so this isn't visible.

Link to comment
Share on other sites

Today's version with recommended changes and sound added. I redrew the flags outside of the loop so they could be displayed while the music played. Why is the music slow and distorted, and why are the PMG's messed up?

 

 


100 REM HAPPY VALENTINE'S DAY GAME/DEMO
110 GOTO 390:REM GO INIT EVERYTHING
120 REM MOVEMENT AND LOGIC
130 HISX=HISX+ST2X(STICK(0))
140 IF HISX>200 THEN HISX=200
150 IF HISX<48 THEN HISX=48
160 HERX=HERX+ST2X(STICK(1))
170 IF HERX>200 THEN HERX=200
180 IF HERX<48 THEN HERX=48
190 IF CAKEMV=0 AND STRIG(0)=0 THEN CAKEMV=SGN(HERX-HISX)*3:CAKEX=HISX
200 CAKEX=CAKEX+CAKEMV:IF CAKEMV=0 THEN CAKEX=0
210 IF CAKEMV<0 AND CAKEX<=HERX THEN CATCHES=CATCHES+1:CAKEMV=0:CAKEX=0
220 IF CAKEMV>0 AND CAKEX>=HERX THEN CATCHES=CATCHES+1:CAKEMV=0:CAKEX=0
230 POKE 53248,HISX:POKE 53249,HERX:POKE 53250,CAKEX:POKE 53251,CAKEX
240 POKE 77,0:IF CATCHES<1 THEN GOTO 130: REM DISABLE ATTRACT MODE, THEN LOOP
250 REM THE END
260 TARGET=HISX-6:IF TARGET<48 THEN TARGET=HISX+6
270 IF HERX=TARGET THEN GOTO 290:REM MOVING HER TO HIM
280 HERX=HERX+SGN(TARGET-HERX):POKE 53249,HERX:GOTO 270
290 POKE 756,226:REM A LAME FONT TRICK
295 POKE 752,0:REM TURN OFF CURSOR
310 FOR OUT=1 TO 10
320 FOR I=48 TO 63 STEP 0.125:POKE 708,I:NEXT I
330 FOR I=63 TO 48 STEP -0.125:POKE 708,I:NEXT I
340 NEXT OUT
350 POKE 708,54
351 SETCOLOR 0,0,15
353 POKE 756,224
355 ? " Happy Birthday!"
360 GOTO 360
370 REM INIT ALL THE STUFF
390 GRAPHICS 3
393 FOR I=0 TO 27:POKE 53248+I,0:NEXT I:REM CLEAR COLORS, HPOS, ETC, IN GTIA.
395 POKE 752,1: REM TURN OFF CURSOR
400 SETCOLOR 0,0,15:SETCOLOR 1,3,6:SETCOLOR 3,12,6
410 DL=PEEK(560)+(256*PEEK(561)):REM FIND THE DISPLAY LIST
420 REM CHANGE THE OS MODE 0/ANTIC MODE 2 TEXT LINES
430 REM TO OS MODE 1/ANTIC MODE 6 TEXT LINES.
440 POKE DL+25,70:POKE DL+28,6:POKE DL+29,6:POKE DL+30,6
450 REM FIND THE START OF THE "TEXT" WINDOW MEMORY IN THE DISPLAY LIST
460 SC=PEEK(DL+26)+(256*PEEK(DL+27))
470 REM STUFF A GRAPHICS CHARACTER ACROSS THE TOP TEXT LINE
480 FOR I=0 TO 19:POKE SC+I,255:NEXT I
481 POSITION 1,5:? #6;" CCCBBBBB":REM US FLAG
482 POSITION 1,6:? #6;" CCCAAAAA"
483 POSITION 1,7:? #6;" BBBBBBBB"
484 POSITION 1,8:? #6;" AAAAAAAA"
485 POSITION 1,9:? #6;" BBBBBBBB"
486 POSITION 31,5:? #6;"BBBBBBBB "
487 POSITION 31,6:? #6;"AAAAAAAA "
488 POSITION 31,7:? #6;"CCCCCCCC "
489 POSITION 31,8:? #6;"AAAAAAAA "
490 POSITION 31,9:? #6;"BBBBBBBB "
491 L = 50:REM SOUND
492 READ NT,TM
493 IF NT=1 THEN T=T+1:RESTORE
494 IF T=1 THEN GOTO 501
495 SOUND 0,NT,10,10
496 FOR PLAY = 1 TO (TM*L) : NEXT PLAY
497 GOTO 491
498 DATA 162,1,121,3,96,1,81,4,81,3,81,1,72,3,81,1,91,3,72,1,81,12,96,3,91,1,96,4,108,4,0,3,108,1,108,3,96,1,108,3
499 DATA 121,8
500 DATA 1,0
501 SOUND 0,0,0,0
502 FOR I=0 TO 10:REM ANIMATE THE FLAGS
510 POSITION I,5:? #6;" CCCBBBBB":REM US FLAG
520 POSITION I,6:? #6;" CCCAAAAA"
530 POSITION I,7:? #6;" BBBBBBBB"
540 POSITION I,8:? #6;" AAAAAAAA"
550 POSITION I,9:? #6;" BBBBBBBB"
560 POSITION 31-I,5:? #6;"BBBBBBBB ":REM THAI FLAG
570 POSITION 31-I,6:? #6;"AAAAAAAA "
580 POSITION 31-I,7:? #6;"CCCCCCCC "
590 POSITION 31-I,8:? #6;"AAAAAAAA "
600 POSITION 31-I,9:? #6;"BBBBBBBB "
610 FOR N=1 TO 100:NEXT N
620 NEXT I
630 HISX=78:HERX=170:CAKEX=0:CAKEMV=0:CATCHES=0
680 POKE 706,248:REM CAKEX
690 POKE 705,88:REM GIRL
700 POKE 704,136:REM BOY
710 POKE 707,15:REM CAKEX
720 REM SET PM GRAPHICS
730 PMPAGE=INT((PEEK(561)/8)-1)*8
740 POKE 54279,PMPAGE
750 PMMEM=PMPAGE*256
760 P0MEM=PMMEM+512
770 P1MEM=PMMEM+640
780 P2MEM=PMMEM+768
790 P3MEM=PMMEM+896
800 FOR I=0 TO 127
810 POKE P0MEM+I,0:POKE P1MEM+I,0:POKE P2MEM+I,0:POKE P3MEM+I,0
820 NEXT I
830 POKE 53277,2:REM GTIA PLAYERS ON
840 POKE 559,42:REM ANTIC SCREEN, PLAYERS, 2 LINE P/M RESOLUTION
850 POKE 623,1:REM PRIORITY ALL P/M ON TOP
860 FOR I=0 TO 9:READ D:POKE P0MEM+86+I,D:NEXT I:REM HIM
870 DATA 24,24,0,60,90,24,0,24,24,60
880 FOR I=0 TO 9:READ D:POKE P1MEM+86+I,D:NEXT I:REM HER
890 DATA 24,24,0,60,90,24,60,126,24,60
900 FOR I=0 TO 5:READ D:POKE P2MEM+86+I,D:NEXT I:REM CAKEX
910 DATA 0,120,0,120,0,0
920 FOR I=0 TO 5:READ D:POKE P3MEM+86+I,D:NEXT I:REM CAKEX
930 DATA 48,0,252,132,0,0
940 DIM ST2X(15):REM CONVERT STICK TO MOVEMENT
950 FOR I=0 TO 15:READ D:ST2X(I)=D:NEXT I
960 DATA 0,0,0,0,0,2,2,2
970 DATA 0,-2,-2,-2,0,0,0,0
980 GOTO 130
Link to comment
Share on other sites

Why is the music slow and distorted, and why are the PMG's messed up?

 

 

This is the busy loop making the program pause while a note is played....

496 FOR PLAY = 1 TO (TM*L) : NEXT PLAY

.

TM (time) is read from DATA.

L is defined here:

491 L = 50:REM SOUND

.

So, that loop runs 50 times whatever value is read for TM.

To make the duration shorter and the music faster, change the DATA or change the multiplier L in the line above. (it's easier/faster to just change L .)

 

The reason the music is slower now than when you had it in a short demo? Atari BASIC is just inefficient at some things and one of those is branching (which is required for FOR/NEXT loops.) Atari BASIC does a search of the code from the start to wherever BASIC determines it must branch. This means loops later in a program are slower than loops near the beginning. (That's one of the reasons the interactive part and moving the players is at the beginning of the program.)

 

Other BASIC's are not so inefficient. Running the program with OSS BASIC XL, the music sounds alright to me.

.

.

 

The Player/Missile data is messed up, because the program is reading the song data as the Player images.

This is what causes the READ statements after the music is over to re-use the music data for the Player graphics:

493 IF NT=1 THEN T=T+1:RESTORE

.

Add this to force the Player initialization section to begin reading data from the correct DATA lines:

855 Restore 870

.

That tells BASIC the next READ it encounters will use the DATA beginning from that line.

Link to comment
Share on other sites

It certainly will.

 

When compiled it should use the jiffy clock to wait for a specific amount of time, not a specific count of loops.

The jiffy clock ticks at the display frame rate -- 60 times a sec for NTSC, 50 ticks per sec for PAL.

 

I discussed that earlier (Post #18): http://atariage.com/forums/topic/221650-valentines-day-programming-project/?do=findComment&comment=2922452

Link to comment
Share on other sites

If you want to start speeding things up as they are (in BASIC) you can combine program lines of code. Combining lines will make the code harder to read so I'd get everything working first; but you will be suprised how much quicker it will run! Remember to have the IFs as the last statements on combined lines as subsequent statements will not be ran unless the IF is true.

 

Also, you have probably already done this, move any setup stuff to the end of the program. Keep your main program loop at the start.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...