Jump to content
IGNORED

Issue with Infinite scrolling and calculating playfield position


Recommended Posts

I am trying to do infinite scrolling in text mode. The idea is that screen is larger (twice)

MAXWIDTH = 96

This is my DLI definition:

dl_start
    dta DL_BLANK8 + DL_DLI                                                   
    dta DL_MODE_40x24T2 + DL_HSCROLL + DL_LMS, a(SCREEN_GAME)
    dta DL_MODE_40x24T2 + DL_HSCROLL + DL_LMS, a(SCREEN_GAME + (MAXWIDTH * 1))
    dta DL_MODE_40x24T2 + DL_HSCROLL + DL_LMS, a(SCREEN_GAME + (MAXWIDTH * 2))
    dta DL_MODE_40x24T2 + DL_HSCROLL + DL_LMS, a(SCREEN_GAME + (MAXWIDTH * 3))
    dta DL_MODE_40x24T2 + DL_HSCROLL + DL_LMS, a(SCREEN_GAME + (MAXWIDTH * 4))
    dta DL_MODE_40x24T2 + DL_HSCROLL + DL_LMS, a(SCREEN_GAME + (MAXWIDTH * 5))
    dta DL_MODE_40x24T2 + DL_HSCROLL + DL_LMS, a(SCREEN_GAME + (MAXWIDTH * 6))
    dta DL_MODE_40x24T2 + DL_HSCROLL + DL_LMS, a(SCREEN_GAME + (MAXWIDTH * 7))
    dta DL_MODE_40x24T2 + DL_HSCROLL + DL_LMS, a(SCREEN_GAME + (MAXWIDTH * 8))
    dta DL_MODE_40x24T2 + DL_HSCROLL + DL_LMS, a(SCREEN_GAME + (MAXWIDTH * 9))
    dta DL_MODE_40x24T2 + DL_HSCROLL + DL_LMS, a(SCREEN_GAME + (MAXWIDTH * 10))
    dta DL_MODE_40x24T2 + DL_HSCROLL + DL_LMS, a(SCREEN_GAME + (MAXWIDTH * 11))
    dta DL_MODE_40x24T2 + DL_HSCROLL + DL_LMS, a(SCREEN_GAME + (MAXWIDTH * 12))
    dta DL_MODE_40x24T2 + DL_HSCROLL + DL_LMS, a(SCREEN_GAME + (MAXWIDTH * 13))
    dta DL_MODE_40x24T2 + DL_HSCROLL + DL_LMS, a(SCREEN_GAME + (MAXWIDTH * 14))
    dta DL_MODE_40x24T2 + DL_HSCROLL + DL_LMS, a(SCREEN_GAME + (MAXWIDTH * 15))
    dta DL_MODE_40x24T2 + DL_HSCROLL + DL_LMS, a(SCREEN_GAME + (MAXWIDTH * 16))
    dta DL_MODE_40x24T2 + DL_HSCROLL + DL_LMS, a(SCREEN_GAME + (MAXWIDTH * 17))
    dta DL_MODE_40x24T2 + DL_HSCROLL + DL_LMS, a(SCREEN_GAME + (MAXWIDTH * 18))
    dta DL_MODE_40x24T2 + DL_HSCROLL + DL_LMS, a(SCREEN_GAME + (MAXWIDTH * 19))
    dta DL_MODE_40x24T2 + DL_HSCROLL + DL_LMS, a(SCREEN_GAME + (MAXWIDTH * 20))
    dta DL_BLANK8                                      
    dta DL_BLANK8 + DL_DLI
    dta DL_MODE_40x24T2 + DL_LMS, a(SCREEN_BOTTOM)
    dta DL_JVB, a(dl_start)

 

If I want to put character in visible part of the screen (while I am not scrolling the screen) I am having trouble. I have determined that I can put character within X position between 4 and 43.

That leads to the problem to write a procedure to calculate sprite collision.

 

    cx:=43;
    cy:=20;
    
    addresscalc:=SCREEN_GAME + row_max[cy] + cx;
    // addresscalc:=SCREEN_GAME  + cy * 96 + cx;
    Poke(addresscalc, SWARN);

 

SWARN is a const for character #. As you can see cx=43 draws almost to the right. There is 1 character to the right, same situation is on left when I draw at cx=4.

That is problematic when I try to understand and modify playfield after sprite and playfield collision.

The question is how should I organize screen and calculate position from pixels to character position in playfield?

 

I was trying to calculate cx and cy with

 cx:= ((missle_x - 48) div 4);
 cy:= ((missle_y - 48 ) div 4);

 

image.thumb.png.ae4cf39c004cf5cc339aba10f52a22f5.png

 

Edited by MADRAFi
Link to comment
Share on other sites

As you've turned on horizontal scroll in each charline, you're screen char position will be influenced by value of hscroll register too.

I'm usually using values for HSCROL in range between 12..15, that makes screen coords make sense the most :)

 

When you turn on horizontal scroll, antic automatically fetches +8 chars then mode you're in. I assume you're using 40 char wide normal screen ?
In that case Antic works like if it's in 48-wide mode. That means HSCROL value 0 will mean screen will be shifted entirely to the left side of 48 wide area.

In 48 wide mode HPOS==$20 of pm gfx is aligned to left side of screen.

So if you put value 12 into HSCROL register, screen will be shifted right 3 chars (3x4=12).

That means that first visible char will be (SCREEN+1)

Now, when you change HSCROLL to 13,14,15, parts of char at (SCREEN+0) will appear from left.

 

You just have to experiment and see what suits you the best imho.

Iterate and enjoy the process :)

 

 

  • Like 1
Link to comment
Share on other sites

yes I am using normal mode.

okey but that does not explains how visible area for sprite that travels between 48 and 200 for x,  24 and 170 for y should be translated to cx and cy.

I am not scrolling yet so hpos is not changing.

 

Lets say collision was detected when player sprite collided playfield character at playerx=200 and playery=160. I think I am missing how these pixel should be translated into char position :)

 

 

Link to comment
Share on other sites

You're not scrolling, but you did turn on HSCROL in display list for each char row.
That means you have take in account value of HSCROL register. Is it maybe zero ?

 

Second question - is "missle_x" value of HPOS hardware register for player or missile ?


ps. Send me xex file and I'll tell you exact formula for char vs pm pos.

 

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