Jump to content
IGNORED

Endless scrolling, making an end?


Retro Lord

Recommended Posts

I'm done with the first level of my little Adventure Island tribute, and I'm thinking of a way to make the level end. I'm thinking of having the levels last 5 minutes, and when you have survived for 5 minutes an exit sign appears that leads to the next stage. How many frames would there be in 5 minutes?

 

I was thinking of calculating it something like this:

 r=r+1

 if r=255 then q=q+1 : r=0

 if q=60 then goto LEVEL_2
Link to comment
Share on other sites

Depends if you're making an NTSC or PAL game.

  • NTSC = 5 minutes * 60 seconds per minute * 60 frames per second = 18,000 frames
  • PAL = 50 minutes * 60 seconds per minute * 50 frames per second = 15,000 frames

A byte value will automatically wrap from 255 to 0, so no need to manually reset r to 0.

Link to comment
Share on other sites

Here is one way to do it for NTSC and PAL60 if I didn't screw up the math:

 

   dim _Counter1 = a
   dim _Counter2 = b


   ;***************************************************************
   ;
   ;  New level check.
   ;
   ;```````````````````````````````````````````````````````````````
   ;  Increments _Counter1.
   ;
   _Counter1 = _Counter1 + 1

   ;```````````````````````````````````````````````````````````````
   ;  _Counter1 resets every 4 seconds (60 * 4 = 240).
   ;
   if _Counter1 < 240 then goto __Skip_5_Min_Check

   ;```````````````````````````````````````````````````````````````
   ;  Clears _Counter1 after 4 seconds have gone by.
   ;
   _Counter1 = 0

   ;```````````````````````````````````````````````````````````````
   ;  _Counter2 increments every 4 seconds.
   ;
   _Counter2 = _Counter2 + 1

   ;```````````````````````````````````````````````````````````````
   ;  If _Counter2 reaches 75 (4 seconds x 75 = 5 minutes),
   ;  program jumps to __LEVEL_2.
   ;
   if _Counter2 > 74 then goto __LEVEL_2

__Skip_5_Min_Check
Link to comment
Share on other sites

That works, though it'll take less ROM and CPU time if you utilize the automatic wrap to 0 to your advantage:

 

counter1 = counter1 + 1

if counter1 then skip_check ; skip if counter1 is not 0

counter2 = counter2 + 1

; 18000 frames / 256 = 70
if (counter2 >= 70) then goto level2

skip_check
I'm not sure if bB does the implicit check for non-zero. If it doesn't, the counter1 test would need to be

 if counter1 > 0 then skip_check
  • Like 1
Link to comment
Share on other sites

using >= in assembly should be more efficient than >

 

Compare sets flags as if a subtraction had been carried out. If the value in the accumulator is equal or greater than the compared value, the Carry will be set. The equal (Z) and sign (S) flags will be set based on equality or lack thereof and the sign (i.e. A>=$80) of the accumulator.

a >= check only needs to worry about the state of C

 

test:
  cmp #70
  bcc Skip ;C is set if Greater Than or Equal To 70
  ; >= 70 logic here
Skip:
while a > check needs to worry about C and Z.

test:
  cmp #69
  bcc Skip ; C is clear if Less Than 69
  beq Skip ; Z is set if Equal To 69
  ; > 69 logic here

Skip:
It's possible bB is written in a way that makes > more efficient than >=
  • Like 1
Link to comment
Share on other sites

They produce basically similar code

.L00 ; if a >= 70 then skip

 LDA a
 CMP #70
 bcs .skip
.
 ; 

.L01 ; if a > 69 then skip

 LDA #69
 CMP a
 bcc .skip
.



another way to do the timer

timer will rollover at 256
and .01 is actually .78125
ie .01 gets rounded to 2/256

 dim timer = counter1.counter0

 
 counter1 = 115


 timer = timer + 0.01


 if !counter1 then next_level

Link to comment
Share on other sites

I shouldn't post this stuff when I'm tired

In the cold light of day..

It's more straight forward to make the timer
count down

.01 rounds to .0078125

I chose that because it gives you the closest
to 5 minutes while only setting one variable
(I think)

 
  dim timer = counter1.counter0

 
 counter1 = 142

 timer = timer - 0.01


 if !counter1 then next_level
Edited by bogax
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...