Jump to content

Photo

Smooth Vertical Scrolling from DATA (Want 4-way)


41 replies to this topic

#26 bogax OFFLINE  

bogax

    Dragonstomper

  • 761 posts

Posted Sat Nov 4, 2017 6:05 AM

If you want to see how I did horizontal scrolling in Princess Rescue, just go to Random Terrain's Batari site, and he has my source code for it there, along with added documentation.  You can find how I did my scrolling in there with the ScrollLeft and ScrollRight routines.  I did use pfhscroll, but with some added code.  When new data needed to show up, it would look at the new data I had in the level data table, using a pointer, to pick up the 2 new bytes, and then it would compare bit by bit with what the var screen variables had on the edge of the screen.  If it didn't match up, it would flip the bit, saving time so it didn't redraw every bit on the edge of the screen.

 

(I haven't looked at your code) (yet)

 

hmm.

 

I wonder if it would be useful to store the data as sort of a table of difs or deltas (or whatever you'ld call them)

then just flip a bit if necessary, depending on what's in the table



#27 Sprybug OFFLINE  

Sprybug

    Dragonstomper

  • 562 posts

Posted Sun Nov 5, 2017 5:21 AM

 

(I haven't looked at your code) (yet)

 

hmm.

 

I wonder if it would be useful to store the data as sort of a table of difs or deltas (or whatever you'ld call them)

then just flip a bit if necessary, depending on what's in the table

 

I'm not sure what you mean by that exactly.  The level data is simply like this.  Every 2 bytes represent the playfield from the top to the bottom vertically.  Since Batari's resolution is 11 rows (12 if you count the invisible one, that I don't use).  This leaves 5 extra bits that I use for enemy/object spawn in information.  So the first byte is row 0 to row 7.  So if one of this bits is on, on the screen (held in the varxx variable), that playfield block will be on, and if that new data shows that one bit in that one row is off, then it'll flip it or vice versa (it's off on the screen and will be flipped to be on). If it's the same then don't do anything.  There's no need to.  The first 3 bits of the second byte represent rows 8-10 and you repeat the same checks.



#28 bogax OFFLINE  

bogax

    Dragonstomper

  • 761 posts

Posted Sun Nov 5, 2017 9:07 AM

 

I'm not sure what you mean by that exactly.

 

I'm not sure exactly what I mean either (and, again, I haven't had a chance to look at your code)

 

And I'm just sorta thinking out loud.

 

from your description:

 


When new data needed to show up, it would look at the new data I had in the level data table, using a pointer, to pick up the 2 new bytes, and then it would compare bit by bit with what the var screen variables had on the edge of the screen.

 

What I'm thinking is rather than doing a comparison just have the level data table indicate if a bit needs flipping (build the results of the comparison into the table)

I wouldn't bet that that would save you anything I'm just wondering if it could.



#29 Sprybug OFFLINE  

Sprybug

    Dragonstomper

  • 562 posts

Posted Mon Nov 6, 2017 5:25 AM

 

I'm not sure exactly what I mean either (and, again, I haven't had a chance to look at your code)

 

And I'm just sorta thinking out loud.

 

from your description:

 

 

 

What I'm thinking is rather than doing a comparison just have the level data table indicate if a bit needs flipping (build the results of the comparison into the table)

I wouldn't bet that that would save you anything I'm just wondering if it could.

 

I think I see where you are going with this, and it might work well if it scrolled in one direction and didn't go back, but with my games they scroll in both directions, which would mean when the data going the other way would have to be different to compensate, which would probably add to the size of the tables, sacrificing ROM space to gain a few CPU cycles.  I know this is a constant game you play with programming on the Atari 2600.  Sometimes you need more CPU cycles, and since you got the ROM space, do some pre-calculations so the CPU doesn't have to.  And sometimes you need more ROM space, so you let the CPU do a little more work to produce the data you need.  I tend to do one or the other depending on what's on my plate.  It's a very delicate balancing act, that's for sure!



#30 Gemintronic OFFLINE  

Gemintronic

    Jason S. - Lead Developer & CEO

  • Topic Starter
  • 8,945 posts

Posted Mon Nov 6, 2017 10:34 AM

Since this topic is still active I may as well post a demonstration video.  Mr SQL reported that the engine is going over cycle, though.

 



#31 Sprybug OFFLINE  

Sprybug

    Dragonstomper

  • 562 posts

Posted Mon Nov 6, 2017 4:24 PM

Since this topic is still active I may as well post a demonstration video.  Mr SQL reported that the engine is going over cycle, though.

 

 

Impressive!

I'd love to see the code on how you did it.  4 way scroll would be great for games I'd like to make!



#32 Mr SQL ONLINE  

Mr SQL

    Stargunner

  • 1,906 posts

Posted Mon Nov 6, 2017 5:58 PM

Macky Man is awesome! :)  If there were a hack to bB to allow access to the other vertical blank there's probably enough time left over there to split the scroll routines up to fit.



#33 bogax OFFLINE  

bogax

    Dragonstomper

  • 761 posts

Posted Sun Nov 19, 2017 3:17 PM

Here's code for 32 byte x 32 byte world

Not sure it's really useful it, doesn't leave much room for code or time to run it

 

There's also a crude world editor

It runs in Opera and Firefox

I'd be curious if any one else can get it to run (and what browser you tried it with)

 

The clear button doesn't do anything

The flip button cycles through flip, on and off

The left arrow buttons move the cursor (there's no other indication where it is though)

The right arrows scroll the world data around

You can also click on the world canvas

The colors just set the colors and display a corresponding hex value (lifted from RT's page)

The little text box is the name for the data statements if you change it you'll have to change

  lines 44, 45 in the code to match

There's no way to save the world data (I should probably fix it so you can put the data statements back in)

 

You should be able to just copy the data statements into the code and adjust lines 44, 45 if necessary

 

Attached Files



#34 Lewis2907 OFFLINE  

Lewis2907

    Chopper Commander

  • 228 posts
  • Location:Senatobia, MS

Posted Sun Nov 19, 2017 8:40 PM

Bogax,

Thanks I plan to give a try and see what I can learn and use.

 

***Edited***

 

Well I was (still am excited about the code). Assembly is way over what I know. But anyways I was trying to slow down the screen movement and have a sprite move around. I figure if you can do that then you can make something open world per say. Maybe Bogax can work his magic again.  I did start to add remarks where I think they should go to explain what is going on to help other novice programmers like me. 

Attached Files


Edited by Lewis2907, Mon Nov 20, 2017 5:31 PM.


#35 bogax OFFLINE  

bogax

    Dragonstomper

  • 761 posts

Posted Sun Nov 26, 2017 9:17 PM

Here's an augmented version of the 32 x 32 world editor

 

You can paste data into the text box and put it in the editor

  it looks for the first 1024 numbers in the form $xx where the xx are hex digits

  and it pads with 0 if there aren't 1024

 

The clear button works.

 

There's a rudimentary undo.  It saves the undo data when you click on the

  canvas or input data but not if you're moving the cursor or the world with

  the arrow buttons.

 

You can load a picture into the world canvas.  So you can do your editing

  in your favorite graphics editor and convert it to data statements.

  It takes the upper left pixel as the background color, any other color

  is a playfield pixel.

 

It seems to work in Opera, the picture loading doesn't work too well in

 (an older version of) Firefox and it doesn't work at all in IE.

  I haven't tryed it in Chrome yet. 

Attached Files


Edited by bogax, Sun Nov 26, 2017 9:20 PM.


#36 Lewis2907 OFFLINE  

Lewis2907

    Chopper Commander

  • 228 posts
  • Location:Senatobia, MS

Posted Tue Nov 28, 2017 4:30 PM

Bogax,

Thanks I plan to give a try and see what I can learn and use.

 

***Edited***

 

Well I was (still am excited about the code). Assembly is way over what I know. But anyways I was trying to slow down the screen movement and have a sprite move around. I figure if you can do that then you can make something open world per say. Maybe Bogax can work his magic again.  I did start to add remarks where I think they should go to explain what is going on to help other novice programmers like me. 

The World Editor works in Chrome, but stops at "data world_data27". I was able to get the sprite working / moving. Still working on slowing down the "movement of the screen".

 

I also tried to use bank switch from 8K to 32K and no luck. I think that is what Bogax was talking about "Not sure it's really useful it, doesn't leave much room for code or time to run it". Attached is where I made some progress, thanks.

 

***edited***

 

I was able to slow down the screen movement using the technique that Gemintronic  used for his " RRatRace2.bas". Now I just have to figure out how to make this bank switch to have more data. If that is possible I think a gosub into another bank may work to add enemy AI, Sprites, and maybe more data for other worlds (other worlds maybe a stretch for now.)

Attached Files


Edited by Lewis2907, Tue Nov 28, 2017 7:24 PM.


#37 bogax OFFLINE  

bogax

    Dragonstomper

  • 761 posts

Posted Wed Nov 29, 2017 7:41 PM

Hmm

 

I got a chance to try it in Chrome today and it seemed to work just fine

except I couldn't scroll the page and the end of the text box was hanging off the screen

where I couldn't get at it, but the data was ok.

 

here's it's fixed for Firefox

 

 

Attached Files



#38 Lewis2907 OFFLINE  

Lewis2907

    Chopper Commander

  • 228 posts
  • Location:Senatobia, MS

Posted Fri Dec 1, 2017 1:41 PM

Bogax,

 

Thanks for the clarification. I did get it to work and I made something to show what I think can be done using your code and others in the forum. My coding style is to combine others and make it work the best I can. Someone once said I program in the old Basic style and that is true. The ASM and other stuff I see everyone do is above what I can do now. Anyways this is what I have so far. Tried to get it bank switch for 8k and up. 8kSC does some weird screen things. Any thoughts on how to make the other bank would be great. I maybe able to make something that is fun, thanks. 

 

   ;```````````````````````````````````````````````````````````````
   ;
   ;  Instructions:
   ; 
   ;  Use the joystick to move the sprite maze
   ;  Use Reset Switch to Reboot game
   ;  Player starts with 2000 points
   ;  Navigate maze and don't touch ghost.
   ;  Once you hit zero points game will reboot
   ; 
   ;```````````````````````````````````````````````````````````````

 

***Edit***

 

I did try to compare Gemintronic's 4 Way as his code will bank switch. They are similar I think but vastly different as well.

Attached Files


Edited by Lewis2907, Fri Dec 1, 2017 1:44 PM.


#39 bogax OFFLINE  

bogax

    Dragonstomper

  • 761 posts

Posted Sun Dec 3, 2017 1:47 PM

I didn't have too much trouble getting the scrolling code to run in a different bank

you have to make sure all the routines are present and not use a bank switching return

(both the bank switching and the scroll routines use the x register, I expect there's

interference there but I didn't try to figure out what/where)

 

in principle at least, you could fill all the banks with world data and scroll around

a 512 x 380 (pf)pixel world (or something, I'd keep x an integral factor of 256 bytes)

the coding might get a little hairy but it wouldn't be THAT bad


Edited by bogax, Sun Dec 3, 2017 1:49 PM.


#40 Lewis2907 OFFLINE  

Lewis2907

    Chopper Commander

  • 228 posts
  • Location:Senatobia, MS

Posted Mon Dec 4, 2017 11:08 AM

I didn't have too much trouble getting the scrolling code to run in a different bank

you have to make sure all the routines are present and not use a bank switching return

(both the bank switching and the scroll routines use the x register, I expect there's

interference there but I didn't try to figure out what/where)

 

in principle at least, you could fill all the banks with world data and scroll around

a 512 x 380 (pf)pixel world (or something, I'd keep x an integral factor of 256 bytes)

the coding might get a little hairy but it wouldn't be THAT bad

Bogax,

 

Thanks again. I am trying what you stated. I did remove the bank switching. I have attached what I did, still not working. I am sure I missed the mark somewhere. I am not even sure what the "X Register" is to start. Are you able to fix the code attached for bank switching? Thanks in advance for any help you can provide. 

 

My next attempt will be if this can port over to Multiprite or DPC. Not sure if that is possible, but it's worth a try. 

Attached Files



#41 bogax OFFLINE  

bogax

    Dragonstomper

  • 761 posts

Posted Mon Dec 4, 2017 6:53 PM

Here I've moved the scroll routines (including the f_ind routine that the fwbyte macro uses)

to bank 2 and fixed the returns.

 

I did the pfread in bB so there wouldn't be a lot of bank switching going on.

 

Seems to work.

 

It could undoubtedly be cleaned up or streamlined some.

 

 

 

 

 

Attached Files



#42 Lewis2907 OFFLINE  

Lewis2907

    Chopper Commander

  • 228 posts
  • Location:Senatobia, MS

Posted Wed Dec 6, 2017 3:03 PM

Here I've moved the scroll routines (including the f_ind routine that the fwbyte macro uses)

to bank 2 and fixed the returns.

 

I did the pfread in bB so there wouldn't be a lot of bank switching going on.

 

Seems to work.

 

It could undoubtedly be cleaned up or streamlined some.

 

 

 

 

 

Bogax,

 

Thanks for the code. Hopefully I can create something worth while to play on the FBP (Flashback Portable).






0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users