+therealbountybob Posted February 23, 2013 Share Posted February 23, 2013 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 [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 Quote Link to comment Share on other sites More sharing options...
phaeron Posted February 23, 2013 Share Posted February 23, 2013 OS timer 1 and 2 callback routines just exit with RTS. Quote Link to comment Share on other sites More sharing options...
Rybags Posted February 23, 2013 Share Posted February 23, 2013 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. Quote Link to comment Share on other sites More sharing options...
phaeron Posted February 23, 2013 Share Posted February 23, 2013 (edited) 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 February 23, 2013 by phaeron Quote Link to comment Share on other sites More sharing options...
snicklin Posted February 23, 2013 Share Posted February 23, 2013 Half of what is above is way too technical for me, but the way that I slow things down is by increasing a counter value and when it hits a specific value, set it back to 0 and then do the action that needs doing (i.e. scrolling in this case) Quote Link to comment Share on other sites More sharing options...
Rybags Posted February 24, 2013 Share Posted February 24, 2013 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. Quote Link to comment Share on other sites More sharing options...
MaPa Posted February 24, 2013 Share Posted February 24, 2013 If you need simple slow down like 2x, 4x etc. you can use RTCLOCK like this: lda $14 and #1 ;1 for half speed, 2 for quarter speed... bne noscroll ... here is your scroll routine Quote Link to comment Share on other sites More sharing options...
+therealbountybob Posted February 25, 2013 Author Share Posted February 25, 2013 Thanks for the info guys I will report back Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.