Jump to content

Recommended Posts

I'm trying to make a timer here and I'm having a little bit of trouble here and I have a couple questions:

20 COLUBK=14 : player0x=95 : player0y=50 : scorecolor= 128 : score=0
30 player0:
 %00010000
 %01000100
 %00000000
 %00011101
 %10010000
 %00010001
 %01000100
 %00010000
end
40 drawscreen
50 if joy0fire then goto 200
60 goto 20

200 score=0
202 t=t+1 : COLUP0=196
 if t=60 then score=score+1 : t=0 : goto 202
 if $60=score[2] then score=1000
216 drawscreen
218 if joy0down then goto 220
219 goto 202

220 COLUP0=64 : t=t+0
221 if joy0fire then goto 202
222 if joy0up then goto 20
223 drawscreen
224 goto 220

#1: How do I make it that when score says 1060, make it say 2000; when it says 2060, make it say 3000; etc. and

#2: Is there any way to hack into the score display to make the fourth 0 from the left look like a colon?

Edited by atari2600land
Link to comment
https://forums.atariage.com/topic/90315-making-a-timer/
Share on other sites

I'm trying to make a timer here and I'm having a little bit of trouble here and I have a couple questions:

20 COLUBK=14 : player0x=95 : player0y=50 : scorecolor= 128 : score=0
30 player0:
 %00010000
 %01000100
 %00000000
 %00011101
 %10010000
 %00010001
 %01000100
 %00010000
end
40 drawscreen
50 if joy0fire then goto 200
60 goto 20

200 score=0
202 t=t+1 : COLUP0=196
 if t=60 then score=score+1 : t=0 : goto 202
 if $60=score[2] then score=1000
216 drawscreen
218 if joy0down then goto 220
219 goto 202

220 COLUP0=64 : t=t+0
221 if joy0fire then goto 202
222 if joy0up then goto 20
223 drawscreen
224 goto 220

#1: How do I make it that when score says 1060, make it say 2000; when it says 2060, make it say 3000; etc. and

#2: Is there any way to hack into the score display to make the fourth 0 from the left look like a colon?

Haven't tested it, but this should work for #1

if $60 = score[1] then score=score + 940

 

For #2 you would need to modify score_graphics.asm to have a : character after the nine. You'd also need to modify the ifconst section at the top and subtract 8 from every ORG and FORG. WARNING - do not change the ORG and FORG values that occur after the score graphics. Then to show the : you'd need to modify the routines that convert the score for display to make the fourth digit from the left be "A" which would show the :

Link to comment
https://forums.atariage.com/topic/90315-making-a-timer/#findComment-1097849
Share on other sites

#1 didn't work. Either you A.) didn't understand my question right or B.) the code is wrong. If it's A.) fill in the question marks:

if $60=score[2] then score=1000

if ????????? then score=2000

----

For #2 you would need to modify score_graphics.asm to have a : character after the nine. You'd also need to modify the ifconst section at the top and subtract 8 from every ORG and FORG. WARNING - do not change the ORG and FORG values that occur after the score graphics. Then to show the : you'd need to modify the routines that convert the score for display to make the fourth digit from the left be "A" which would show the :

I have no idea what that means. Do you program this into the program itself or change an ASM file and put it in the program or what? I've never hacked into Batari Basic before.

Edited by atari2600land
Link to comment
https://forums.atariage.com/topic/90315-making-a-timer/#findComment-1097854
Share on other sites

#1: How do I make it that when score says 1060, make it say 2000; when it says 2060, make it say 3000; etc.

 

SpiceWare's answer was correct, except it looks like it had a typo in it, because score[1] should have been score[2], like this:

 

202 t=t+1 : COLUP0=196
 if t=60 then score=score+1 : t=0 : rem * take out "goto 202" !
 if $60=score[2] then score=score+940
216 drawscreen

 

I tested it, and it works. :)

 

#2: Is there any way to hack into the score display to make the fourth 0 from the left look like a colon?

 

This is trickier. Again, SpiceWare's answer was correct. However, you don't need to do anything to make bB interpret $A as a colon, because it will do that automatically once you add the data for the colon to the scoregraphics table. On the other hand, you *will* need to change the way you're doing mathematical operations with the score, since the nybble (half-byte) that's used for the fourth digit (the hundreds place) won't be a number anymore! And you'll also need to temporarily change the file that tells bB which includes to use ("default.inc"), so it uses your new score graphics instead of the standard score graphics.

 

I realize that a lot of this is over your head right now-- not to worry, be patient and persistent, and you'll understand it eventually (this stuff ain't rocket science, but it ain't a piece of cake, either!)-- so I've done it for you.

 

First, you need to add an eleventh character (":") to the score's character set. In bB 0.99, the score's character set is in the "score_graphics.asm" file. You don't want to destroy the original file, so it'd be best to copy it, and rename the copy to something else, like "timer_score_graphics.asm". Then you can change the ORG and RORG statements at the beginning of "timer_score_graphics.asm," to move it down 8 bytes in memory (since you're going to be making scoretable 8 bytes longer), like this:

 

; feel free to modify the score graphics - just keep each digit 8 high
; and keep the conditional compilation stuff intact
ifconst ROM2k
  ORG $F7A4; was ORG $F7AC. $F7A4 is 8 bytes less than $F7AC.
else
  ifconst bankswitch; subtract 8 bytes from the addresses
 if bankswitch == 8
   ORG $2F9C-bscode_length; was ORG $2FA4-bscode_length
   RORG $FF9C-bscode_length; was RORG $FFA4-bscode_length
 endif
 if bankswitch == 16
   ORG $4F9C-bscode_length; was ORG $4FA4-bscode_length
   RORG $FF9C-bscode_length; was RORG $FFA4-bscode_length
 endif
 if bankswitch == 32
   ORG $8F9C-bscode_length; was ORG $8FA4-bscode_length
   RORG $FF9C-bscode_length; was RORG $FFA4-bscode_length
 endif
  else
 ORG $FFA4; was ORG $FFAC
  endif
endif

 

Then scroll to the bottom of the file and add the graphics for the new colon character to the end of scoretable, just above the ifs, like this:

 

   .byte %00111100; data for character "9"; leave it alone
   .byte %01000110
   .byte %00000110
   .byte %00111110
   .byte %01100110
   .byte %01100110
   .byte %01100110
   .byte %00111100

   .byte %00000000; data for new colon character
   .byte %00011000; it goes just after the data for "9"
   .byte %00011000
   .byte %00000000
   .byte %00000000
   .byte %00011000
   .byte %00011000
   .byte %00000000

ifconst ROM2k; Do not mess with any of this stuff at the end!
  ORG $F7FC
else

 

After you make these changes, save the modified "timer_score_graphics.asm" file.

 

Now you need to edit the "default.inc" file to use your new "timer_score_graphics.asm" file. Scroll down toward the bottom of the file and look for where it refers to the score graphics, then change it to look like this:

 

; score graphics.
; score_graphics.asm
timer_score_graphics.asm

 

Then save the modified "default.inc" file.

 

Finally, you must initialize the score so it has the colon in the fourth place. Then you must force the fourth place to always be $A for the colon. Each time you do math with the score, it will destroy the colon-- and the colon will interfere with the math-- so you want to remove the colon, do the math, and then put the colon back, like this:

 

200 score=0
 dim colon = score+1
202 t=t+1 : COLUP0=196
 colon = colon && $F0
 if t=60 then score=score+1 : t=0 : rem * take out "goto 202" !
 if $60=score[2] then score=score+940
 colon = colon || $0A
216 drawscreen
218 if joy0down then goto 220
219 goto 202

 

Save your program and compile it. I tested it, and it works! Just be sure that when you're all done, you change "default.inc" back to what it looked like originally.

 

I'm attaching all the files as I've changed them, for convenience, but I encourage you to try making the changes yourself to help it all sink in better. I couldn't attach files ending in ".inc" or ".asm," so I renamed "default.inc" to "default.txt," and "timer_score_graphics.asm" to "timer_score_graphics.txt." You'll need to rename them back after you download them.

 

Another approach to doing a timer in bB would be to forget about doing the colon, and leave the scoregraphics alone, but just change the spacing of the players for the score digits, so they're arranged like this:

 

  12  34  56

 

Then you can use the first two places for hours, use the middle two places for minutes, and use the last two places for seconds. :) That would mean changing the kernel include file to alter the way it spaces and positions the score characters, not to mention changing the timing for when bB loads and stores the players in the score. Maybe we'll try that in another post.

 

By the way, I'm glad you asked these questions, because otherwise I wouldn't have learned what I did while I was answering them. Now I know how to use the score to do a six-item inventory strip, with up to 16 different items to choose from! :cool:

 

Michael Rideout

default.txt

timer_score_graphics.txt

timer_question.bas

timer_question.bas.bin

Link to comment
https://forums.atariage.com/topic/90315-making-a-timer/#findComment-1097927
Share on other sites

aarrgh - darn typos! that's what I get for answering late at night after a full day of fun with my nephews :lol:

 

thanks for fleshing out the answer to #2. I didn't want to stay up any later.

Edited by SpiceWare
Link to comment
https://forums.atariage.com/topic/90315-making-a-timer/#findComment-1097988
Share on other sites

Wow, thanks a lot, Michael! Now there's a timer for the 2600. The colon looks absolutely perfect.

 

"By the way, I'm glad you asked these questions, because otherwise I wouldn't have learned what I did while I was answering them. Now I know how to use the score to do a six-item inventory strip, with up to 16 different items to choose from!"

 

Do you have a game idea in mind after Sudoku is done?

Link to comment
https://forums.atariage.com/topic/90315-making-a-timer/#findComment-1098057
Share on other sites

aarrgh - darn typos! that's what I get for answering late at night after a full day of fun with my nephews :lol:

 

Hey, I had to look at bB's kernel source to be sure I was using the right byte/index for the last two digits of the score. And then I had to reread atari2600land's original post twice because I had just glanced at it quickly the first time, then merrily proceeded to write up an example and an answer that did *NOT* do what he said he wanted to do. So I had to scrap all that and start over. :D

 

thanks for fleshing out the answer to #2.

 

I would have sworn it was going to be necessary to change the way the kernel handles the score-- but after I explained about copying the two kernels and renaming them to "timer_std_kernel.asm" and "timer_multisprite_kernel.asm" (and actually did that myself), then opened up the kernel and scrolled down to modify the code, I saw the use of Y as the index (d'oh, of course!), and realized that bB doesn't give a hoot what's in Y, so I had to change my answer in mid post AGAIN, to remove all the unnecessary talk about copying and changing the kernels! This is why the score graphics can get munged-up if the score's bytes ever contain non-BCD values in them-- and this will also make it a snap to use bB's score to do things like display an 8-line tall title or copyright message at the bottom of the screen, or a six-item inventory strip using any of up to 16 different items, etc. You don't even have to change bB-- just define a data table in your bB program for the game title, inventory items, etc., then dim three variables to the three bytes that store the score pointers so you can point them wherever you want, and then just don't do any assignments or math with the score. I think that should work with no problem.

 

Hang on, now that I think about it, it should be possible to choose from up to 256 different items for an inventory strip, since Y can be 0 to 255, and the score pointers point to an entire byte, not to a nybble. (D'oh again!) I haven't checked bB's routines, but I know there's a place where it converts the nybbles of the score into addresses for the score pointers, so it might be necessary to modify that section-- or it might be possible to just override that stuff on every frame by setting the score pointers manually just before calling drawscreen. I'll do some examples later and post them.

 

I didn't want to stay up any later.

 

I got like 3.5 hours of sleep Thursday night after going to the midnight showing of Pirates 2, so I had to take a 3-hour nap when I got home from work. Then after I got up after my nap, I still wasn't able to stay up all night and work on Sudoku like I'd planned. Sleep is *GOOD*! Considering how hard it is to talk myself into getting out of bed in the morning, I don't know why it's always so hard to make myself go to bed at night! :)

 

I hope you're having fun with your nephew, by the way. You're helping him learn Atari 2600 game programming, right? I don't think my youngest nephew is old enough to handle that yet, at least not the bB coding and program logic. It will be fun to help him learn 2600 programming in a few more years. In the meantime, he can help with designing the games. I'll have to set up bB on my dad's computer to see how much my nephew is able to absorb about programming while he's staying with my parents this summer.

 

Michael Rideout

Link to comment
https://forums.atariage.com/topic/90315-making-a-timer/#findComment-1098063
Share on other sites

Wow, thanks a lot, Michael! Now there's a timer for the 2600. The colon looks absolutely perfect.

 

You're welcome, and thank you for the compliment about the look of the colon. It was hard to design the way a colon should look. :ponder: Just kidding, of course! :D

 

Do you have a game idea in mind after Sudoku is done?

 

Well, I REALLY need to go back and work on "Reventure" some more, because I sort of abandoned it last year, but I definitely want to finish it. And eventually I want to get back to my grandiose "Quest for the Lost Pyramids of Atlantis" game trilogy. Adventures are just about my favorite type of game.

 

But before I get too wrapped up in making games, I also need to resume working on the bB tutorial I started. I've decided to postpone several of the early installments I'd planned (the TV picture, the Atari's features, the Atari's memory map, a crash course in programming, designing a game, etc.), and just go directly into bB programming to help people jump in and get their feet wet. Then I can go back later and post the "missing" installments. And I can always update installments after they've been posted-- in fact, I'll absolutely need to. For example, I should post an addendum to some of the existing installments, to talk about upgrading from one version of bB to another, or installing a newer version of an emulator-- not to mention, we now have another bB code editor to choose from.

 

I'm wondering if I should get the latest unposted bleeding-edge build of bB from batari so I can talk about it in the tutorial, or if it would be better to wait until it's posted for anyone to download and then just update any tutorial installments as needed? I'm using 0.99 for the tutorial, because it's available from batari's blog, but it isn't even "officially" released yet. Are most people using 0.35 or 0.99, I wonder? Which version are *you* using?

 

Michael Rideout

Link to comment
https://forums.atariage.com/topic/90315-making-a-timer/#findComment-1098074
Share on other sites

How come the latest bleeding-edge hasn't been posted yet?

 

I think batari is afraid that (1) it contains too many bugs right now, and (2) any future bug-fixes to it may conceivably "break" a program that was written with it.

 

http://www.atariage.com/forums/index.php?s...t&p=1093212

 

Michael Rideout

Link to comment
https://forums.atariage.com/topic/90315-making-a-timer/#findComment-1098108
Share on other sites

I hope you're having fun with your nephew, by the way. You're helping him learn Atari 2600 game programming, right? I don't think my youngest nephew is old enough to handle that yet, at least not the bB coding and program logic. It will be fun to help him learn 2600 programming in a few more years. In the meantime, he can help with designing the games. I'll have to set up bB on my dad's computer to see how much my nephew is able to absorb about programming while he's staying with my parents this summer.

 

I had a lot of fun. Saw a number of relatives I hadn't seen in a while, got up on a wake board(harder than it looks), and all sorts of other stuff. We worked on his game Wednesday thru Friday, spending about 4-5 hours each day on it. It was harder than he expected, though we got farther along than I thought we would. I don't know if he'll do anything else with it, only time will tell.

 

Anyhow I'm heading off to bed, sure to have a busy day at work tomorrow.

Link to comment
https://forums.atariage.com/topic/90315-making-a-timer/#findComment-1098923
Share on other sites

  • 3 months later...

Sorry to revive a dead thread here, but what if you wanted to add 2 sprites to the score counter? I put in the bytes

.byte %111 whatever

 

and I guess what I need to know is what hexadecimal number I need to replace $F7A4 & $FFA4 with in the score_graphics.asm file. I tried $F7BC and $FFBC and that was completely wrong (my math is probably wrong here.)

Link to comment
https://forums.atariage.com/topic/90315-making-a-timer/#findComment-1154120
Share on other sites

Sorry to revive a dead thread here, but what if you wanted to add 2 sprites to the score counter? I put in the bytes

.byte %111 whatever

 

and I guess what I need to know is what hexadecimal number I need to replace $F7A4 & $FFA4 with in the score_graphics.asm file. I tried $F7BC and $FFBC and that was completely wrong (my math is probably wrong here.)

I think this should be right:

 ifconst ROM2k
  ORG $F79C; was ORG $F7AC. $F79C is 16 bytes less than $F7AC.
 else
  ifconst bankswitch; subtract 16 bytes from the addresses
 if bankswitch == 8
   ORG $2F94-bscode_length; was ORG $2FA4-bscode_length
   RORG $FF94-bscode_length; was RORG $FFA4-bscode_length
 endif
 if bankswitch == 16
   ORG $4F94-bscode_length; was ORG $4FA4-bscode_length
   RORG $FF94-bscode_length; was RORG $FFA4-bscode_length
 endif
 if bankswitch == 32
   ORG $8F94-bscode_length; was ORG $8FA4-bscode_length
   RORG $FF94-bscode_length; was RORG $FFA4-bscode_length
 endif
  else
 ORG $FF9C; was ORG $FFAC
  endif
 endif

MR

Link to comment
https://forums.atariage.com/topic/90315-making-a-timer/#findComment-1154220
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...