-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
34 changed files
with
3,509 additions
and
3,019 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
Boost Software License - Version 1.0 - August 17th, 2003 | ||
|
||
Permission is hereby granted, free of charge, to any person or organization | ||
obtaining a copy of the software and accompanying documentation covered by | ||
this license (the "Software") to use, reproduce, display, distribute, | ||
execute, and transmit the Software, and to prepare derivative works of the | ||
Software, and to permit third-parties to whom the Software is furnished to | ||
do so, all subject to the following: | ||
|
||
The copyright notices in the Software and this entire statement, including | ||
the above license grant, this restriction and the following disclaimer, | ||
must be included in all copies of the Software, in whole or in part, and | ||
all derivative works of the Software, unless such copies or derivative | ||
works are solely in the form of machine-executable object code generated by | ||
a source language processor. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT | ||
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE | ||
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, | ||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* Copyright (c) 2022, Patrick Bene | ||
* This file is distributed under the Boost Software License, Version 1.0. | ||
* See LICENSE_1_0.txt or https://www.boost.org/LICENSE_1_0.txt | ||
*/ | ||
|
||
// Code for manipulating OAM (Object Attribute Memory), | ||
// which is the memory that represents sprites. | ||
// See: https://www.nesdev.org/wiki/PPU_OAM | ||
|
||
vars /oam | ||
// This array represents the CPU-side copy of OAM. | ||
// Make your modifications to it, then call 'ppu_upload_oam' during VBLANK. | ||
U[256] oam | ||
: +align | ||
|
||
// Offsets into OAM, as determined by the hardware: | ||
ct Int OAM_Y = 0 | ||
ct Int OAM_P = 1 | ||
ct Int OAM_A = 2 | ||
ct Int OAM_X = 3 | ||
|
||
// Copies 'oam' into PPU memory. Call during VBLANK only. | ||
fn ppu_upload_oam(U offset) | ||
: employs /oam | ||
: +inline | ||
fence | ||
{OAMADDR}(offset) | ||
{OAMDMA}((&oam).b) | ||
|
||
// !!! For the following functions: !!! | ||
// 'index' must be a multiple of 4, otherwise the behavior is undefined. | ||
|
||
// Hides every sprite, starting from 'index': | ||
fn hide_oam(U index) | ||
: +inline | ||
do for(; index; index += 4) | ||
oam{OAM_Y + index} = $FF | ||
|
||
// The 'set_oam' functions use the '{}' operator for array indexing | ||
// instead of '[]', as it's more efficient in this case. | ||
|
||
fn set_oam_x(U index, U x) | ||
: +inline | ||
oam{OAM_X + index} = x | ||
|
||
fn set_oam_y(U index, U y) | ||
: +inline | ||
oam{OAM_Y + index} = y | ||
|
||
fn set_oam_p(U index, U p) | ||
: +inline | ||
oam{OAM_P + index} = p | ||
|
||
fn set_oam_a(U index, U a) | ||
: +inline | ||
oam{OAM_A + index} = a | ||
|
||
fn set_oam(U index, U x, U y, U p, U a) | ||
: +inline | ||
oam{OAM_Y + index} = y | ||
oam{OAM_P + index} = p | ||
oam{OAM_A + index} = a | ||
oam{OAM_X + index} = x | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.