Jump to content
IGNORED

Vertical Scrolling Question


Recommended Posts

After many aborted attempts I'm at last getting into assembler[*] with MAC/65 and working on my first game, no not part of the Gwobby legacy :D [sighs of relief]. I'm working on a vertical scrolling game the routine I have adapted works ok (I'm scrolling the playfield upwards)...

 

I'm probably doing something entirely wrong here but it's fun learning:

The scroll routine was using VB1 for some reason so I moved it to VB2 and it works ok, but after years of squeezing out every nanocock of speed in BASIC it's still way too fast! So I noticed in (the excellent) "Assembly Language Programmer's Guide" [Moose&Lorenz] (Ch.6), the mention of System Timer 2 (CDTMV2)...

 

...I point CDTMA2 to the former VB code loop and store something in the timer to start it but seem to be locking up. How do I exit from the VB code using System Timer 2? (There is an exit for the VBI1/2 routines but I can't see a mention of one for Timer 2) - OR - does this operate in a different way and I should be combining my code in a single loop rather than a loop for the game and a separate loop for my VB code [hope that makes sense]

 

Are there other ways of slowing down the scrolling in VB2?

 

Thanks :)

 

[*] Anyone else starting out I'd say the Analog mags listings are a good place to start, the code has lots of comments. After reading lots fo the books and looking at several routines I decided a new approach this time and did same as I did when I learned BASIC: by amending other peoples code and seeing what was what. I've gone for running [testing] the game outside the assembler environment, bit of a pain but less memory conflicts and constraints to worry about. (suppose I could try the file version of MAC/65 to save changing the cartridge). Anyway I seem to be well into it now so fingers crossed I will come up with a game for this years abbuc contest :)

Link to comment
Share on other sites

OS software timers the exit is just via RTS.

 

The timers are of limited value. Timer 1 is best but the OS uses it for SIO so exclusive use isn't guaranteed.

 

The others are much less usable because the processing is done in Stage 2 VBlank. Problem there is that Stage 2 is often disabled, e.g. if SIO occurring or something as simple as an IRQ being processed and interrupted by VBlank, key press being common occurrence.

 

The trick with scrolling, moving PM, anything in VBlank - just use a fractional movement calculation system, that allows for a wide range of velocities.

Link to comment
Share on other sites

I was surprised to find out you allowed to reuse timer 1 whenever you're not using SIO -- turns out this is guaranteed in Appendix L, H27 of the OS manual. I found this out the hard way when working on my replacement OS and Cross Town Crazy Eight blew up because it did so.

Edited by phaeron
Link to comment
Share on other sites

It depends how you implement the scrolling - if simply moving a window over a pre-rendered "world" then it's somewhat easier.

 

An example of fractional scrolling, you use a 2 byte value for velocity - either add or subtract the velocity from a larger "pointer" value to determine the window origin and VSCROL value.

Use masking and shifting to work out what VSCROL/LMS values need to be plugged in. Horizontal scrolling is slightly more work in that the HSCROL values work back to front vs VSCROL and you usually have multiple LMS instructions that need modifying.

 

Advantage of fractional velocity vs stuff like delay counters is that you get a much larger range of values available. You can do smooth acceleration and also use it to implement inertia to objects.

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...