Skip to content

Commit

Permalink
chore(*): typo fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
alekmaul committed Apr 9, 2024
1 parent 7c00264 commit 00279bb
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 7 deletions.
4 changes: 2 additions & 2 deletions pvsneslib/include/snes.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
- <a href="http://code.google.com/p/neo-myth-menu/">Neoflash Menu google code. </a>
- <a href="http://www.devkitpro.org/">Devkitpro team for pvsneslib structure (lib, makefile, examples, and so on ...). </a>
- <a href="https://github.com/undisbeliever/castle_platformer">undisbeliever for his great platform code example on github. </a>
- <a href="https://github.com/DigiDwrf">digidwrf for fastrom / hirom support. </a>
- <a href="https://github.com/DigiDwrf">digidwrf for fastrom / hirom support, mouse and superscope support. </a>
*/

// adding the example page.
Expand Down Expand Up @@ -120,7 +120,7 @@
<!-- palettes -->
\example graphics/Palette/GetColors/GetColors.c
<!-- keypad -->
<!-- inputs -->
\example input/controller/controller.c
\example input/mouse/mouse.c
\example input/multiplay5/multiplay5.c
Expand Down
4 changes: 2 additions & 2 deletions pvsneslib/source/input.asm
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
;---------------------------------------------------------------------------------
;
; Copyright (C) 2013-2020
; Alekmaul
; Copyright (C) 2013-2024
; Alekmaul - DigiDwrf
;
; This software is provided 'as-is', without any express or implied
; warranty. In no event will the authors be held liable for any
Expand Down
3 changes: 2 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ Sydney Hunter by [CollectorVision](https://collectorvision.com/store/shop/snes/s
- **RedBug** for constify tcc bug fix and tips for Linux and Docker.
- [**Mills32**](https://github.com/mills32/) for his mode7 3D example.
- [**N_Arno**](https://github.com/nArnoSNES/) for his help on Linux version.
- [**DigiDwrf**](https://github.com/DigiDwrf/) for hirom / fastrom support.
- [**DigiDwrf**](https://github.com/DigiDwrf/) for hirom / fastrom support and also mouse & superscope support.
- [**undisbeliever**](https://github.com/undisbeliever/castle_platformer/) for map engine example.

And, of course, all the [**discord community**](https://discord.gg/DzEFnhB) !

Expand Down
86 changes: 84 additions & 2 deletions wiki/Input-and-Output.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,92 @@ At least, the pad is refresh during VBL (thanks to VBlank function), so it is no

### Mouse

** WORK IN PROGRESS **
**snes_mouse** has to be turned on (snes_mouse = 1). This is set 0 by default after consoleInit().
This will tell the system to read from a mouse, if it is found.
Mouse and pads can be used simultaneously, on any ports. Externs in the pad.h file goes like this:

```
snes_mouse; /*!1 if Mouse is going to be used */
```

mouseConnect[2]; /* 1 if Mouse present */
mouseButton[2]; /* 1 if button is pressed, stays for a bit and then it gets released (Click mode). */
mousePressed[2]; /* 1 if button is pressed, stays until is unpressed (Turbo mode). */
mouse_x[2], mouse_y[2]; /* Mouse acceleration. daaaaaaa, d = direction (0: up/left, 1: down/right), a = acceleration. */
mouseSpeedSet[2]; /* Mouse speed setting. 0: slow, 1: normal, 2: fast */

First, we might use **detectMouse()** to populate snes_mouse to 1, so It can be called at boot and like this:

```
if (snes_mouse == false)
{
detectMouse();
// some other code you might need in your program, like displaying warning messages and stopping your game.
}
```

the number inside array specifies port (0 or 1). I recommend using this code structure to convert raw acceleration into usable values:

```
u16 p1_mouse_x = 0x80;
u16 p1_mouse_y = 0x70;
u16 p2_mouse_x = 0x80;
u16 p2_mouse_y = 0x70;
if (mouse_x[0] & 0x80)
p1_mouse_x -= mouse_x[0] & 0x7F;
else
p1_mouse_x += mouse_x[0] & 0x7F;
if (mouse_y[0] & 0x80)
p1_mouse_y -= mouse_y[0] & 0x7F;
else
p1_mouse_y += mouse_y[0] & 0x7F;
```

And that's most of it. You can look inside the example file **(input** folder) to have an idea of how you can program Mouse games.


### SuperScope

** WORK IN PROGRESS **
First, we might use **detectSuperScope()** on boot to detect Super Scope presence. Other way is to force detection by populating snes_sscope to 1 manually, but we dont need to do that if we call this function. We need to call this function everytime Scope gets disconnected from the system, a usefull way to do it is inside this conditional:

```
if (snes_sscope == false)
{
detectSuperScope();
// some other code you might need in your program, like displaying warning messages and stopping your game.
}
```

Here is a brief explanation of every variable we might be using:

```
extern u16 scope_holddelay; /*! \brief Hold delay. */
extern u16 scope_repdelay; /*! \brief Repeat rate. */
extern u16 scope_shothraw; /*! \brief Horizontal shot position, not adjusted. */
extern u16 scope_shotvraw; /*! \brief Vertical shot position, not adjusted. */
extern u16 scope_shoth; /*! \brief Horizontal shot position, adjusted for aim. */
extern u16 scope_shotv; /*! \brief Vertical shot position, adjusted for aim. */
extern u16 scope_centerh; /*! \brief 0x0000 is the center of the screen, positive values go to bottom right. */
extern u16 scope_centerv; /*! \brief 0x0000 is the center of the screen, positive values go to bottom right. */
extern u16 scope_down; /*! \brief flags that are currently true.*/
extern u16 scope_now; /*! \brief flags that have become true this frame.*/
extern u16 scope_held; /*! \brief flagsthat have been true for a certain length of time.*/
extern u16 scope_last; /*! \brief flags that were true on the previous frame.*/
extern u16 scope_sinceshot; /*! \brief Number of frames elapsed since last shot was fired.*/
for scope_down, scope_now, scope_held, scope_last, we need to mask our bits with this usefull bits:
typedef enum SUPERSCOPE_BITS
{
SSC_FIRE = BIT(15), //!< superscope FIRE button.
SSC_CURSOR = BIT(14), //!< superscope CURSOR button.
SSC_PAUSE = BIT(12), //!< superscope PAUSE button.
SSC_TURBO = BIT(13), //!< superscope TURBO flag.
SSC_OFFSCREEN = BIT(9), //!< superscope OFFSCREEN flag.
SSC_NOISE = BIT(8), //!< superscope NOISE flag.
} SUPERSCOPE_BITS;
```

And that's most of it. You can look inside the example file **(input** folder) to have an idea of how you can program Super Scope games.


0 comments on commit 00279bb

Please sign in to comment.