Jump to content

Photo

Setting/Detecting Screen Rotation


26 replies to this topic

#1 bhall408 ONLINE  

bhall408

    Space Invader

  • 43 posts
  • Location:California

Posted Mon Feb 11, 2019 7:52 PM

When developing a lynx game that is intended to be played with the device rotated (Gauntlet for example), do you set a flag to indicate this to the hardware?

 

Or put in reverse, is there something the device looks for to auto-detect that a game is designed for rotated play?

 



#2 necrocia ONLINE  

necrocia

    Moonsweeper

  • 292 posts

Posted Mon Feb 11, 2019 8:14 PM

I couldn't see anything to do with rotating a screen. There is support for flipping a screen, but that's not what you're after.

Personally not a huge fan of rotated games, but I guess some like Klax work well.



#3 bhall408 ONLINE  

bhall408

    Space Invader

  • Topic Starter
  • 43 posts
  • Location:California

Posted Mon Feb 11, 2019 8:20 PM

I couldn't see anything to do with rotating a screen. There is support for flipping a screen, but that's not what you're after.

Personally not a huge fan of rotated games, but I guess some like Klax work well.

Yeah, you understand the question.

 

I want to know how (or if) the hardware was able to detect that Gauntlet/Klax/etc were rotated.

 

It is possible the answer is no, but I'm hoping there is a way...


Edited by bhall408, Mon Feb 11, 2019 8:20 PM.


#4 sage OFFLINE  

sage

    Dragonstomper

  • 981 posts
  • Location:Germany

Posted Mon Feb 11, 2019 9:27 PM

I think thye hardware relies on the mind of the player to notice that the game is to be played rotated. anyway, its unclear to me how the hardware should rotate the build-in screen or teh full device.



#5 42bs OFFLINE  

42bs

    Moonsweeper

  • 288 posts
  • Location:Germany/Southest West

Posted Mon Feb 11, 2019 11:35 PM

Yeah, you understand the question.

 

I want to know how (or if) the hardware was able to detect that Gauntlet/Klax/etc were rotated.

 

It is possible the answer is no, but I'm hoping there is a way...

 

No, it can't detect it. 1989, there were no MEMS gyroscopes or magnetic field sensors as you have in smart phones or tablets. At least, not for a reasonable price. So the Lynx can not detect its orientation or the change of.



#6 bhall408 ONLINE  

bhall408

    Space Invader

  • Topic Starter
  • 43 posts
  • Location:California

Posted Mon Feb 11, 2019 11:37 PM

 

No, it can't detect it. 1989, there were no MEMS gyroscopes or magnetic field sensors as you have in smart phones or tablets. At least, not for a reasonable price. So the Lynx can not detect its orientation or the change of.

 

 

I wasn't expecting that the Lynx could detect it's own orientation (which would be common for a modern phone/tablet).

 

What I am hoping, is that perhaps a memory location (register) is set to indicate that a cartridge is expected to be played in the "normal" vs "rotated" orientation.



#7 karri OFFLINE  

karri

    River Patroller

  • 2,561 posts
  • Location:Espoo, Finland

Posted Mon Feb 11, 2019 11:54 PM

For emulation there is a bit in the lnx header telling that the game is rotated. So it is possible to emulate the Lynx correctly on a large screen. But this lnx header is not part of the cart ROM. It is for emulators only.

 

        .segment "EXEHDR"
        .byte   'L','Y','N','X'                         ; magic
        .word   __BLOCKSIZE__                           ; bank 0 page size
        .word   0                                       ; bank 1 page size
        .word   1                                       ; version number
        .asciiz "Cart name                      "       ; 32 bytes cart name
        .asciiz "Manufacturer   "                       ; 16 bytes manufacturer
        .byte   0                                       ; rotation 1=left
                                                        ; rotation 2=right


#8 Nop90 OFFLINE  

Nop90

    Space Invader

  • 49 posts
  • Location:Italy

Posted Tue Feb 12, 2019 12:03 AM

Code can change screen orientation from righthaned to lefthanded (180 degrees rotation) , and (reading in the CC65 sources) this is traced by bit 3 in the SPRSYS register:

 

/* SPRSYS (read) $FC92 */
#define MATHWORKING     0x80
#define MATHWARNING     0x40
#define MATHCARRY       0x20
#define VSTRETCHING     0x10
#define LEFTHANDED      0x08
#define UNSAFE_ACCESS   0x04
#define SPRITETOSTOP    0x02
#define SPRITEWORKING 0x01

 

if you're referring to some game being rotated 90 degrees, I think it's only a screen setup from the developer, there is no hw setting for it.

 

But the .lnx file format has an extra header added for emulators that has a byte value that can inform the emulator to preset a 90 dgree rotation (0= no totation, 1= left rotation, 2 = right rotation).

 

Obviously this is only for emulaors, but it's a clue that there isn't the same information on the cart data or there wouldn't be ny need to add it in that header.



#9 42bs OFFLINE  

42bs

    Moonsweeper

  • 288 posts
  • Location:Germany/Southest West

Posted Tue Feb 12, 2019 12:11 AM

 

 

I wasn't expecting that the Lynx could detect it's own orientation (which would be common for a modern phone/tablet).

 

What I am hoping, is that perhaps a memory location (register) is set to indicate that a cartridge is expected to be played in the "normal" vs "rotated" orientation.

 

Nope, it's all up to the programmer. Even flipping is software driven. You do not have to respect the design guidelines as these are just _guidelines_.



#10 bhall408 ONLINE  

bhall408

    Space Invader

  • Topic Starter
  • 43 posts
  • Location:California

Posted Tue Feb 12, 2019 1:37 AM

if you're referring to some game being rotated 90 degrees, I think it's only a screen setup from the developer, there is no hw setting for it.

 

But the .lnx file format has an extra header added for emulators that has a byte value that can inform the emulator to preset a 90 dgree rotation (0= no totation, 1= left rotation, 2 = right rotation).

 

Obviously this is only for emulaors, but it's a clue that there isn't the same information on the cart data or there wouldn't be ny need to add it in that header.

 

 

Bingo!

 

That is what I was looking for.

 

The emulators I am using don't seem to implement it, but at least now I know it is possible.



#11 bhall408 ONLINE  

bhall408

    Space Invader

  • Topic Starter
  • 43 posts
  • Location:California

Posted Tue Feb 12, 2019 1:44 AM

 

For emulation there is a bit in the lnx header telling that the game is rotated. So it is possible to emulate the Lynx correctly on a large screen. But this lnx header is not part of the cart ROM. It is for emulators only.

 

        .segment "EXEHDR"
        .byte   'L','Y','N','X'                         ; magic
        .word   __BLOCKSIZE__                           ; bank 0 page size
        .word   0                                       ; bank 1 page size
        .word   1                                       ; version number
        .asciiz "Cart name                      "       ; 32 bytes cart name
        .asciiz "Manufacturer   "                       ; 16 bytes manufacturer
        .byte   0                                       ; rotation 1=left
                                                        ; rotation 2=right

 

 

Thanks for the header definition...

 

The name/manufacturer fields are also useful...



#12 sage OFFLINE  

sage

    Dragonstomper

  • 981 posts
  • Location:Germany

Posted Tue Feb 12, 2019 5:38 AM

 

Thanks for the header definition...

 

The name/manufacturer fields are also useful...

The implementation in most emulator is broken anyway, because of a typo ;-))


Edited by sage, Tue Feb 12, 2019 5:38 AM.


#13 bhall408 ONLINE  

bhall408

    Space Invader

  • Topic Starter
  • 43 posts
  • Location:California

Posted Tue Feb 12, 2019 3:21 PM

The implementation in most emulator is broken anyway, because of a typo ;-))

 

 

Of the ones I have been trying, they don't even *try* to implement rotated games. So you'd never get to see if there is a bug or not ;-)

 

One is based on mednafen (I think you work on that?) and the other is based on Handy.



#14 necrocia ONLINE  

necrocia

    Moonsweeper

  • 292 posts

Posted Tue Feb 12, 2019 4:07 PM

 

 

Of the ones I have been trying, they don't even *try* to implement rotated games. So you'd never get to see if there is a bug or not ;-)

 

One is based on mednafen (I think you work on that?) and the other is based on Handy.

 

 

I'm completely guilty of that too with the online emulator I host (https://atarigamer.com/lynx/play). I probably should provide an option to rotate the canvas at some point.



#15 bhall408 ONLINE  

bhall408

    Space Invader

  • Topic Starter
  • 43 posts
  • Location:California

Posted Tue Feb 12, 2019 4:11 PM

 

 

I'm completely guilty of that too with the online emulator I host (https://atarigamer.com/lynx/play). I probably should provide an option to rotate the canvas at some point.

 

 

So I guess you don't like any rotated games? ;-)

For myself, even if nobody else cared, I'd want support just so I could play Guantlet, Klax and Flappy Bird!



#16 necrocia ONLINE  

necrocia

    Moonsweeper

  • 292 posts

Posted Tue Feb 12, 2019 4:28 PM

Not a huge fan of them just because the console is awkward to hold. I've tried doing a simple rotation, that works fine with a bit of CSS, but then the controls get all messed up. I'm not certain how retroarch with emscripten captures keyboard events, maybe I can intercept and remap keys. Will give it a go in the next few days.



#17 sage OFFLINE  

sage

    Dragonstomper

  • 981 posts
  • Location:Germany

Posted Tue Feb 12, 2019 6:16 PM

 

 

Of the ones I have been trying, they don't even *try* to implement rotated games. So you'd never get to see if there is a bug or not ;-)

 

One is based on mednafen (I think you work on that?) and the other is based on Handy.

 

At some times zes. But I stopped because I disliked the update/commit patches policy. In Retroarch is easier to get patches and enhancements in.

The problem with emu and rotation is, that they compared the angle to 240, not 270 degree ;-)

And whoever made the lnx images, might not have noticed that the rotation flag must be either 0,90,180,270, and not 0,1

 

... and ...

 

often enough lnx files are plain rom dumps without any header (thanks to archive). So ... what do you expect? that the emulation checks each rom by hash andcomes with a embedded database? possible for lynx with teh tremendous amount of games, sure.


Edited by sage, Tue Feb 12, 2019 6:25 PM.


#18 bhall408 ONLINE  

bhall408

    Space Invader

  • Topic Starter
  • 43 posts
  • Location:California

Posted Tue Feb 12, 2019 9:45 PM

 

The problem with emu and rotation is, that they compared the angle to 240, not 270 degree ;-)

And whoever made the lnx images, might not have noticed that the rotation flag must be either 0,90,180,270, and not 0,1

 

... and ...

 

often enough lnx files are plain rom dumps without any header (thanks to archive). So ... what do you expect? that the emulation checks each rom by hash andcomes with a embedded database? possible for lynx with teh tremendous amount of games, sure.

 

 

Well 240 vs 270 is an easy enough fix.

 

You really have 3 states based on the v1 header -- no rotation, rotate right 90 degrees, rotate left 90 degrees. Just need to map that, and then map the controller inputs accordingly as well.

 

As to the LNX headers being incorrect...

 

Im wein ist Wahrheit... (oder Weisheit?)

 

UGH!

 

I was hoping that would not be the case.

 

We've considered writing a little command line tool to dump the headers and check them out. I guess we need to do that.

 

And if you were to do a hash and a database, is the hash on the whole file, or on the ROM portion of the file? Or both? ;-)

 

With 100-200 titles, I think that is manageable, even if you had to do it by hand.

 

I've also considered that it could be time to implement a v2 of the LNX header... Include more meta-data...

 

The other option (we are more likely to do) is to have all the meta-data in a parallel .json file and/or pull from a server database we maintain.

 

We'd like to have developer, publisher, release date, screen shots, speed-runs, etc as part of the meta-data.

 

Feel free to PM/email me if you'd like to take this offline.



#19 sage OFFLINE  

sage

    Dragonstomper

  • 981 posts
  • Location:Germany

Posted Tue Feb 12, 2019 11:04 PM

 

 

Well 240 vs 270 is an easy enough fix.

 

You really have 3 states based on the v1 header -- no rotation, rotate right 90 degrees, rotate left 90 degrees. Just need to map that, and then map the controller inputs accordingly as well.

 

As to the LNX headers being incorrect...

 

Im wein ist Wahrheit... (oder Weisheit?)

 

UGH!

 

I was hoping that would not be the case.

 

We've considered writing a little command line tool to dump the headers and check them out. I guess we need to do that.

 

And if you were to do a hash and a database, is the hash on the whole file, or on the ROM portion of the file? Or both? ;-)

 

With 100-200 titles, I think that is manageable, even if you had to do it by hand.

 

I've also considered that it could be time to implement a v2 of the LNX header... Include more meta-data...

 

The other option (we are more likely to do) is to have all the meta-data in a parallel .json file and/or pull from a server database we maintain.

 

We'd like to have developer, publisher, release date, screen shots, speed-runs, etc as part of the meta-data.

 

Feel free to PM/email me if you'd like to take this offline.

There are already documented extension ... but that doesnt mean that emulators use them consistently...

anyway it does not solve the problem, that people complain that the emulator is not detecting everything if they run a plain rom dump ;-) got enough complains already



#20 sage OFFLINE  

sage

    Dragonstomper

  • 981 posts
  • Location:Germany

Posted Tue Feb 12, 2019 11:05 PM

what do you want to fix? the emulators out there or the lnx files ;-))))))



#21 42bs OFFLINE  

42bs

    Moonsweeper

  • 288 posts
  • Location:Germany/Southest West

Posted Thu Feb 14, 2019 10:56 PM

what do you want to fix? the emulators out there or the lnx files ;-))))))

 

You can make an MD5 hash of the ROM and then compare against saved ones to detect at least the commercial games that were using portrait mode.

So, "easy" to fix the emulators.



#22 sage OFFLINE  

sage

    Dragonstomper

  • 981 posts
  • Location:Germany

Posted Thu Feb 14, 2019 10:58 PM

That is exacly something I wanted to avoid. Luckily there are not that many rotated games, rigth ;-)



#23 karri OFFLINE  

karri

    River Patroller

  • 2,561 posts
  • Location:Espoo, Finland

Posted Fri Feb 15, 2019 1:15 AM

Fixing the lnx headers for the few portrait games with correct block size definitions, correct eeprom settings, correct rotation settings does not sound as a gigantic work.



#24 bhall408 ONLINE  

bhall408

    Space Invader

  • Topic Starter
  • 43 posts
  • Location:California

Posted Sat Feb 16, 2019 11:22 AM

 

For emulation there is a bit in the lnx header telling that the game is rotated. So it is possible to emulate the Lynx correctly on a large screen. But this lnx header is not part of the cart ROM. It is for emulators only.

 

Oh, how right you are...

 

The very first file I opened up (Gauntlet) was totally incorrect. Had no values for name, manufacture or rotation (the most important part!)

Attached Thumbnails

  • Screen Shot 2019-02-16 at 9.12.13 AM.png


#25 bhall408 ONLINE  

bhall408

    Space Invader

  • Topic Starter
  • 43 posts
  • Location:California

Posted Sat Feb 16, 2019 4:44 PM

Oh, in case it helps others, here is the list of rotated games I could find, and what their orientation (per header) should be:

 

 

Flappy Bird - Left

Gauntlet: The Third Encounter - Left

KLAX - Left

Lexis - Right

NFL Football - Right

Raiden - Right

Centipede - Right


Edited by bhall408, Sat Feb 16, 2019 4:45 PM.





0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users