ref: 3f1b1d5a61e954eb7690887eaf43ab7e549491fb
parent: 782063496254cca4e6e1848ae87ee7b730c73db9
author: Snesrev <snesrev@protonmail.com>
date: Sat Oct 1 21:59:15 EDT 2022
Change a lot of places to use the oam helpers
--- a/ancilla.c
+++ b/ancilla.c
@@ -344,6 +344,35 @@
return -1;
}
+static void Ancilla_SetOam(OamEnt *oam, uint16 x, uint16 y, uint8 charnum, uint8 flags, uint8 big) {
+ uint8 yval = 0xf0;
+ int xt = enhanced_features0 ? 0x40 : 0;
+ if ((uint16)(x + xt) < 256 + xt * 2 && y < 256) {
+ big |= (x >> 8) & 1;
+ oam->x = x;
+ if (y < 0xf0)
+ yval = y;
+ }
+ oam->y = yval;
+ oam->charnum = charnum;
+ oam->flags = flags;
+ bytewise_extended_oam[oam - oam_buf] = big;
+}
+
+static void Ancilla_SetOam_Safe(OamEnt *oam, uint16 x, uint16 y, uint8 charnum, uint8 flags, uint8 big) {
+ uint8 yval = 0xf0;
+ oam->x = x;
+ if ((uint16)(x + 0x80) < 0x180) {
+ big |= (x >> 8) & 1;
+ if ((uint16)(y + 0x10) < 0x100)
+ yval = y;
+ }
+ oam->y = yval;
+ oam->charnum = charnum;
+ oam->flags = flags;
+ bytewise_extended_oam[oam - oam_buf] = big;
+}
+
void Ancilla_Empty(int k) {
}
@@ -382,11 +411,8 @@
assert(t < 32);
for(int i = 0; i < 4; i++, t++) {
if (kInitialSpinSpark_Char[t] != 0xff) {
- uint8 ext = Ancilla_SetOam_XY(oam,
- info.x + kInitialSpinSpark_X[t], info.y + kInitialSpinSpark_Y[t]);
- oam->charnum = kInitialSpinSpark_Char[t];
- oam->flags = kInitialSpinSpark_Flags[t] & ~0x30 | HIBYTE(oam_priority_value);
- bytewise_extended_oam[oam - oam_buf] = ext;
+ Ancilla_SetOam(oam, info.x + kInitialSpinSpark_X[t], info.y + kInitialSpinSpark_Y[t],
+ kInitialSpinSpark_Char[t], kInitialSpinSpark_Flags[t] & ~0x30 | HIBYTE(oam_priority_value), 0);
oam++;
}
}
@@ -681,13 +707,8 @@
OamEnt *oam = GetOamCurPtr();
j = ancilla_timer[k] & 0x1c;
- for (int i = 3; i >= 0; i--, oam++) {
- oam->x = info.x + kIceShotSparkle_X[i + j];
- oam->y = info.y + kIceShotSparkle_Y[i + j];
- oam->charnum = kIceShotSparkle_Char[i + j];
- oam->flags = info.flags | 4;
- bytewise_extended_oam[oam - oam_buf] = 0;
- }
+ for (int i = 3; i >= 0; i--, oam++)
+ SetOamPlain(oam, info.x + kIceShotSparkle_X[i + j], info.y + kIceShotSparkle_Y[i + j], kIceShotSparkle_Char[i + j], info.flags | 4, 0);
}
void AncillaAdd_IceRodSparkle(int k) { // 8884c8
@@ -792,21 +813,10 @@
};
OamEnt *oam = GetOamCurPtr();
int j = ancilla_dir[k] * 6 + ancilla_step[k];
-
- oam[0].x = info.x + kSomarianBlast_Draw_X0[j];
- oam[1].x = info.x + kSomarianBlast_Draw_X1[j];
- if (!sign8(kSomarianBlast_Draw_Y0[j]))
- oam[0].y = info.y + kSomarianBlast_Draw_Y0[j];
- if (!sign8(kSomarianBlast_Draw_Y1[j]))
- oam[1].y = info.y + kSomarianBlast_Draw_Y1[j];
- oam[0].charnum = 0x82 + kSomarianBlast_Draw_Char0[j];
- oam[1].charnum = 0x82 + kSomarianBlast_Draw_Char1[j];
- oam[0].flags = info.flags | kSomarianBlast_Draw_Flags0[j];
- oam[1].flags = info.flags | kSomarianBlast_Draw_Flags1[j];
- bytewise_extended_oam[oam - oam_buf] = 0;
- bytewise_extended_oam[oam - oam_buf + 1] = 0;
-
-
+ SetOamPlain(oam + 0, info.x + kSomarianBlast_Draw_X0[j], sign8(kSomarianBlast_Draw_Y0[j]) ? 0xf0 : info.y + kSomarianBlast_Draw_Y0[j],
+ 0x82 + kSomarianBlast_Draw_Char0[j], info.flags | kSomarianBlast_Draw_Flags0[j], 0);
+ SetOamPlain(oam + 1, info.x + kSomarianBlast_Draw_X1[j], sign8(kSomarianBlast_Draw_Y1[j]) ? 0xf0 : info.y + kSomarianBlast_Draw_Y1[j],
+ 0x82 + kSomarianBlast_Draw_Char1[j], info.flags | kSomarianBlast_Draw_Flags1[j], 0);
}
void Ancilla02_FireRodShot(int k) { // 8886d2
@@ -855,22 +865,10 @@
int j = ancilla_timer[k] >> 3;
if (j != 0) {
static const uint8 kFireShot_Draw_Char[3] = {0xa2, 0xa0, 0x8e};
- oam->x = info.x;
- oam->y = info.y;
- oam->charnum = kFireShot_Draw_Char[j - 1];
- oam->flags = info.flags | 2;
- bytewise_extended_oam[oam - oam_buf] = 2;
+ SetOamPlain(oam, info.x, info.y, kFireShot_Draw_Char[j - 1], info.flags | 2, 2);
} else {
- bytewise_extended_oam[oam - oam_buf] = 0;
- bytewise_extended_oam[oam - oam_buf + 1] = 0;
- oam[0].x = info.x;
- oam[1].x = info.x + 8;
- oam[0].y = info.y - 3;
- oam[1].y = info.y - 3;
- oam[0].charnum = 0xa4;
- oam[1].charnum = 0xa5;
- oam[0].flags = info.flags | 2;
- oam[1].flags = info.flags | 2;
+ SetOamPlain(oam + 0, info.x + 0, info.y - 3, 0xa4, info.flags | 2, 0);
+ SetOamPlain(oam + 1, info.x + 8, info.y - 3, 0xa5, info.flags | 2, 0);
}
}
}
@@ -887,14 +885,8 @@
OamEnt *oam = GetOamCurPtr();
int j = ancilla_item_to_link[k] & 0xc;
- for (int i = 2; i >= 0; i--) {
- oam->x = info.x + kFireShot_Draw_X2[j + i];
- oam->y = info.y + kFireShot_Draw_Y2[j + i];
- oam->charnum = kFireShot_Draw_Char2[i];
- oam->flags = info.flags | 2;
- bytewise_extended_oam[oam - oam_buf] = 0;
- oam++;
- }
+ for (int i = 2; i >= 0; i--, oam++)
+ SetOamPlain(oam, info.x + kFireShot_Draw_X2[j + i], info.y + kFireShot_Draw_Y2[j + i], kFireShot_Draw_Char2[i], info.flags | 2, 0);
}
uint8 Ancilla_CheckTileCollision_staggered(int k) { // 88897b
@@ -1061,15 +1053,12 @@
uint8 r6 = ancilla_y - BG2VOFS_copy2;
for (int i = 3; i >= 0; i--, oam++) {
int m = j * 4 + i;
- oam->x = info.x + kBeamHit_X[m];
- oam->y = info.y + kBeamHit_Y[m];
- oam->charnum = kBeamHit_Char[m] + 0x82;
- oam->flags = kBeamHit_Flags[m] | 2 | info.flags;
- uint16 x_adj = (uint16)(ancilla_x + (int8)(oam->x - r7) - BG2HOFS_copy2);
- bytewise_extended_oam[oam - oam_buf] = (x_adj >= 0x100) ? 1 : 0;
- uint16 y_adj = (uint16)(ancilla_y + (int8)(oam->y - r6) - BG2VOFS_copy2 + 0x10);
- if (y_adj >= 0x100)
- oam->y = 0xf0;
+ uint8 x = info.x + kBeamHit_X[m];
+ uint8 y = info.y + kBeamHit_Y[m];
+ uint16 x_adj = (uint16)(ancilla_x + (int8)(x - r7) - BG2HOFS_copy2);
+ uint16 y_adj = (uint16)(ancilla_y + (int8)(y - r6) - BG2VOFS_copy2 + 0x10);
+ SetOamPlain(oam, x, (y_adj >= 0x100) ? 0xf0 : y,
+ kBeamHit_Char[m] + 0x82, kBeamHit_Flags[m] | 2 | info.flags, (x_adj >= 0x100) ? 1 : 0);
}
}
@@ -1236,42 +1225,18 @@
}
OamEnt *oam = GetOamCurPtr();
-
static const uint8 kRepulseSpark_Flags[4] = {0x22, 0x12, 0x22, 0x22};
uint8 flags = kRepulseSpark_Flags[repulsespark_floor_status];
if (repulsespark_timer >= 3) {
- oam->x = x;
- oam->y = y;
- oam->charnum = (repulsespark_timer < 9) ? 0x92 : 0x80;
- oam->flags = flags;
- bytewise_extended_oam[oam - oam_buf] = 0;
+ SetOamPlain(oam, x, y, (repulsespark_timer < 9) ? 0x92 : 0x80, flags, 0);
return;
}
-
- oam[0].x = x - 4;
- oam[2].x = x - 4;
- oam[1].x = x + 4;
- oam[3].x = x + 4;
-
- oam[0].y = y - 4;
- oam[1].y = y - 4;
- oam[2].y = y + 4;
- oam[3].y = y + 4;
-
- oam[0].flags = flags;
- oam[1].flags = flags | 0x40;
- oam[2].flags = flags | 0x80;
- oam[3].flags = flags | 0xc0;
-
- static const uint8 kRepulseSpark_Char[3] = {0x93, 0x82, 0x81};
+ static const uint8 kRepulseSpark_Char[3] = { 0x93, 0x82, 0x81 };
uint8 c = kRepulseSpark_Char[repulsespark_timer];
- oam[0].charnum = c;
- oam[1].charnum = c;
- oam[2].charnum = c;
- oam[3].charnum = c;
-
- uint8 *ext = &bytewise_extended_oam[oam - oam_buf];
- ext[0] = ext[1] = ext[2] = ext[3] = 0;
+ SetOamPlain(oam + 0, x - 4, y - 4, c, flags | 0x00, 0);
+ SetOamPlain(oam + 1, x + 4, y - 4, c, flags | 0x40, 0);
+ SetOamPlain(oam + 2, x - 4, y + 4, c, flags | 0x80, 0);
+ SetOamPlain(oam + 3, x + 4, y + 4, c, flags | 0xc0, 0);
}
void Ancilla_MoveX(int k) { // 889080
@@ -1430,12 +1395,7 @@
oam_ext_cur_ptr = (i >> 2) + 0xa20;
oam_cur_ptr = i + 0x800;
}
- OamEnt *oam = GetOamCurPtr();
- uint8 ext = Ancilla_SetOam_XY_safe(oam, x, y);
- oam->charnum = 0x26;
- oam->flags = kBoomerang_Flags[ancilla_G[k] * 4 + j] & ~0x30 | HIBYTE(oam_priority_value);
- bytewise_extended_oam[oam - oam_buf] = 2 | ext;
-
+ Ancilla_SetOam_Safe(GetOamCurPtr(), x, y, 0x26, kBoomerang_Flags[ancilla_G[k] * 4 + j] & ~0x30 | HIBYTE(oam_priority_value), 2);
}
void Ancilla06_WallHit(int k) { // 8893e8
@@ -1490,10 +1450,8 @@
OamEnt *oam = GetOamCurPtr();
for (int n = 3; n >= 0; n--, t++) {
if (kWallHit_Char[t] != 0) {
- uint8 ext = Ancilla_SetOam_XY(oam, info.x + kWallHit_X[t], info.y + kWallHit_Y[t]);
- oam->charnum = kWallHit_Char[t];
- oam->flags = kWallHit_Flags[t] & ~0x30 | HIBYTE(oam_priority_value);
- bytewise_extended_oam[oam - oam_buf] = ext;
+ Ancilla_SetOam(oam, info.x + kWallHit_X[t], info.y + kWallHit_Y[t], kWallHit_Char[t],
+ kWallHit_Flags[t] & ~0x30 | HIBYTE(oam_priority_value), 0);
oam++;
}
oam = Ancilla_AllocateOamFromCustomRegion(oam);
@@ -1935,13 +1893,9 @@
for (int i = 0; i != 2; i++) {
int t = j * 2 + i;
//kDoorDebris_XY
- uint8 ext = Ancilla_SetOam_XY(oam, x + kDoorDebris_XY[t * 2 + 1], y + kDoorDebris_XY[t * 2 + 0]);
-
uint16 d = kDoorDebris_CharFlags[t];
- oam->charnum = d;
- oam->flags = (d >> 8) & 0xc0 | HIBYTE(oam_priority_value);
-
- bytewise_extended_oam[oam - oam_buf] = ext;
+ Ancilla_SetOam(oam, x + kDoorDebris_XY[t * 2 + 1], y + kDoorDebris_XY[t * 2 + 0],
+ d, (d >> 8) & 0xc0 | HIBYTE(oam_priority_value), 0);
oam = Ancilla_AllocateOamFromCustomRegion(oam + 1);
}
}
@@ -2053,10 +2007,8 @@
uint8 flags = (link_item_bow & 4) ? 2 : 4;
for (int i = 0; i != 2; i++, j++) {
if (kArrow_Draw_Char[j] != 0xff) {
- uint8 ext = Ancilla_SetOam_XY(oam, x + kArrow_Draw_X[j], y + kArrow_Draw_Y[j]);
- oam->charnum = kArrow_Draw_Char[j];
- oam->flags = kArrow_Draw_Flags[j] & ~0x3E | flags | HIBYTE(oam_priority_value);
- bytewise_extended_oam[oam - oam_buf] = ext;
+ Ancilla_SetOam(oam, x + kArrow_Draw_X[j], y + kArrow_Draw_Y[j],
+ kArrow_Draw_Char[j], kArrow_Draw_Flags[j] & ~0x3E | flags | HIBYTE(oam_priority_value), 0);
oam++;
}
}
@@ -2242,11 +2194,10 @@
do {
if (kBomb_DrawExplosion_CharFlags[frame * 2] != 0xff) {
int i = idx + base_frame;
- uint16 xt = x + kBomb_DrawExplosion_XY[i * 2 + 1];
- uint8 ext = Ancilla_SetOam_XY_safe(oam, xt, y + kBomb_DrawExplosion_XY[i * 2 + 0]);
- oam->charnum = kBomb_DrawExplosion_CharFlags[frame * 2];
- oam->flags = kBomb_DrawExplosion_CharFlags[frame * 2 + 1] & ~0x3E | HIBYTE(oam_priority_value) | r11;
- bytewise_extended_oam[oam - oam_buf] = ext | kBomb_DrawExplosion_Ext[frame];
+ Ancilla_SetOam_Safe(oam, x + kBomb_DrawExplosion_XY[i * 2 + 1], y + kBomb_DrawExplosion_XY[i * 2 + 0],
+ kBomb_DrawExplosion_CharFlags[frame * 2],
+ kBomb_DrawExplosion_CharFlags[frame * 2 + 1] & ~0x3E | HIBYTE(oam_priority_value) | r11,
+ kBomb_DrawExplosion_Ext[frame]);
oam++;
}
} while (frame++, ++idx != idx_end);
@@ -2282,18 +2233,12 @@
int j = ancilla_item_to_link[k];
uint8 flags = 0;
for (int i = 0; i < 2; i++) {
- uint8 ext = Ancilla_SetOam_XY(oam, pt.x, pt.y);
- oam->charnum = kAncilla_JumpSplash_Char[j];
- oam->flags = 0x24 | flags;
- bytewise_extended_oam[oam - oam_buf] = ext | 2;
+ Ancilla_SetOam(oam, pt.x, pt.y, kAncilla_JumpSplash_Char[j], 0x24 | flags, 2);
oam = Ancilla_AllocateOamFromCustomRegion(oam + 1);
pt.x = x8;
flags = 0x40;
}
- uint8 ext = Ancilla_SetOam_XY(oam, x6, pt.y);
- oam->charnum = 0xc0;
- oam->flags = 0x24;
- bytewise_extended_oam[oam - oam_buf] = ext | ((j == 1) ? 1 : 2);
+ Ancilla_SetOam(oam, x6, pt.y, 0xc0, 0x24, ((j == 1) ? 1 : 2));
}
void Ancilla16_HitStars(int k) { // 88a8e5
@@ -2333,10 +2278,9 @@
uint16 x = info.x, y = info.y;
uint8 flags = 0;
for (int i = 1; i >= 0; i--) {
- uint8 ext = Ancilla_SetOam_XY(oam, x, y);
- oam->charnum = kAncilla_HitStars_Char[ancilla_item_to_link[k]];
- oam->flags = HIBYTE(oam_priority_value) | 4 | flags;
- bytewise_extended_oam[oam - oam_buf] = ext;
+ Ancilla_SetOam(oam, x, y,
+ kAncilla_HitStars_Char[ancilla_item_to_link[k]],
+ HIBYTE(oam_priority_value) | 4 | flags, 0);
flags = 0x40;
BYTE(x) = r8;
oam = HitStars_UpdateOamBufferPosition(oam + 1);
@@ -2361,10 +2305,7 @@
pt.x += kShovelDirt_XY[j * 2 + 1];
pt.y += kShovelDirt_XY[j * 2 + 0];
for (int i = 0; i < 2; i++) {
- uint8 ext = Ancilla_SetOam_XY(oam, pt.x + i * 8, pt.y);
- oam->charnum = kShovelDirt_Char[b] + i;
- oam->flags = 4 | HIBYTE(oam_priority_value);
- bytewise_extended_oam[oam - oam_buf] = ext;
+ Ancilla_SetOam(oam, pt.x + i * 8, pt.y, kShovelDirt_Char[b] + i, 4 | HIBYTE(oam_priority_value), 0);
oam = Ancilla_AllocateOamFromCustomRegion(oam + 1);
}
}
@@ -2390,11 +2331,7 @@
Point16U pt;
Ancilla_PrepOamCoord(k, &pt);
- OamEnt *oam = GetOamCurPtr();
- uint8 ext = Ancilla_SetOam_XY(oam, pt.x, pt.y);
- oam->charnum = kBlastWallFireball_Char[blastwall_var12[k] & 8 ? 0 : blastwall_var12[k] & 4 ? 1 : 2];
- oam->flags = 0x22;
- bytewise_extended_oam[oam - oam_buf] = ext;
+ Ancilla_SetOam(GetOamCurPtr(), pt.x, pt.y, kBlastWallFireball_Char[blastwall_var12[k] & 8 ? 0 : blastwall_var12[k] & 4 ? 1 : 2], 0x22, 0);
}
void Ancilla18_EtherSpell(int k) { // 88aaa0
@@ -2559,10 +2496,7 @@
static const uint8 kEther_BlitzBall_Char[2] = {0x68, 0x6a};
int x = (arp->r6 ? -arp->r4 : arp->r4) + ether_x2 - 8 - BG2HOFS_copy2;
int y = (arp->r2 ? -arp->r0 : arp->r0) + ether_y3 - 8 - BG2VOFS_copy2;
- uint8 ext = Ancilla_SetOam_XY(oam, x, y);
- oam->charnum = kEther_BlitzBall_Char[s];
- oam->flags = 0x3c;
- bytewise_extended_oam[oam - oam_buf] = ext | 2;
+ Ancilla_SetOam(oam, x, y, kEther_BlitzBall_Char[s], 0x3c, 2);
return Ancilla_AllocateOamFromCustomRegion(oam + 1);
}
@@ -2579,19 +2513,15 @@
};
int x = (arp->r6 ? -arp->r4 : arp->r4);
int y = (arp->r2 ? -arp->r0 : arp->r0);
- uint8 ext = Ancilla_SetOam_XY(oam, x + ether_x2 - 8 - BG2HOFS_copy2, y + ether_y3 - 8 - BG2VOFS_copy2);
int t = s * 8 + k;
- oam->charnum = kEther_SpllittingBlitzSegment_Char[t * 2];
- oam->flags = kEther_SpllittingBlitzSegment_Flags[t * 2];
- bytewise_extended_oam[oam - oam_buf] = ext | 2;
- oam++;
- ext = Ancilla_SetOam_XY(oam,
+ Ancilla_SetOam(oam, x + ether_x2 - 8 - BG2HOFS_copy2, y + ether_y3 - 8 - BG2VOFS_copy2,
+ kEther_SpllittingBlitzSegment_Char[t * 2], kEther_SpllittingBlitzSegment_Flags[t * 2], 2);
+ Ancilla_SetOam(oam + 1,
x + ether_x2 + kEther_SpllittingBlitzSegment_X[t] - BG2HOFS_copy2,
- y + ether_y3 + kEther_SpllittingBlitzSegment_Y[t] - BG2VOFS_copy2);
- oam->charnum = kEther_SpllittingBlitzSegment_Char[t * 2 + 1];
- oam->flags = kEther_SpllittingBlitzSegment_Flags[t * 2 + 1];
- bytewise_extended_oam[oam - oam_buf] = ext | 2;
- return Ancilla_AllocateOamFromCustomRegion(oam + 1);
+ y + ether_y3 + kEther_SpllittingBlitzSegment_Y[t] - BG2VOFS_copy2,
+ kEther_SpllittingBlitzSegment_Char[t * 2 + 1],
+ kEther_SpllittingBlitzSegment_Flags[t * 2 + 1], 2);
+ return Ancilla_AllocateOamFromCustomRegion(oam + 2);
}
void AncillaDraw_EtherBlitz(int k) { // 88ae87
@@ -2602,10 +2532,9 @@
int i = ancilla_arr25[k];
int m = 0;
do {
- uint8 ext = Ancilla_SetOam_XY(oam, info.x, info.y);
- oam->charnum = kEther_BlitzSegment_Char[t * 2 + m];
- oam->flags = kEther_BlitzOrb_Flags[0] | HIBYTE(oam_priority_value);
- bytewise_extended_oam[oam - oam_buf] = ext | 2;
+ Ancilla_SetOam(oam, info.x, info.y,
+ kEther_BlitzSegment_Char[t * 2 + m],
+ kEther_BlitzOrb_Flags[0] | HIBYTE(oam_priority_value), 2);
info.y -= 16;
oam++;
m ^= 1;
@@ -2620,10 +2549,7 @@
int t = ancilla_item_to_link[k] * 4;
for (int i = 0; i < 4; i++) {
- uint8 ext = Ancilla_SetOam_XY(oam, x, y);
- oam->charnum = kEther_BlitzOrb_Char[t + i];
- oam->flags = kEther_BlitzOrb_Flags[t + i];
- bytewise_extended_oam[oam - oam_buf] = ext | 2;
+ Ancilla_SetOam(oam, x, y, kEther_BlitzOrb_Char[t + i], kEther_BlitzOrb_Flags[t + i], 2);
oam++;
oam = Ancilla_AllocateOamFromCustomRegion(oam);
x += 16;
@@ -2808,10 +2734,9 @@
uint16 y = bombos_y_lo[kk] | bombos_y_hi[kk] << 8;
y += kBombosSpell_FireColumn_Y[k] - BG2VOFS_copy2;
x += kBombosSpell_FireColumn_X[k] - BG2HOFS_copy2;
- uint8 ext = Ancilla_SetOam_XY(oam, x, y);
- oam->charnum = kBombosSpell_FireColumn_Char[k];
- oam->flags = kBombosSpell_FireColumn_Flags[k];
- bytewise_extended_oam[oam - oam_buf] = ext | 2;
+ Ancilla_SetOam(oam, x, y,
+ kBombosSpell_FireColumn_Char[k],
+ kBombosSpell_FireColumn_Flags[k], 2);
oam++;
}
oam = Ancilla_AllocateOamFromCustomRegion(oam);
@@ -2898,12 +2823,11 @@
int t = bombos_arr3[k] * 4 + 3;
for (int j = 0; j < 4; j++, t--) {
if (kBombosSpell_DrawBlast_Char[t] != 0xff) {
- uint8 ext = Ancilla_SetOam_XY(oam,
+ Ancilla_SetOam(oam,
x + kBombosSpell_DrawBlast_X[t] - BG2HOFS_copy2,
- y + kBombosSpell_DrawBlast_Y[t] - BG2VOFS_copy2);
- oam->charnum = kBombosSpell_DrawBlast_Char[t];
- oam->flags = kBombosSpell_DrawBlast_Flags[t];
- bytewise_extended_oam[oam - oam_buf] = ext | 2;
+ y + kBombosSpell_DrawBlast_Y[t] - BG2VOFS_copy2,
+ kBombosSpell_DrawBlast_Char[t],
+ kBombosSpell_DrawBlast_Flags[t], 2);
oam++;
}
oam = Ancilla_AllocateOamFromCustomRegion(oam);
@@ -2989,18 +2913,14 @@
uint16 x = p->x + quake_var2 - BG2HOFS_copy2;
uint16 y = p->y + quake_var1 - BG2VOFS_copy2;
- uint8 yval = 0xf0;
+ uint8 xval = oam->x, yval = 0xf0;
if (x < 256 && y < 256) {
- oam->x = x;
+ xval = x;
if (y < 0xf0)
yval = y;
}
- oam->y = yval;
- oam->charnum = kQuakeDrawGroundBolts_Char[p->f & 0x0f];
- oam->flags = p->f & 0xc0 | 0x3c;
- bytewise_extended_oam[oam - oam_buf] = 2;
- oam++;
- oam_cur_ptr += 4, oam_ext_cur_ptr += 1;
+ SetOamPlain(oam, xval, yval, kQuakeDrawGroundBolts_Char[p->f & 0x0f], p->f & 0xc0 | 0x3c, 2);
+ oam++, oam_cur_ptr += 4, oam_ext_cur_ptr += 1;
} while (++p != pend);
}
@@ -3014,19 +2934,12 @@
return;
}
}
-
int t = ancilla_item_to_link[k];
-
int idx = kQuakeItemPos2[t], num = kQuakeItemPos2[t + 1] - idx;
const QuakeItem *p = &kQuakeItems2[idx], *pend = p + num;
OamEnt *oam = GetOamCurPtr();
-
do {
- oam->x = p->x;
- oam->y = p->y;
- oam->charnum = kQuakeDrawGroundBolts_Char[p->f & 0x0f];
- oam->flags = p->f & 0xc0 | 0x3c;
- bytewise_extended_oam[oam - oam_buf] = p->f >> 4 & 3;
+ SetOamPlain(oam, p->x, p->y, kQuakeDrawGroundBolts_Char[p->f & 0x0f], p->f & 0xc0 | 0x3c, p->f >> 4 & 3);
oam_cur_ptr += 4, oam_ext_cur_ptr += 1;
oam = Ancilla_AllocateOamFromCustomRegion(oam + 1);
} while (++p != pend);
@@ -3080,10 +2993,8 @@
OamEnt *oam = GetOamCurPtr();
int b = ancilla_arr25[k];
for (int i = 0; i < 4; i++, oam++) {
- uint8 ext = Ancilla_SetOam_XY(oam, info.x + kMagicPowder_DrawX[b * 4 + i], info.y + kMagicPowder_DrawY[b * 4 + i]);
- oam->charnum = kMagicPowder_Draw_Char[b];
- oam->flags = kMagicPowder_Draw_Flags[b * 4 + i] & ~0x30 | HIBYTE(oam_priority_value);
- bytewise_extended_oam[oam - oam_buf] = ext;
+ Ancilla_SetOam(oam, info.x + kMagicPowder_DrawX[b * 4 + i], info.y + kMagicPowder_DrawY[b * 4 + i],
+ kMagicPowder_Draw_Char[b], kMagicPowder_Draw_Flags[b * 4 + i] & ~0x30 | HIBYTE(oam_priority_value), 0);
}
}
@@ -3171,14 +3082,10 @@
for (int n = 2; n >= 0; n--, t++) {
if (kDashDust_Draw_Char[t] != 0xff) {
- uint8 ext = Ancilla_SetOam_XY(oam, info.x + r12 + kDashDust_Draw_X[t], info.y + kDashDust_Draw_Y[t]);
- oam->charnum = kDashDust_Draw_Char[t];
- oam->flags = 4 | HIBYTE(oam_priority_value);
- bytewise_extended_oam[oam - oam_buf] = ext;
+ Ancilla_SetOam(oam, info.x + r12 + kDashDust_Draw_X[t], info.y + kDashDust_Draw_Y[t], kDashDust_Draw_Char[t], 4 | HIBYTE(oam_priority_value), 0);
oam++;
}
}
-
}
void Ancilla1F_Hookshot(int k) { // 88bd74
@@ -3289,10 +3196,7 @@
int x = info.x, y = info.y;
for (int i = 2; i >= 0; i--, j++) {
if (kHookShot_Draw_Char[j] != 0xff) {
- uint8 ext = Ancilla_SetOam_XY(oam, x, y);
- oam->charnum = kHookShot_Draw_Char[j];
- oam->flags = kHookShot_Draw_Flags[j] | 2 | HIBYTE(oam_priority_value);
- bytewise_extended_oam[oam - oam_buf] = ext;
+ Ancilla_SetOam(oam, x, y, kHookShot_Draw_Char[j], kHookShot_Draw_Flags[j] | 2 | HIBYTE(oam_priority_value), 0);
oam++;
}
if (i == 1)
@@ -3323,10 +3227,7 @@
if (kHookShot_Move_X[j])
x += kHookShot_Move_X[j] + r10;
if (!Hookshot_CheckProximityToLink(x, y)) {
- uint8 ext = Ancilla_SetOam_XY(oam, x, y);
- oam->charnum = 0x19;
- oam->flags = (frame_counter & 2) << 6 | 2 | HIBYTE(oam_priority_value);
- bytewise_extended_oam[oam - oam_buf] = ext;
+ Ancilla_SetOam(oam, x, y, 0x19, (frame_counter & 2) << 6 | 2 | HIBYTE(oam_priority_value), 0);
oam++;
}
} while (--n >= 0);
@@ -3348,10 +3249,7 @@
int j = link_pose_during_opening ? 4 : 0;
uint16 x = pt.x, y = pt.y;
for (int i = 3; i >= 0; i--, j++, oam++) {
- uint8 ext = Ancilla_SetOam_XY(oam, x, y);
- oam->charnum = kBedSpread_Char[j];
- oam->flags = kBedSpread_Flags[j] | 0xd | HIBYTE(oam_priority_value);
- bytewise_extended_oam[oam - oam_buf] = ext | 2;
+ Ancilla_SetOam(oam, x, y, kBedSpread_Char[j], kBedSpread_Flags[j] | 0xd | HIBYTE(oam_priority_value), 2);
x += 16;
if (i == 2)
x -= 32, y += 8;
@@ -3375,11 +3273,7 @@
link_dma_var5 = kBedSpread_Dma[ancilla_item_to_link[k]];
Point16U pt;
Ancilla_PrepOamCoord(k, &pt);
- OamEnt *oam = GetOamCurPtr();
- uint8 ext = Ancilla_SetOam_XY(oam, pt.x, pt.y);
- oam->charnum = 9;
- oam->flags = 0x24;
- bytewise_extended_oam[oam - oam_buf] = ext;
+ Ancilla_SetOam(GetOamCurPtr(), pt.x, pt.y, 9, 0x24, 0);
}
void Ancilla3B_SwordUpSparkle(int k) { // 88c167
@@ -3401,20 +3295,17 @@
return;
}
}
-
Point16U pt;
Ancilla_PrepOamCoord(k, &pt);
OamEnt *oam = GetOamCurPtr();
-
int j = ancilla_item_to_link[k] * 4;
for (int i = 0; i < 4; i++, j++) {
if (kAncilla_VictorySparkle_Char[j] != 0xff) {
- uint8 ext = Ancilla_SetOam_XY(oam,
- link_x_coord + kAncilla_VictorySparkle_X[j] - BG2HOFS_copy2,
- link_y_coord + kAncilla_VictorySparkle_Y[j] - BG2VOFS_copy2);
- oam->charnum = kAncilla_VictorySparkle_Char[j];
- oam->flags = kAncilla_VictorySparkle_Flags[j] | 4 | HIBYTE(oam_priority_value);
- bytewise_extended_oam[oam - oam_buf] = ext;
+ Ancilla_SetOam(oam,
+ link_x_coord + kAncilla_VictorySparkle_X[j] - BG2HOFS_copy2,
+ link_y_coord + kAncilla_VictorySparkle_Y[j] - BG2VOFS_copy2,
+ kAncilla_VictorySparkle_Char[j],
+ kAncilla_VictorySparkle_Flags[j] | 4 | HIBYTE(oam_priority_value), 0);
oam++;
}
}
@@ -3434,12 +3325,9 @@
ancilla_oam_idx[k] = Ancilla_AllocateOamFromRegion_A_or_D_or_F(k, 4);
Point16U info;
Ancilla_PrepOamCoord(k, &info);
- OamEnt *oam = GetOamCurPtr();
- uint8 ext = Ancilla_SetOam_XY(oam, info.x, info.y);
int j = ancilla_item_to_link[k];
- oam->charnum = kSwordChargeSpark_Char[j];
- oam->flags = kSwordChargeSpark_Flags[j] | HIBYTE(oam_priority_value);
- bytewise_extended_oam[oam - oam_buf] = ext;
+ Ancilla_SetOam(GetOamCurPtr(), info.x, info.y,
+ kSwordChargeSpark_Char[j], kSwordChargeSpark_Flags[j] | HIBYTE(oam_priority_value), 0);
}
void Ancilla35_MasterSwordReceipt(int k) { // 88c25f
@@ -3464,10 +3352,8 @@
return;
for (int i = 0; i < 4; i++, j++, oam++) {
- uint8 ext = Ancilla_SetOam_XY(oam, pt.x + kSwordCeremony_X[j], pt.y + kSwordCeremony_Y[j]);
- oam->charnum = kSwordCeremony_Char[j];
- oam->flags = kSwordCeremony_Flags[j] & ~0x30 | 4 | HIBYTE(oam_priority_value);
- bytewise_extended_oam[oam - oam_buf] = ext;
+ Ancilla_SetOam(oam, pt.x + kSwordCeremony_X[j], pt.y + kSwordCeremony_Y[j],
+ kSwordCeremony_Char[j], kSwordCeremony_Flags[j] & ~0x30 | 4 | HIBYTE(oam_priority_value), 0);
}
}
@@ -3648,20 +3534,14 @@
OamEnt *Ancilla_ReceiveItem_Draw(int k, int x, int y) { // 88c690
OamEnt *oam = GetOamCurPtr();
int j = ancilla_item_to_link[k];
- uint8 ext = Ancilla_SetOam_XY(oam, x, y);
oam->charnum = 0x24;
uint8 a = kWishPond2_OamFlags[j];
if (sign8(a))
a = ancilla_arr4[k];
- oam->flags = a * 2 | 0x30;
- ext |= kReceiveItem_Tab1[j];
- bytewise_extended_oam[oam - oam_buf] = ext;
+ Ancilla_SetOam(oam, x, y, 0x24, a * 2 | 0x30, kReceiveItem_Tab1[j]);
oam++;
- if (ext == 0) {
- ext = Ancilla_SetOam_XY(oam, x, y + 8);
- oam->charnum = 0x34;
- oam->flags = a * 2 | 0x30;
- bytewise_extended_oam[oam - oam_buf] = ext;
+ if (kReceiveItem_Tab1[j] == 0) {
+ Ancilla_SetOam(oam, x, y + 8, 0x34, a * 2 | 0x30, 0);
oam++;
}
return oam;
@@ -3830,10 +3710,9 @@
int j = ancilla_item_to_link[k] * 2;
for (int i = 0; i != 2; i++, j++) {
if (kObjectSplash_Draw_Char[j] != 0xff) {
- uint8 ext = Ancilla_SetOam_XY(oam, pt.x + kObjectSplash_Draw_X[j], pt.y + kObjectSplash_Draw_Y[j]);
- oam->charnum = kObjectSplash_Draw_Char[j];
- oam->flags = kObjectSplash_Draw_Flags[j] | 0x24;
- bytewise_extended_oam[oam - oam_buf] = ext | kObjectSplash_Draw_Ext[j];
+ Ancilla_SetOam(oam, pt.x + kObjectSplash_Draw_X[j], pt.y + kObjectSplash_Draw_Y[j],
+ kObjectSplash_Draw_Char[j], kObjectSplash_Draw_Flags[j] | 0x24,
+ kObjectSplash_Draw_Ext[j]);
oam++;
}
}
@@ -4073,11 +3952,7 @@
}
void AncillaDraw_GTCutsceneCrystal(OamEnt *oam, int x, int y) { // 88ceaa
- uint8 ext = Ancilla_SetOam_XY_safe(oam, x, y);
- oam->charnum = 0x24;
- oam->flags = 0x3c;
- int j = oam - oam_buf;
- bytewise_extended_oam[oam - oam_buf] = ext | 2;
+ Ancilla_SetOam_Safe(oam, x, y, 0x24, 0x3c, 2);
}
void GTCutscene_ActivateSparkle() { // 88cec7
@@ -4116,11 +3991,8 @@
int x = breaktowerseal_sparkle_x_hi[k] << 8 | breaktowerseal_sparkle_x_lo[k];
int y = breaktowerseal_sparkle_y_hi[k] << 8 | breaktowerseal_sparkle_y_lo[k];
- uint8 ext = Ancilla_SetOam_XY(oam, x, y);
int j = breaktowerseal_sparkle_var1[k];
- oam->charnum = kSwordChargeSpark_Char[j];
- oam->flags = kSwordChargeSpark_Flags[j] | 0x30;
- bytewise_extended_oam[oam - oam_buf] = ext;
+ Ancilla_SetOam(oam, x, y, kSwordChargeSpark_Char[j], kSwordChargeSpark_Flags[j] | 0x30, 0);
oam++;
}
return oam;
@@ -4152,10 +4024,7 @@
Point16U pt;
Ancilla_PrepAdjustedOamCoord(k, &pt);
OamEnt *oam = GetOamCurPtr();
- uint8 ext = Ancilla_SetOam_XY(oam, pt.x, pt.y - (int8)ancilla_z[k]);
- oam->charnum = 0x24;
- oam->flags = HIBYTE(oam_priority_value) | 4;
- bytewise_extended_oam[oam - oam_buf] = ext | 2;
+ Ancilla_SetOam(oam, pt.x, pt.y - (int8)ancilla_z[k], 0x24, HIBYTE(oam_priority_value) | 4, 2);
if (oam->y == 0xf0)
ancilla_type[k] = 0;
}
@@ -4229,12 +4098,8 @@
int i = ancilla_item_to_link[k];
if (sign8(i))
return;
- OamEnt *oam = GetOamCurPtr() + (weathervane_var14 >> 2);
- uint8 ext = Ancilla_SetOam_XY(oam, pt.x, pt.y);
- oam->charnum = kWeathervane_Explode_Char[i];
- oam->flags = 0x3c;
+ Ancilla_SetOam(GetOamCurPtr() + (weathervane_var14 >> 2), pt.x, pt.y, kWeathervane_Explode_Char[i], 0x3c, 0);
weathervane_var14 += 4;
- bytewise_extended_oam[oam - oam_buf] = ext;
}
void Ancilla38_CutsceneDuck(int k) { // 88d1d8
@@ -4283,11 +4148,9 @@
Point16U info;
Ancilla_PrepOamCoord(k, &info);
OamEnt *oam = GetOamCurPtr();
-
- uint8 ext = Ancilla_SetOam_XY(oam, info.x + kTravelBird_Draw_X[0], info.y + (int8)ancilla_z[k] + kTravelBird_Draw_Y[0]);
- oam->charnum = kTravelBird_Draw_Char[0];
- oam->flags = kTravelBird_Draw_Flags[0] | 0x30 | kTravelBirdIntro_Tab0[ancilla_dir[k] & 1];
- bytewise_extended_oam[oam - oam_buf] = ext | 2;
+ Ancilla_SetOam(oam, info.x + kTravelBird_Draw_X[0], info.y + (int8)ancilla_z[k] + kTravelBird_Draw_Y[0],
+ kTravelBird_Draw_Char[0],
+ kTravelBird_Draw_Flags[0] | 0x30 | kTravelBirdIntro_Tab0[ancilla_dir[k] & 1], 2);
oam++;
AncillaDraw_Shadow(oam, 1, info.x, info.y + 48, 0x30);
if (!sign16(info.x) && info.x >= 248) {
@@ -4336,10 +4199,8 @@
uint8 ext = kMorphPoof_Ext[j];
uint8 chr = kMorphPoof_Char[j];
for (int i = 0; i < 4; i++, oam++) {
- uint8 ext2 = Ancilla_SetOam_XY(oam, info.x + kMorphPoof_X[j * 4 + i], info.y + kMorphPoof_Y[j * 4 + i]);
- oam->charnum = chr;
- oam->flags = kMorphPoof_Flags[j * 4 + i] | 4 | HIBYTE(oam_priority_value);
- bytewise_extended_oam[oam - oam_buf] = ext | ext2;
+ Ancilla_SetOam(oam, info.x + kMorphPoof_X[j * 4 + i], info.y + kMorphPoof_Y[j * 4 + i], chr,
+ kMorphPoof_Flags[j * 4 + i] | 4 | HIBYTE(oam_priority_value), ext);
if (ext == 2)
break;
}
@@ -4377,10 +4238,8 @@
int j = ancilla_item_to_link[k] * 4;
for (int i = 0; i < 4; i++, j++, oam++) {
- uint8 ext = Ancilla_SetOam_XY(oam, pt.x + kBushPoof_Draw_X[j], pt.y + kBushPoof_Draw_Y[j]);
- oam->charnum = kBushPoof_Draw_Char[j];
- oam->flags = kBushPoof_Draw_Flags[j] | 4 | HIBYTE(oam_priority_value);
- bytewise_extended_oam[oam - oam_buf] = ext;
+ Ancilla_SetOam(oam, pt.x + kBushPoof_Draw_X[j], pt.y + kBushPoof_Draw_Y[j],
+ kBushPoof_Draw_Char[j], kBushPoof_Draw_Flags[j] | 4 | HIBYTE(oam_priority_value), 0);
}
}
@@ -4424,10 +4283,8 @@
uint8 chr = kSwordSwingSparkle_Char[k];
if (chr == 0xff)
continue;
- oam->charnum = chr;
- oam->flags = kSwordSwingSparkle_Flags[k] | 0x4 | (oam_priority_value >> 8);
- uint8 ext = Ancilla_SetOam_XY(oam, info.x + kSwordSwingSparkle_X[k], info.y + kSwordSwingSparkle_Y[k]);
- bytewise_extended_oam[oam - oam_buf] = ext;
+ Ancilla_SetOam(oam, info.x + kSwordSwingSparkle_X[k], info.y + kSwordSwingSparkle_Y[k],
+ chr, kSwordSwingSparkle_Flags[k] | 0x4 | (oam_priority_value >> 8), 0);
}
}
@@ -4510,10 +4367,7 @@
if (submodule_index == 0)
swordbeam_arr[i] = (swordbeam_arr[i] + 4) & 0x3f;
Point16U pt = Sparkle_PrepOamFromRadial(Ancilla_GetRadialProjection(swordbeam_arr[i], swordbeam_var2));
- uint8 ext = Ancilla_SetOam_XY(oam, pt.x, pt.y);
- oam->charnum = kSpinSpark_Char[i];
- oam->flags = flags | HIBYTE(oam_priority_value);
- bytewise_extended_oam[oam - oam_buf] = ext;
+ Ancilla_SetOam(oam, pt.x, pt.y, kSpinSpark_Char[i], flags | HIBYTE(oam_priority_value), 0);
} while (oam++, --i >= 0);
if (submodule_index == 0) {
@@ -4532,10 +4386,7 @@
if (t != 3) {
static const uint8 kSpinSpark_Char2[3] = {0xb7, 0x80, 0x83};
Point16U pt = Sparkle_PrepOamFromRadial(Ancilla_GetRadialProjection(swordbeam_var1, swordbeam_var2));
- uint8 ext = Ancilla_SetOam_XY(oam, pt.x, pt.y);
- oam->charnum = kSpinSpark_Char2[t];
- oam->flags = 4 | HIBYTE(oam_priority_value);
- bytewise_extended_oam[oam - oam_buf] = ext;
+ Ancilla_SetOam(oam, pt.x, pt.y, kSpinSpark_Char2[t], 4 | HIBYTE(oam_priority_value), 0);
}
endif_2:
if (ancilla_item_to_link[k] == 7)
@@ -4596,10 +4447,9 @@
OamEnt *oam = GetOamCurPtr();
for (int i = 0; i < 4; i++, j++) {
if (kInitialCaneSpark_Draw_Char[j] != 255) {
- uint8 ext = Ancilla_SetOam_XY(oam, pt.x + kInitialCaneSpark_Draw_X[j], pt.y + kInitialCaneSpark_Draw_Y[j]);
- oam->charnum = kInitialCaneSpark_Draw_Char[j];
- oam->flags = kInitialCaneSpark_Draw_Flags[j] & ~0x30 | HIBYTE(oam_priority_value);
- bytewise_extended_oam[oam - oam_buf] = ext;
+ Ancilla_SetOam(oam, pt.x + kInitialCaneSpark_Draw_X[j], pt.y + kInitialCaneSpark_Draw_Y[j],
+ kInitialCaneSpark_Draw_Char[j],
+ kInitialCaneSpark_Draw_Flags[j] & ~0x30 | HIBYTE(oam_priority_value), 0);
oam++;
}
}
@@ -4679,11 +4529,7 @@
if (!submodule_index)
swordbeam_arr[i] = (swordbeam_arr[i] + 3) & 0x3f;
Point16U pt = Sparkle_PrepOamFromRadial(Ancilla_GetRadialProjection(swordbeam_arr[i], swordbeam_var2));
- uint8 ext = Ancilla_SetOam_XY(oam, pt.x, pt.y);
- oam->charnum = kCaneSpark_Char[i];
- oam->flags = flags | HIBYTE(oam_priority_value);
- bytewise_extended_oam[oam - oam_buf] = ext;
-
+ Ancilla_SetOam(oam, pt.x, pt.y, kCaneSpark_Char[i], flags | HIBYTE(oam_priority_value), 0);
Ancilla_SetXY(k, pt.x + BG2HOFS_copy2, pt.y + BG2VOFS_copy2);
ancilla_dir[k] = 0;
Ancilla_CheckSpriteCollision(k);
@@ -4729,10 +4575,7 @@
if (submodule_index == 0)
swordbeam_arr[i] = (swordbeam_arr[i] + s) & 0x3f;
Point16U pt = Sparkle_PrepOamFromRadial(Ancilla_GetRadialProjection(swordbeam_arr[i], swordbeam_var2));
- uint8 ext = Ancilla_SetOam_XY(oam, pt.x, pt.y);
- oam->charnum = kSwordBeam_Char[i];
- oam->flags = flags | HIBYTE(oam_priority_value);
- bytewise_extended_oam[oam - oam_buf] = ext;
+ Ancilla_SetOam(oam, pt.x, pt.y, kSwordBeam_Char[i], flags | HIBYTE(oam_priority_value), 0);
}
if (submodule_index == 0) {
@@ -4751,10 +4594,7 @@
if (t != 3) {
static const uint8 kSwordBeam_Char2[3] = {0xb7, 0x80, 0x83};
Point16U pt = Sparkle_PrepOamFromRadial(Ancilla_GetRadialProjection(swordbeam_var1, swordbeam_var2));
- uint8 ext = Ancilla_SetOam_XY(oam, pt.x, pt.y);
- oam->charnum = kSwordBeam_Char2[t];
- oam->flags = 4 | HIBYTE(oam_priority_value);
- bytewise_extended_oam[oam - oam_buf] = ext;
+ Ancilla_SetOam(oam, pt.x, pt.y, kSwordBeam_Char2[t], 4 | HIBYTE(oam_priority_value), 0);
}
endif_2:
oam -= 4;
@@ -4784,10 +4624,7 @@
oam_priority_value = kSwordFullChargeSpark_Flags[ancilla_floor[k]] << 8;
OamEnt *oam = GetOamCurPtr();
- uint8 ext = Ancilla_SetOam_XY(oam, x, y);
- oam->charnum = 0xd7;
- oam->flags = HIBYTE(oam_priority_value) | 2;
- bytewise_extended_oam[oam - oam_buf] = ext;
+ Ancilla_SetOam(oam, x, y, 0xd7, HIBYTE(oam_priority_value) | 2, 0);
}
void Ancilla27_Duck(int k) { // 88dde8
@@ -4896,10 +4733,8 @@
int z = ancilla_z[k] ? ancilla_z[k] | ~0xff : 0;
int i = 0, n = ancilla_step[k] + 1;
do {
- uint8 ext = Ancilla_SetOam_XY(oam, info.x + (int8)kTravelBird_Draw_X[i], info.y + z + (int8)kTravelBird_Draw_Y[i]);
- oam->charnum = kTravelBird_Draw_Char[i];
- oam->flags = kTravelBird_Draw_Flags[i] | 0x30;
- bytewise_extended_oam[oam - oam_buf] = ext | 2;
+ Ancilla_SetOam(oam, info.x + (int8)kTravelBird_Draw_X[i], info.y + z + (int8)kTravelBird_Draw_Y[i],
+ kTravelBird_Draw_Char[i], kTravelBird_Draw_Flags[i] | 0x30, 2);
oam++;
} while (++i != n);
@@ -5198,10 +5033,8 @@
int j = ancilla_arr1[k] * 4;
int r8 = 0;
do {
- uint8 t = Ancilla_SetOam_XY_safe(oam, pt.x + kSomarianBlock_Draw_X[j], pt.y + kSomarianBlock_Draw_Y[j]);
- oam->charnum = 0xe9;
- oam->flags = kSomarianBlock_Draw_Flags[j] & ~0x30 | 2 | HIBYTE(oam_priority_value);
- bytewise_extended_oam[oam - oam_buf] = t;
+ Ancilla_SetOam_Safe(oam, pt.x + kSomarianBlock_Draw_X[j], pt.y + kSomarianBlock_Draw_Y[j], 0xe9,
+ kSomarianBlock_Draw_Flags[j] & ~0x30 | 2 | HIBYTE(oam_priority_value), 0);
oam++;
} while (j++, ++r8 & 3);
@@ -5276,10 +5109,9 @@
int j = ancilla_item_to_link[k] * 2;
for (int i = 0; i < 2; i++, j++, oam++) {
if (kSomariaBlockFizzle_Char[j] != 0xff) {
- uint8 ext = Ancilla_SetOam_XY(oam, x + kSomariaBlockFizzle_X[j], y + kSomariaBlockFizzle_Y[j]);
- oam->charnum = kSomariaBlockFizzle_Char[j];
- oam->flags = kSomariaBlockFizzle_Flags[j] & ~0x30 | HIBYTE(oam_priority_value);
- bytewise_extended_oam[oam - oam_buf] = ext;
+ Ancilla_SetOam(oam, x + kSomariaBlockFizzle_X[j], y + kSomariaBlockFizzle_Y[j],
+ kSomariaBlockFizzle_Char[j],
+ kSomariaBlockFizzle_Flags[j] & ~0x30 | HIBYTE(oam_priority_value), 0);
}
}
}
@@ -5338,10 +5170,8 @@
int8 z = ancilla_z[k] + (ancilla_K[k] == 3 && BYTE(link_z_coord) != 0xff ? BYTE(link_z_coord) : 0);
int j = ancilla_item_to_link[k] * 8;
for (int i = 0; i != 8; i++, j++, oam++) {
- uint8 ext = Ancilla_SetOam_XY(oam, pt.x + kSomarianBlockDivide_X[j], pt.y + kSomarianBlockDivide_Y[j] - z);
- oam->charnum = kSomarianBlockDivide_Char[j];
- oam->flags = kSomarianBlockDivide_Flags[j] & ~0x30 | HIBYTE(oam_priority_value);
- bytewise_extended_oam[oam - oam_buf] = ext;
+ Ancilla_SetOam(oam, pt.x + kSomarianBlockDivide_X[j], pt.y + kSomarianBlockDivide_Y[j] - z,
+ kSomarianBlockDivide_Char[j], kSomarianBlockDivide_Flags[j] & ~0x30 | HIBYTE(oam_priority_value), 0);
}
}
@@ -5360,10 +5190,7 @@
int j = (ancilla_timer[k] & 0xf8) >> 1;
do {
if (kLampFlame_Draw_Char[j] != 0xff) {
- uint8 ext = Ancilla_SetOam_XY(oam, pt.x + kLampFlame_Draw_X[j], pt.y + kLampFlame_Draw_Y[j]);
- oam->charnum = kLampFlame_Draw_Char[j];
- oam->flags = HIBYTE(oam_priority_value) | 2;
- bytewise_extended_oam[oam - oam_buf] = ext;
+ Ancilla_SetOam(oam, pt.x + kLampFlame_Draw_X[j], pt.y + kLampFlame_Draw_Y[j], kLampFlame_Draw_Char[j], HIBYTE(oam_priority_value) | 2, 0);
oam++;
}
} while (++j & 3);
@@ -5410,10 +5237,8 @@
int j = ancilla_item_to_link[k] * 2;
for (int i = 0; i != 2; i++, j++, oam++) {
if (kWaterfallSplash_Char[j] != 0xff) {
- uint8 ext = Ancilla_SetOam_XY(oam, pt.x + kWaterfallSplash_X[j], pt.y + kWaterfallSplash_Y[j]);
- oam->charnum = kWaterfallSplash_Char[j];
- oam->flags = kWaterfallSplash_Flags[j] | 0x30;
- bytewise_extended_oam[oam - oam_buf] = ext | kWaterfallSplash_Ext[j];
+ Ancilla_SetOam(oam, pt.x + kWaterfallSplash_X[j], pt.y + kWaterfallSplash_Y[j], kWaterfallSplash_Char[j],
+ kWaterfallSplash_Flags[j] | 0x30, kWaterfallSplash_Ext[j]);
}
}
}
@@ -5427,10 +5252,7 @@
OamEnt *oam = GetOamCurPtr();
uint16 x = pt.x, y = pt.y;
for (int i = 0; i < 4; i++, oam++) {
- uint8 ext = Ancilla_SetOam_XY(oam, x, y);
- oam->charnum = kAncilla_Gravestone_Char[i];
- oam->flags = kAncilla_Gravestone_Flags[i] | 0x3d;
- bytewise_extended_oam[oam - oam_buf] = ext | 2;
+ Ancilla_SetOam(oam, x, y, kAncilla_Gravestone_Char[i], kAncilla_Gravestone_Flags[i] | 0x3d, 2);
x += 16;
if (i == 1)
x -= 32, y += 8;
@@ -5493,17 +5315,10 @@
int j = skullwoodsfire_var0[k];
uint16 x = skullwoodsfire_x_arr[k] - BG2HOFS_copy2;
uint16 y = skullwoodsfire_y_arr[k] - BG2VOFS_copy2 + kSkullWoodsFire_Draw_Y[j];
- uint8 ext2 = Ancilla_SetOam_XY(oam, x, y);
- oam->charnum = kSkullWoodsFire_Draw_Char[j];
- oam->flags = 0x32;
- uint8 ext = kSkullWoodsFire_Draw_Ext[j];
- bytewise_extended_oam[oam - oam_buf] = ext | ext2;
+ Ancilla_SetOam(oam, x, y, kSkullWoodsFire_Draw_Char[j], 0x32, kSkullWoodsFire_Draw_Ext[j]);
oam++;
if (kSkullWoodsFire_Draw_Ext[j] != 2) {
- uint8 ext2 = Ancilla_SetOam_XY(oam, x + 8, y);
- oam->charnum = kSkullWoodsFire_Draw_Char[j] + 1;
- oam->flags = 0x32;
- bytewise_extended_oam[oam - oam_buf] = ext | ext2;
+ Ancilla_SetOam(oam, x + 8, y, kSkullWoodsFire_Draw_Char[j] + 1, 0x32, kSkullWoodsFire_Draw_Ext[j]);
oam++;
}
}
@@ -5522,12 +5337,11 @@
int j = ancilla_item_to_link[k] * 6;
for (int i = 0; i < 6; i++, j++) {
if (kSkullWoodsFire_Draw2_Char[j] != 0xff) {
- uint8 ext = Ancilla_SetOam_XY(oam,
+ Ancilla_SetOam(oam,
168 - BG2HOFS_copy2 + kSkullWoodsFire_Draw2_X[j],
- 200 - BG2VOFS_copy2 + kSkullWoodsFire_Draw2_Y[j]);
- oam->charnum = kSkullWoodsFire_Draw2_Char[j];
- oam->flags = kSkullWoodsFire_Draw2_Flags[j] | 0x32;
- bytewise_extended_oam[oam - oam_buf] = ext | kSkullWoodsFire_Draw2_Ext[j];
+ 200 - BG2VOFS_copy2 + kSkullWoodsFire_Draw2_Y[j],
+ kSkullWoodsFire_Draw2_Char[j],
+ kSkullWoodsFire_Draw2_Flags[j] | 0x32, kSkullWoodsFire_Draw2_Ext[j]);
oam++;
}
}
@@ -5624,14 +5438,11 @@
Ancilla_PrepOamCoord(k, &pt);
OamEnt *oam = GetOamCurPtr();
int t = (ancilla_step[k] == 1 && ancilla_L[k]) ? ancilla_item_to_link[k] + 1 : 0;
- uint8 ext = Ancilla_SetOam_XY(oam, pt.x, pt.y - (int8)ancilla_z[k]);
if (t != 0)
t += 1;
else
t = (frame_counter >> 2) & 1;
- oam->charnum = kAncilla_RevivalFaerie_Tab1[t];
- oam->flags = 0x74;
- bytewise_extended_oam[oam - oam_buf] = ext | 2;
+ Ancilla_SetOam(oam, pt.x, pt.y - (int8)ancilla_z[k], kAncilla_RevivalFaerie_Tab1[t], 0x74, 2);
if (oam->y == 0xf0) {
ancilla_step[k] = 3;
submodule_index++;
@@ -5714,17 +5525,9 @@
OamEnt *oam = GetOamCurPtr();
int k = flag_for_boomerang_in_place;
do {
- uint8 ext = Ancilla_SetOam_XY(oam, Ancilla_GetX(k), 0x57);
- oam->charnum = kGameOverText_Chars[k * 2 + 0];
- oam->flags = 0x3c;
- bytewise_extended_oam[oam - oam_buf] = ext;
- oam++;
- ext = Ancilla_SetOam_XY(oam, Ancilla_GetX(k), 0x5f);
- oam->charnum = kGameOverText_Chars[k * 2 + 1];
- oam->flags = 0x3c;
- bytewise_extended_oam[oam - oam_buf] = ext;
- oam++;
- } while (--k >= 0);
+ Ancilla_SetOam(oam + 0, Ancilla_GetX(k), 0x57, kGameOverText_Chars[k * 2 + 0], 0x3c, 0);
+ Ancilla_SetOam(oam + 1, Ancilla_GetX(k), 0x5f, kGameOverText_Chars[k * 2 + 1], 0x3c, 0);
+ } while (oam += 2, --k >= 0);
}
int AncillaAdd_AddAncilla_Bank08(uint8 type, uint8 y) { // 88f631
@@ -5754,34 +5557,6 @@
info->y = Ancilla_GetY(k) - BG2VOFS_copy;
}
-
-uint8 Ancilla_SetOam_XY(OamEnt *oam, uint16 x, uint16 y) { // 88f6e1
- uint8 rv = 0;
- uint8 yval = 0xf0;
- int xt = enhanced_features0 ? 0x40 : 0;
- if ((uint16)(x + xt) < 256 + xt * 2 && y < 256) {
- rv = (x >> 8) & 1;
- oam->x = x;
- if (y < 0xf0)
- yval = y;
- }
- oam->y = yval;
- return rv;
-}
-
-uint8 Ancilla_SetOam_XY_safe(OamEnt *oam, uint16 x, uint16 y) { // 88f702
- uint8 rv = 0;
- oam->x = x;
- if ((uint16)(x + 0x80) < 0x180) {
- rv = (x >> 8) & 1;
- oam->y = y;
- if ((uint16)(y + 0x10) < 0x100)
- return rv;
- }
- oam->y = 0xf0;
- return rv;
-}
-
bool Ancilla_CheckLinkCollision(int k, int j, CheckPlayerCollOut *out) { // 88f76b
static const int16 kAncilla_Coll_Yoffs[5] = {0, 8, 8, 8, 0};
static const int16 kAncilla_Coll_Xoffs[5] = {0, 8, 8, 8, 0};
@@ -5820,19 +5595,13 @@
if (k == 2)
x += 4;
- uint8 ext = Ancilla_SetOam_XY_safe(oam, x, y);
- oam->charnum = kAncilla_DrawShadow_Char[k * 2];
- oam->flags = kAncilla_DrawShadow_Flags[k * 2] & ~0x30 | pal;
- bytewise_extended_oam[oam - oam_buf] = ext;
- oam++;
-
+ Ancilla_SetOam_Safe(oam, x, y,
+ kAncilla_DrawShadow_Char[k * 2],
+ kAncilla_DrawShadow_Flags[k * 2] & ~0x30 | pal, 0);
uint8 ch = kAncilla_DrawShadow_Char[k * 2 + 1];
if (ch != 0xff) {
x += 8;
- ext = Ancilla_SetOam_XY_safe(oam, x, y);
- oam->charnum = ch;
- oam->flags = kAncilla_DrawShadow_Flags[k * 2 + 1] & ~0x30 | pal;
- bytewise_extended_oam[oam - oam_buf] = ext;
+ Ancilla_SetOam_Safe(oam + 1, x, y, ch, kAncilla_DrawShadow_Flags[k * 2 + 1] & ~0x30 | pal, 0);
}
}
@@ -7191,11 +6960,8 @@
Oam_AllocateFromRegionB(4);
Point16U info;
Ancilla_PrepOamCoord(k, &info);
- OamEnt *oam = GetOamCurPtr();
- uint8 ext = Ancilla_SetOam_XY(oam, info.x, info.y);
- oam->charnum = kMotiveDashDust_Draw_Char[ancilla_item_to_link[k]];
- oam->flags = 4 | HIBYTE(oam_priority_value);
- bytewise_extended_oam[oam - oam_buf] = ext;
+ Ancilla_SetOam(GetOamCurPtr(), info.x, info.y,
+ kMotiveDashDust_Draw_Char[ancilla_item_to_link[k]], 4 | HIBYTE(oam_priority_value), 0);
}
uint8 Ancilla_CalculateSfxPan(int k) { // 8dbb5e
--- a/ancilla.h
+++ b/ancilla.h
@@ -197,8 +197,6 @@
int AncillaAdd_AddAncilla_Bank08(uint8 type, uint8 y);
void Ancilla_PrepOamCoord(int k, Point16U *info);
void Ancilla_PrepAdjustedOamCoord(int k, Point16U *info);
-uint8 Ancilla_SetOam_XY(OamEnt *oam, uint16 x, uint16 y);
-uint8 Ancilla_SetOam_XY_safe(OamEnt *oam, uint16 x, uint16 y);
bool Ancilla_CheckLinkCollision(int k, int j, CheckPlayerCollOut *out);
bool Hookshot_CheckProximityToLink(int x, int y);
bool Ancilla_CheckForEntranceTrigger(int what);
--- a/attract.c
+++ b/attract.c
@@ -109,13 +109,8 @@
void Attract_DrawSpriteSet2(const AttractOamInfo *p, int n) {
OamEnt *oam = &oam_buf[attract_oam_idx + 64];
attract_oam_idx += n;
- for (; n--; oam++) {
- oam->x = attract_x_base + p[n].x;
- oam->y = attract_y_base + p[n].y;
- oam->charnum = p[n].c;
- oam->flags = p[n].f;
- bytewise_extended_oam[oam - oam_buf] = p[n].e;
- }
+ for (; n--; oam++)
+ SetOamPlain(oam, attract_x_base + p[n].x, attract_y_base + p[n].y, p[n].c, p[n].f, p[n].e);
}
void Attract_ZeldaPrison_Case0() {
@@ -203,19 +198,10 @@
void Attract_ZeldaPrison_DrawA() {
OamEnt *oam = &oam_buf[64 + attract_oam_idx];
-
uint8 ext = attract_x_base_hi ? 3 : 2;
- bytewise_extended_oam[oam - oam_buf] = ext;
- bytewise_extended_oam[oam - oam_buf + 1] = ext;
-
- oam[0].x = oam[1].x = attract_x_base;
int j = (attract_var1 >> 3) & 1;
- oam[0].y = attract_y_base + j;
- oam[1].y = attract_y_base + 10;
- oam[0].charnum = 6;
- oam[1].charnum = j ? 10 : 8;
- oam[0].flags = oam[1].flags = 0x3d;
-
+ SetOamPlain(oam + 0, attract_x_base, attract_y_base + j, 6, 0x3d, ext);
+ SetOamPlain(oam + 1, attract_x_base, attract_y_base + 10, j ? 10 : 8, 0x3d, ext);
attract_oam_idx += 2;
}
@@ -1045,24 +1031,14 @@
OamEnt *oam = &oam_buf[attract_oam_idx + 64];
attract_oam_idx += n + 1;
do {
- oam->x = attract_x_base + xp[n];
- oam->y = attract_y_base + yp[n];
- oam->charnum = cp[n];
- oam->flags = fp[n];
- bytewise_extended_oam[oam - oam_buf] = ep[n];
+ SetOamPlain(oam, attract_x_base + xp[n], attract_y_base + yp[n], cp[n], fp[n], ep[n]);
} while (oam++, --n >= 0);
}
void Attract_DrawZelda() { // 8cf9e8
OamEnt *oam = &oam_buf[64 + attract_oam_idx];
- bytewise_extended_oam[oam - oam_buf] = 2;
- oam[0].x = oam[1].x = 0x60;
- oam[0].y = attract_x_base;
- oam[1].y = attract_x_base + 10;
- oam[0].charnum = 0x28;
- oam[1].charnum = 0x2a;
- oam[0].flags = 0x29;
- oam[1].flags = 0x29;
+ SetOamPlain(oam + 0, 0x60, attract_x_base, 0x28, 0x29, 2);
+ SetOamPlain(oam + 1, 0x60, attract_x_base + 10, 0x2a, 0x29, 2);
attract_oam_idx += 2;
}
--- a/ending.c
+++ b/ending.c
@@ -1192,14 +1192,8 @@
void Intro_DisplayLogo() { // 8ced82
static const uint8 kIntroLogo_X[4] = { 0x60, 0x70, 0x80, 0x88 };
static const uint8 kIntroLogo_Tile[4] = { 0x69, 0x6b, 0x6d, 0x6e };
- OamEnt *oam = oam_buf;
- for (int i = 0; i < 4; i++) {
- oam[i].x = kIntroLogo_X[i];
- oam[i].y = 0x68;
- oam[i].charnum = kIntroLogo_Tile[i];
- oam[i].flags = 0x32;
- bytewise_extended_oam[i] = 2;
- }
+ for (int i = 0; i < 4; i++)
+ SetOamPlain(&oam_buf[i], kIntroLogo_X[i], 0x68, kIntroLogo_Tile[i], 0x32, 2);
}
void Intro_SetupSwordAndIntroFlash() { // 8cfe45
@@ -1227,12 +1221,8 @@
static const uint8 kIntroSword_Char[10] = { 0, 2, 0x20, 0x22, 4, 6, 8, 0xa, 0xc, 0xe };
static const uint8 kIntroSword_X[10] = { 0x40, 0x40, 0x30, 0x50, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40 };
static const uint16 kIntroSword_Y[10] = { 0x10, 0x20, 0x28, 0x28, 0x30, 0x40, 0x50, 0x60, 0x70, 0x80 };
- bytewise_extended_oam[0x52 + j] = 2;
- oam[j].charnum = kIntroSword_Char[j];
- oam[j].flags = 0x21;
- oam[j].x = kIntroSword_X[j];
uint16 y = intro_sword_ypos + kIntroSword_Y[j];
- oam[j].y = ((y & 0xff00) ? 0xf8 : y) - 8;
+ SetOamPlain(&oam[j], kIntroSword_X[j], ((y & 0xff00) ? 0xf8 : y) - 8, kIntroSword_Char[j], 0x21, 2);
}
if (intro_sword_ypos != 30) {
@@ -1265,11 +1255,7 @@
intro_sword_18 = kSwordSparkle_Tab[intro_sword_19];
}
static const uint8 kSwordSparkle_Char[7] = { 0x28, 0x37, 0x27, 0x36, 0x27, 0x37, 0x28 };
- bytewise_extended_oam[0x50] = 0;
- oam_buf[0x50].x = 0x44;
- oam_buf[0x50].y = 0x43;
- oam_buf[0x50].flags = 0x25;
- oam_buf[0x50].charnum = kSwordSparkle_Char[intro_sword_19];
+ SetOamPlain(&oam_buf[0x50], 0x44, 0x43, kSwordSparkle_Char[intro_sword_19], 0x25, 0);
break;
}
case 2: {
@@ -1277,16 +1263,9 @@
int k = intro_sword_19;
if (k >= 7)
return;
- bytewise_extended_oam[0x50] = 0;
- bytewise_extended_oam[0x51] = 0;
- oam_buf[0x51].x = oam_buf[0x50].x = 0x42;
-
uint8 y = (intro_sword_21 < 0x50 ? intro_sword_21 : 0x4f) + intro_sword_ypos + 0x31;
- oam_buf[0x50].y = y;
- oam_buf[0x51].y = y + 8;
- oam_buf[0x50].charnum = kIntroSwordSparkle_Char[k];
- oam_buf[0x51].charnum = kIntroSwordSparkle_Char[k + 1];
- oam_buf[0x51].flags = oam_buf[0x50].flags = 0x23;
+ SetOamPlain(&oam_buf[0x50], 0x42, y + 0, kIntroSwordSparkle_Char[k + 0], 0x23, 0);
+ SetOamPlain(&oam_buf[0x51], 0x42, y + 8, kIntroSwordSparkle_Char[k + 1], 0x23, 0);
if (intro_sword_18 == 0) {
intro_sword_21 += 4;
if (intro_sword_21 == 0x4 || intro_sword_21 == 0x48 || intro_sword_21 == 0x4c || intro_sword_21 == 0x58)
@@ -2657,14 +2636,10 @@
}
void Credits_HangForever() { // 8ec41a
- static const OamEntSigned kEndSequence37_Oams[4] = {
- {-96, -72, 0x00, 0x3b},
- {-80, -72, 0x02, 0x3b},
- {-64, -72, 0x04, 0x3b},
- {-48, -72, 0x06, 0x3b},
- };
- memcpy(oam_buf, kEndSequence37_Oams, 4 * 4);
- bytewise_extended_oam[0] = bytewise_extended_oam[1] = bytewise_extended_oam[2] = bytewise_extended_oam[3] = 2;
+ SetOamPlain(&oam_buf[0], -96, -72, 0x00, 0x3b, 2);
+ SetOamPlain(&oam_buf[1], -80, -72, 0x02, 0x3b, 2);
+ SetOamPlain(&oam_buf[2], -64, -72, 0x04, 0x3b, 2);
+ SetOamPlain(&oam_buf[3], -48, -72, 0x06, 0x3b, 2);
}
void CrystalCutscene_InitializePolyhedral() { // 9ecdd9
--- a/messaging.c
+++ b/messaging.c
@@ -966,12 +966,7 @@
}
void GameOver_AnimateChoiceFairy() { // 89f67a
- int spr = 0x14;
- bytewise_extended_oam[spr] = 2;
- oam_buf[spr].x = 0x34;
- oam_buf[spr].y = kDeath_SprY0[subsubmodule_index];
- oam_buf[spr].charnum = kDeath_SprChar0[frame_counter >> 3 & 1];
- oam_buf[spr].flags = 0x78;
+ SetOamPlain(&oam_buf[0x14], 0x34, kDeath_SprY0[subsubmodule_index], kDeath_SprChar0[frame_counter >> 3 & 1], 0x78, 2);
}
void GameOver_InitializeRevivalFairy() { // 89f6a4
@@ -1626,11 +1621,7 @@
r14_x -= 4;
r15_y -= 4;
}
- bytewise_extended_oam[spr] = r11_ext;
- oam_buf[spr].x = r14_x;
- oam_buf[spr].y = r15_y;
- oam_buf[spr].charnum = r13_char;
- oam_buf[spr].flags = r12_flags;
+ SetOamPlain(&oam_buf[spr], r14_x, r15_y, r13_char, r12_flags, r11_ext);
}
bool OverworldMap_CheckForPendant(int k) { // 8ac5a9
@@ -2045,33 +2036,23 @@
if (a >= 0)
r3 -= a;
}
- bytewise_extended_oam[spr_pos] = 2;
- oam_buf[spr_pos].x = 0x19;
- oam_buf[spr_pos].y = kDungMap_Tab33[r3] - 4;
- oam_buf[spr_pos].charnum = 0;
- oam_buf[spr_pos].flags = overworld_palette_swap_flag ? 0x30 : 0x3e;
+ SetOamPlain(&oam_buf[spr_pos], 0x19, kDungMap_Tab33[r3] - 4, 0, overworld_palette_swap_flag ? 0x30 : 0x3e, 2);
}
int DungeonMap_DrawBlinkingIndicator(int spr_pos) { // 8aeb50
- bytewise_extended_oam[spr_pos] = 0;
- oam_buf[spr_pos].x = dungmap_var3 - 3;
- oam_buf[spr_pos].y = ((dungmap_var5 < 256) ? dungmap_var5 : 0xf0) - 3;
- oam_buf[spr_pos].charnum = 0x34;
- oam_buf[spr_pos].flags = kDungMap_Tab38[frame_counter >> 2 & 3];
+ SetOamPlain(&oam_buf[spr_pos], dungmap_var3 - 3, ((dungmap_var5 < 256) ? dungmap_var5 : 0xf0) - 3, 0x34, kDungMap_Tab38[frame_counter >> 2 & 3], 0);
return spr_pos + 1;
}
int DungeonMap_DrawLocationMarker(int spr_pos, uint16 r14) { // 8aeba8
for (int i = 3; i >= 0; i--, spr_pos++) {
- bytewise_extended_oam[spr_pos] = 2;
- oam_buf[spr_pos].x = kDungMap_Tab29[i] + (dungmap_var3 & 0xf0);
uint8 r15 = dungmap_var6 + kDungMap_Tab24[r14];
- oam_buf[spr_pos].y = r15 + kDungMap_Tab30[i];
- oam_buf[spr_pos].charnum = 0;
int fr = (frame_counter >> 2) & 1;
- if ((dungmap_var5 + 1 & 0xf0) == ++r15 && dungmap_var5 < 256)
+ if ((dungmap_var5 + 1 & 0xf0) == r15 + 1 && dungmap_var5 < 256)
fr += 2;
- oam_buf[spr_pos].flags = kDungMap_Tab32[fr] | kDungMap_Tab31[i];
+ SetOamPlain(&oam_buf[spr_pos], kDungMap_Tab29[i] + (dungmap_var3 & 0xf0),
+ r15 + kDungMap_Tab30[i],
+ 0, kDungMap_Tab32[fr] | kDungMap_Tab31[i], 2);
}
return spr_pos;
}
@@ -2094,17 +2075,9 @@
r2--;
r3 = -r3;
do {
- bytewise_extended_oam[spr_pos+0] = 0;
- bytewise_extended_oam[spr_pos+1] = 0;
- oam_buf[spr_pos + 0].x = 0x30;
- oam_buf[spr_pos + 1].x = 0x38;
- oam_buf[spr_pos + 0].y = r4;
- oam_buf[spr_pos + 1].y = r4;
+ SetOamPlain(&oam_buf[spr_pos + 0], 0x30, r4, sign8(r2) ? 0x1c : kDungMap_Tab34[r2], 0x3d, 0);
+ SetOamPlain(&oam_buf[spr_pos + 1], 0x38, r4, sign8(r2) ? kDungMap_Tab34[r2 ^ 0xff] : 0x1d, 0x3d, 0);
r4 += 16;
- oam_buf[spr_pos + 0].flags = 0x3d;
- oam_buf[spr_pos + 1].flags = 0x3d;
- oam_buf[spr_pos + 0].charnum = sign8(r2) ? 0x1c : kDungMap_Tab34[r2];
- oam_buf[spr_pos + 1].charnum = sign8(r2) ? kDungMap_Tab34[r2 ^ 0xff] : 0x1d;
} while (spr_pos += 2, r2-- != r3);
return spr_pos;
}
@@ -2134,17 +2107,9 @@
uint8 x = 40;
int spr_pos = 0x40 + kDungMap_Tab35[flag];
for (int i = 3; i >= 0; i--, spr_pos++) {
- bytewise_extended_oam[spr_pos+0] = 0;
- bytewise_extended_oam[spr_pos+4] = 0;
- oam_buf[spr_pos + 0].x = x;
- oam_buf[spr_pos + 4].x = x;
- oam_buf[spr_pos + 0].y = y + flag * 16;
- oam_buf[spr_pos + 4].y = y + flag * 16 + 8;
- oam_buf[spr_pos + 0].charnum = kDungMap_Tab36[i];
- oam_buf[spr_pos + 4].charnum = kDungMap_Tab36[i];
uint8 t = 0x3d | (i ? 0 : 0x40);
- oam_buf[spr_pos + 0].flags = t;
- oam_buf[spr_pos + 4].flags = t | 0x80;
+ SetOamPlain(&oam_buf[spr_pos + 0], x, y + flag * 16 + 0, kDungMap_Tab36[i], t, 0);
+ SetOamPlain(&oam_buf[spr_pos + 4], x, y + flag * 16 + 8, kDungMap_Tab36[i], t | 0x80, 0);
x += 8;
}
} while (flag--);
@@ -2157,12 +2122,8 @@
spr_pos = DungeonMap_DrawBossIconByFloor(spr_pos);
if ((frame_counter & 0xf) >= 10)
return spr_pos;
- bytewise_extended_oam[spr_pos] = 0;
uint16 xy = kDungMap_Tab37[dung];
- oam_buf[spr_pos].x = (xy >> 8) + dungmap_var7 + 0x90;
- oam_buf[spr_pos].y = (dungmap_var8 < 256) ? xy + dungmap_var8 : 0xf0;
- oam_buf[spr_pos].charnum = 0x31;
- oam_buf[spr_pos].flags = 0x33;
+ SetOamPlain(&oam_buf[spr_pos], (xy >> 8) + dungmap_var7 + 0x90, (dungmap_var8 < 256) ? xy + dungmap_var8 : 0xf0, 0x31, 0x33, 0);
return spr_pos + 1;
}
@@ -2179,12 +2140,7 @@
}
if ((frame_counter & 0xf) >= 10)
return spr_pos;
- bytewise_extended_oam[spr_pos] = 0;
- uint16 xy = kDungMap_Tab37[dung];
- oam_buf[spr_pos].x = 0x4C;
- oam_buf[spr_pos].y = kDungMap_Tab33[r3];
- oam_buf[spr_pos].charnum = 0x31;
- oam_buf[spr_pos].flags = 0x33;
+ SetOamPlain(&oam_buf[spr_pos], 0x4c, kDungMap_Tab33[r3], 0x31, 0x33, 0);
return spr_pos + 1;
}
@@ -3021,13 +2977,7 @@
return;
uint8 y = link_y_coord + 16 - BG2VOFS_copy2;
uint8 x = link_x_coord + 7 - BG2HOFS_copy2;
-
- int spr = 0x74;
- bytewise_extended_oam[spr] = 2;
- oam_buf[spr].x = x;
- oam_buf[spr].y = y;
- oam_buf[spr].charnum = 0xaa;
- oam_buf[spr].flags = kDeath_SprFlags[link_is_on_lower_level] | 2;
+ SetOamPlain(&oam_buf[0x74], x, y, 0xaa, kDeath_SprFlags[link_is_on_lower_level] | 2, 2);
}
void Death_PrepFaint() { // 8ffa6f
--- a/player.c
+++ b/player.c
@@ -6127,13 +6127,8 @@
y -= BG2VOFS_copy2 + 1;
x -= BG2HOFS_copy2;
uint8 ch = kPushedblock_Char[kPushedBlock_Tab1[pushedblocks_some_index]];
- if (ch != 0xff) {
- oam->x = x;
- oam->y = y;
- oam->charnum = ch;
- oam->flags = 0x20;
- bytewise_extended_oam[oam - oam_buf] = 2;
- }
+ if (ch != 0xff)
+ SetOamPlain(oam, x, y, ch, 0x20, 2);
}
void Link_Initialize() { // 87f13c
--- a/select_file.c
+++ b/select_file.c
@@ -5,6 +5,7 @@
#include "snes/snes_regs.h"
#include "overworld.h"
#include "messaging.h"
+#include "sprite.h"
#define selectfile_R16 g_ram[0xc8]
#define selectfile_R17 g_ram[0xc9]
@@ -45,36 +46,18 @@
uint8 x = 0x34;
uint8 y = kSelectFile_Draw_Y[k];
- oam[0].x = oam[1].x = x + 0xc;
- oam[0].y = y - 5;
- oam[1].y = y + 3;
- oam[0].flags = oam[1].flags = kSelectFile_Draw_Flags[k];
uint8 sword = sram[kSrmOffs_Sword] - 1;
+ uint8 swordchar = kSelectFile_Draw_SwordChar[sign8(sword) ? 0 : sword];
+ SetOamPlain(oam + 0, x + 0xc, y - 5, swordchar, kSelectFile_Draw_Flags[k], 0);
+ SetOamPlain(oam + 1, x + 0xc, y + 3, swordchar + 16, kSelectFile_Draw_Flags[k], 0);
if (sign8(sword))
- oam[1].y = oam[0].y = 0xf0, sword = 0;
- oam[0].charnum = kSelectFile_Draw_SwordChar[sword];
- oam[1].charnum = oam[0].charnum + 16;
- bytewise_extended_oam[oam - oam_buf] = bytewise_extended_oam[oam - oam_buf + 1] = 0;
-
- oam += 2;
- oam[0].x = x - 5;
- oam[0].y = y + 10;
+ oam[1].y = oam[0].y = 0xf0;
uint8 shield = sram[kSrmOffs_Shield] - 1;
+ SetOamPlain(oam + 2, x - 5, y + 10, kSelectFile_Draw_ShieldChar[sign8(shield) ? 0 : shield], kSelectFile_Draw_Flags2[k], 2);
if (sign8(shield))
- oam[0].y = 0xf0, shield = 0;
- oam[0].charnum = kSelectFile_Draw_ShieldChar[shield];
- oam[0].flags = kSelectFile_Draw_Flags2[k];
- bytewise_extended_oam[oam - oam_buf] = 2;
- oam++;
-
- oam[0].x = oam[1].x = x;
- oam[0].y = y;
- oam[1].y = y + 8;
- oam[0].charnum = 0;
- oam[1].charnum = 2;
- oam[0].flags = kSelectFile_Draw_Flags3[k];
- oam[1].flags = oam[0].flags | 0x40;
- bytewise_extended_oam[oam - oam_buf] = bytewise_extended_oam[oam - oam_buf + 1] = 2;
+ oam[2].y = 0xf0;
+ SetOamPlain(oam + 3, x, y + 0, 0, kSelectFile_Draw_Flags3[k], 2);
+ SetOamPlain(oam + 4, x, y + 8, 2, kSelectFile_Draw_Flags3[k] | 0x40, 2);
}
void SelectFile_Func6_DrawOams2(int k) {
@@ -102,11 +85,7 @@
int i = (digits[2] != 0) ? 2 : (digits[1] != 0) ? 1 : 0;
OamEnt *oam = oam_buf + kSelectFile_DrawDigit_OamIdx[k] / 4;
do {
- oam->charnum = kSelectFile_DrawDigit_Char[digits[i]];
- oam->x = x + kSelectFile_DrawDigit_X[i];
- oam->y = y + 0x10;
- oam->flags = 0x3c;
- bytewise_extended_oam[oam - oam_buf] = 0;
+ SetOamPlain(oam, x + kSelectFile_DrawDigit_X[i], y + 0x10, kSelectFile_DrawDigit_Char[digits[i]], 0x3c, 0);
} while (oam++, --i >= 0);
}
@@ -743,11 +722,7 @@
}
void FileSelect_DrawFairy(uint8 x, uint8 y) { // 8cd7a5
- oam_buf[0].x = x;
- oam_buf[0].y = y;
- oam_buf[0].charnum = frame_counter & 8 ? 0xaa : 0xa8;
- oam_buf[0].flags = 0x7e;
- bytewise_extended_oam[0] = 2;
+ SetOamPlain(&oam_buf[0], x, y, frame_counter & 8 ? 0xaa : 0xa8, 0x7e, 2);
}
void Module04_NameFile() { // 8cd88a
@@ -834,19 +809,10 @@
OamEnt *oam = oam_buf;
for (int i = 0; i != 26; i++) {
- oam->x = 0x18 + i * 8;
- oam->y = selectfile_var7;
- oam->charnum = 0x2e;
- oam->flags = 0x3c;
- bytewise_extended_oam[oam - oam_buf] = 0;
+ SetOamPlain(oam, 0x18 + i * 8, selectfile_var7, 0x2e, 0x3c, 0);
oam++;
}
-
- oam->x = kNamePlayer_X[selectfile_var4];
- oam->y = 0x58;
- oam->charnum = 0x29;
- oam->flags = 0xc;
- bytewise_extended_oam[oam - oam_buf] = 0;
+ SetOamPlain(oam, kNamePlayer_X[selectfile_var4], 0x58, 0x29, 0xc, 0);
if (selectfile_var9 | selectfile_var11)
return;
--- a/snes/cpu.c
+++ b/snes/cpu.c
@@ -811,12 +811,19 @@
case 0x1d8f29:
case 0x1dc812:
+ case 0x1DDBD3:
+ case 0x1DF856:
case 0x6ED0B:
case 0x9b478:
case 0x9b46c:
cpu->c = 0;
goto adc_69;
+
+ case 0x1E88DA:
+ cpu->c = 0;
+ goto adc_65;
+
case 0x9B468:
case 0x9B46A:
case 0x9B474:
@@ -1481,7 +1488,7 @@
cpu_stz(cpu, low, high);
break;
}
- case 0x65: { // adc dp
+ case 0x65: adc_65: { // adc dp
uint32_t low = 0;
uint32_t high = cpu_adrDp(cpu, &low);
cpu_adc(cpu, low, high);
--- a/sprite.c
+++ b/sprite.c
@@ -598,12 +598,9 @@
if (Garnish_ReturnIfPrepFails(k, &pt))
return;
OamEnt *oam = GetOamCurPtr();
- oam->x = pt.x;
- oam->y = pt.y;
- oam->charnum = kGarnishSparkle_Char[t];
int j = garnish_sprite[k];
- oam->flags = (sprite_oam_flags[j] | sprite_obj_prio[j]) & 0xf0 | 4;
- bytewise_extended_oam[oam - oam_buf] = 0;
+ SetOamPlain(oam, pt.x, pt.y, kGarnishSparkle_Char[t],
+ (sprite_oam_flags[j] | sprite_obj_prio[j]) & 0xf0 | 4, 0);
}
void Garnish_DustCommon(int k, uint8 shift) {
@@ -613,11 +610,7 @@
if (Garnish_ReturnIfPrepFails(k, &pt))
return;
OamEnt *oam = GetOamCurPtr();
- oam->x = pt.x;
- oam->y = pt.y;
- oam->charnum = kRunningManDust_Char[tmp_counter];
- oam->flags = 0x24;
- bytewise_extended_oam[oam - oam_buf] = 0;
+ SetOamPlain(oam, pt.x, pt.y, kRunningManDust_Char[tmp_counter], 0x24, 0);
}
void SpriteModule_Explode(int k) {
@@ -918,15 +911,11 @@
BYTE(word_7E0CFE) = sprite_unk5[k];
OamEnt *oam = GetOamCurPtr();
do {
- uint16 x = src->x + info->x;
- uint16 y = src->y + info->y;
- oam->x = x;
- oam->y = (uint16)(y + 0x10) < 0x100 ? y : 0xf0;
uint16 d = src->char_flags ^ WORD(info->r4);
if (word_7E0CFE >= 1)
d = d & ~0xE00 | 0x400;
- WORD(oam->charnum) = d;
- bytewise_extended_oam[oam - oam_buf] = (x >> 8 & 1) | src->ext;
+ SetOamHelper0(oam, src->x + info->x, src->y + info->y, d, d >> 8, src->ext);
+
} while (src++, oam++, --n);
}
@@ -1533,17 +1522,10 @@
if ((uint16)(y + 0x10) >= 0x100)
return;
OamEnt *oam = GetOamCurPtr() + (sprite_flags2[k] & 0x1f);
- oam->x = info->x;
if (sprite_flags3[k] & 0x20) {
- oam->y = y + 1;
- oam->charnum = 0x38;
- oam->flags = (info->flags & 0x30) | 8;
- bytewise_extended_oam[oam - oam_buf] = (info->x >> 8 & 1);
+ SetOamHelper1(oam, info->x, y + 1, 0x38, (info->flags & 0x30) | 8, 0);
} else {
- oam->y = y;
- oam->charnum = 0x6c;
- oam->flags = (info->flags & 0x30) | 8;
- bytewise_extended_oam[oam - oam_buf] = (info->x >> 8 & 1) | 2;
+ SetOamHelper1(oam, info->x, y, 0x6c, (info->flags & 0x30) | 8, 2);
}
}
@@ -1833,11 +1815,8 @@
OamEnt *oam = GetOamCurPtr();
int j = ((sprite_delay_main[k] >> 1) & ~3) + 3;
for (int i = 3; i >= 0; i--, j--, oam++) {
- oam->x = kSpritePoof_X[j] + BYTE(dungmap_var7);
- oam->y = kSpritePoof_Y[j] + HIBYTE(dungmap_var7);
- oam->charnum = kSpritePoof_Char[j];
- oam->flags = kSpritePoof_Flags[j];
- bytewise_extended_oam[oam - oam_buf] = kSpritePoof_Ext[j];
+ SetOamPlain(oam, kSpritePoof_X[j] + BYTE(dungmap_var7), kSpritePoof_Y[j] + HIBYTE(dungmap_var7),
+ kSpritePoof_Char[j], kSpritePoof_Flags[j], kSpritePoof_Ext[j]);
}
Sprite_CorrectOamEntries(k, 3, 0xff);
}
@@ -3132,11 +3111,8 @@
int n = (q < 12 && (q & 3) == 0) ? 3 : 0, nn = n;
do {
int i = q * 4 + n;
- oam->x = info.x + kSpriteDrawFall1_X[i];
- oam->y = info.y + kSpriteDrawFall1_Y[i];
- oam->charnum = kSpriteDrawFall1_Char[i];
- oam->flags = info.flags ^ kSpriteDrawFall1_Flags[i];
- bytewise_extended_oam[oam - oam_buf] = kSpriteDrawFall1_Ext[i];
+ SetOamPlain(oam, info.x + kSpriteDrawFall1_X[i], info.y + kSpriteDrawFall1_Y[i],
+ kSpriteDrawFall1_Char[i], info.flags ^ kSpriteDrawFall1_Flags[i], kSpriteDrawFall1_Ext[i]);
} while (oam++, --n >= 0);
Sprite_CorrectOamEntries(k, nn, 0xff);
}
@@ -3324,14 +3300,9 @@
return;
OamEnt *oam = GetOamCurPtr();
int g = (garnish_countdown[k] >> 1) & 6;
- for (int i = 1; i >= 0; i--) {
+ for (int i = 1; i >= 0; i--, oam++) {
int j = i + g;
- oam->x = pt.x + kArrghusSplash_X[j];
- oam->y = pt.y + kArrghusSplash_Y[j];
- oam->charnum = kArrghusSplash_Char[j];
- oam->flags = kArrghusSplash_Flags[j];
- bytewise_extended_oam[oam - oam_buf] = kArrghusSplash_Ext[j];
- oam++;
+ SetOamPlain(oam, pt.x + kArrghusSplash_X[j], pt.y + kArrghusSplash_Y[j], kArrghusSplash_Char[j], kArrghusSplash_Flags[j], kArrghusSplash_Ext[j]);
}
}
@@ -3371,16 +3342,8 @@
if (Garnish_ReturnIfPrepFails(k, &pt))
return;
OamEnt *oam = GetOamCurPtr();
- oam[0].x = pt.x;
- oam[0].y = pt.y;
- oam[1].x = pt.x + 8;
- oam[1].y = pt.y;
- oam[0].charnum = 0xa4;
- oam[1].charnum = 0xa5;
- oam[0].flags = 0x22;
- oam[1].flags = 0x22;
- bytewise_extended_oam[oam - oam_buf] = 0;
- bytewise_extended_oam[oam - oam_buf + 1] = 0;
+ SetOamPlain(oam + 0, pt.x + 0, pt.y, 0xa4, 0x22, 0);
+ SetOamPlain(oam + 1, pt.x + 8, pt.y, 0xa5, 0x22, 0);
}
void Garnish10_GanonBatFlame(int k) { // 89b306
@@ -3396,13 +3359,8 @@
Point16U pt;
if (Garnish_ReturnIfPrepFails(k, &pt))
return;
- OamEnt *oam = GetOamCurPtr();
- oam->x = pt.x;
- oam->y = pt.y;
int j = kGanonBatFlame_Idx[garnish_countdown[k] >> 3];
- oam->charnum = kGanonBatFlame_Char[j];
- oam->flags = kGanonBatFlame_Flags[j] | 0x22;
- bytewise_extended_oam[oam - oam_buf] = 2;
+ SetOamPlain(GetOamCurPtr(), pt.x, pt.y, kGanonBatFlame_Char[j], kGanonBatFlame_Flags[j] | 0x22, 2);
Garnish_CheckPlayerCollision(k, pt.x, pt.y);
}
@@ -3416,13 +3374,8 @@
Point16U pt;
if (Garnish_ReturnIfPrepFails(k, &pt))
return;
-
- OamEnt *oam = GetOamCurPtr();
- oam->x = pt.x;
- oam->y = pt.y;
- oam->charnum = kTrinexxIce_Char[garnish_countdown[k] >> 4];
- oam->flags = kTrinexxIce_Flags[(garnish_countdown[k] >> 2) & 3] | 0x35;
- bytewise_extended_oam[oam - oam_buf] = 2;
+ SetOamPlain(GetOamCurPtr(), pt.x, pt.y, kTrinexxIce_Char[garnish_countdown[k] >> 4],
+ kTrinexxIce_Flags[(garnish_countdown[k] >> 2) & 3] | 0x35, 2);
}
void Garnish14_KakKidDashDust(int k) { // 89b3bc
@@ -3439,13 +3392,8 @@
Point16U pt;
if (Garnish_ReturnIfPrepFails(k, &pt))
return;
- OamEnt *oam = GetOamCurPtr();
- oam->x = pt.x;
- oam->y = pt.y;
- oam->charnum = kGarnish_CannonPoof_Char[garnish_countdown[k] >> 3];
int j = garnish_sprite[k];
- oam->flags = kGarnish_CannonPoof_Flags[j] | 4;
- bytewise_extended_oam[oam - oam_buf] = 2;
+ SetOamPlain(GetOamCurPtr(), pt.x, pt.y, kGarnish_CannonPoof_Char[garnish_countdown[k] >> 3], kGarnish_CannonPoof_Flags[j] | 4, 2);
}
void Garnish09_LightningTrail(int k) { // 89b429
@@ -3454,13 +3402,10 @@
Point16U pt;
if (Garnish_ReturnIfPrepFails(k, &pt))
return;
- OamEnt *oam = GetOamCurPtr();
- oam->x = pt.x;
- oam->y = pt.y;
int j = garnish_sprite[k];
- oam->charnum = kLightningTrail_Char[j] - (BYTE(dungeon_room_index2) == 0x20 ? 0x80 : 0);
- oam->flags = (frame_counter << 1) & 0xe | kLightningTrail_Flags[j];
- bytewise_extended_oam[oam - oam_buf] = 2;
+ SetOamPlain(GetOamCurPtr(), pt.x, pt.y,
+ kLightningTrail_Char[j] - (BYTE(dungeon_room_index2) == 0x20 ? 0x80 : 0),
+ (frame_counter << 1) & 0xe | kLightningTrail_Flags[j], 2);
Garnish_CheckPlayerCollision(k, pt.x, pt.y);
}
@@ -3484,13 +3429,8 @@
Point16U pt;
if (Garnish_ReturnIfPrepFails(k, &pt))
return;
- OamEnt *oam = GetOamCurPtr();
- oam->x = pt.x;
- oam->y = pt.y;
int j = garnish_countdown[k] >> 3;
- oam->charnum = kBabusuFlash_Char[j];
- oam->flags = kBabusuFlash_Flags[j];
- bytewise_extended_oam[oam - oam_buf] = 2;
+ SetOamPlain(GetOamCurPtr(), pt.x, pt.y, kBabusuFlash_Char[j], kBabusuFlash_Flags[j], 2);
}
void Garnish08_KholdstareTrail(int k) { // 89b4c6
@@ -3500,14 +3440,10 @@
Point16U pt;
if (Garnish_ReturnIfPrepFails(k, &pt))
return;
- OamEnt *oam = GetOamCurPtr();
int i = garnish_countdown[k] >> 2;
- oam->x = pt.x + kGarnish_Nebule_XY[i];
- oam->y = pt.y + kGarnish_Nebule_XY[i];
- oam->charnum = kGarnish_Nebule_Char[i];
int j = garnish_sprite[k];
- oam->flags = (sprite_oam_flags[j] | sprite_obj_prio[j]) & ~1;
- bytewise_extended_oam[oam - oam_buf] = 0;
+ SetOamPlain(GetOamCurPtr(), pt.x + kGarnish_Nebule_XY[i], pt.y + kGarnish_Nebule_XY[i], kGarnish_Nebule_Char[i],
+ (sprite_oam_flags[j] | sprite_obj_prio[j]) & ~1, 0);
}
void Garnish06_ZoroTrail(int k) { // 89b4fb
@@ -3514,13 +3450,8 @@
Point16U pt;
if (Garnish_ReturnIfPrepFails(k, &pt))
return;
- OamEnt *oam = GetOamCurPtr();
- oam->x = pt.x;
- oam->y = pt.y;
- oam->charnum = 0x75;
int j = garnish_sprite[k];
- oam->flags = sprite_oam_flags[j] | sprite_obj_prio[j];
- bytewise_extended_oam[oam - oam_buf] = 0;
+ SetOamPlain(GetOamCurPtr(), pt.x, pt.y, 0x75, sprite_oam_flags[j] | sprite_obj_prio[j], 0);
}
void Garnish12_Sparkle(int k) { // 89b520
@@ -3536,14 +3467,9 @@
Point16U pt;
if (Garnish_ReturnIfPrepFails(k, &pt))
return;
- OamEnt *oam = GetOamCurPtr();
- oam->x = pt.x;
- oam->y = pt.y;
- oam->charnum = kTrinexxLavaBubble_Char[garnish_countdown[k] >> 3];
int j = garnish_sprite[k];
- oam->flags = (sprite_oam_flags[j] | sprite_obj_prio[j]) & 0xf0 | 0xe;
- bytewise_extended_oam[oam - oam_buf] = 0;
-
+ SetOamPlain(GetOamCurPtr(), pt.x, pt.y, kTrinexxLavaBubble_Char[garnish_countdown[k] >> 3],
+ (sprite_oam_flags[j] | sprite_obj_prio[j]) & 0xf0 | 0xe, 0);
}
void Garnish0F_BlindLaserTrail(int k) { // 89b591
@@ -3551,13 +3477,8 @@
Point16U pt;
if (Garnish_ReturnIfPrepFails(k, &pt))
return;
- OamEnt *oam = GetOamCurPtr();
- oam->x = pt.x;
- oam->y = pt.y;
- oam->charnum = kBlindLaserTrail_Char[garnish_oam_flags[k] - 7];
int j = garnish_sprite[k];
- oam->flags = sprite_oam_flags[j] | sprite_obj_prio[j];
- bytewise_extended_oam[oam - oam_buf] = 0;
+ SetOamPlain(GetOamCurPtr(), pt.x, pt.y, kBlindLaserTrail_Char[garnish_oam_flags[k] - 7], sprite_oam_flags[j] | sprite_obj_prio[j], 0);
}
void Garnish04_LaserTrail(int k) { // 89b5bb
@@ -3565,12 +3486,7 @@
Point16U pt;
if (Garnish_ReturnIfPrepFails(k, &pt))
return;
- OamEnt *oam = GetOamCurPtr();
- oam->x = pt.x;
- oam->y = pt.y;
- oam->charnum = kLaserBeamTrail_Char[garnish_oam_flags[k]];
- oam->flags = 0x25;
- bytewise_extended_oam[oam - oam_buf] = 0;
+ SetOamPlain(GetOamCurPtr(), pt.x, pt.y, kLaserBeamTrail_Char[garnish_oam_flags[k]], 0x25, 0);
}
bool Garnish_ReturnIfPrepFails(int k, Point16U *pt) { // 89b5de
@@ -3596,18 +3512,10 @@
if ((j = garnish_countdown[k]) == 0x1e && (j = (submodule_index | flag_unk1)) == 0)
Dungeon_UpdateTileMapWithCommonTile(Garnish_GetX(k), Garnish_GetY(k) - 16, 4);
j >>= 3;
-
uint16 x = Garnish_GetX(k) + kCrumbleTile_XY[j] - BG2HOFS_copy2;
uint16 y = Garnish_GetY(k) + kCrumbleTile_XY[j] - BG2VOFS_copy2;
-
- if (x < 256 && y < 256) {
- OamEnt *oam = GetOamCurPtr();
- oam->x = x;
- oam->y = y - 16;
- oam->charnum = kCrumbleTile_Char[j];
- oam->flags = kCrumbleTile_Flags[j];
- bytewise_extended_oam[oam - oam_buf] = kCrumbleTile_Ext[j];
- }
+ if (x < 256 && y < 256)
+ SetOamPlain(GetOamCurPtr(), x, y - 16, kCrumbleTile_Char[j], kCrumbleTile_Flags[j], kCrumbleTile_Ext[j]);
}
void Garnish01_FireSnakeTail(int k) { // 89b6c0
@@ -3614,23 +3522,14 @@
Point16U pt;
if (Garnish_ReturnIfPrepFails(k, &pt))
return;
- OamEnt *oam = GetOamCurPtr();
- oam->x = pt.x;
- oam->y = pt.y;
- oam->charnum = 0x28;
int j = garnish_sprite[k];
- oam->flags = sprite_oam_flags[j] | sprite_obj_prio[j];
- bytewise_extended_oam[oam - oam_buf] = 2;
+ SetOamPlain(GetOamCurPtr(), pt.x, pt.y, 0x28, sprite_oam_flags[j] | sprite_obj_prio[j], 2);
}
void Garnish02_MothulaBeamTrail(int k) { // 89b6e1
- OamEnt *oam = GetOamCurPtr();
- oam->x = garnish_x_lo[k] - BG2HOFS_copy2;
- oam->y = garnish_y_lo[k] - BG2VOFS_copy2;
- oam->charnum = 0xaa;
int j = garnish_sprite[k];
- oam->flags = sprite_oam_flags[j] | sprite_obj_prio[j];
- bytewise_extended_oam[oam - oam_buf] = 2;
+ SetOamPlain(GetOamCurPtr(), garnish_x_lo[k] - BG2HOFS_copy2, garnish_y_lo[k] - BG2VOFS_copy2, 0xaa,
+ sprite_oam_flags[j] | sprite_obj_prio[j], 2);
}
void Dungeon_ResetSprites() { // 89c114
@@ -4012,16 +3911,11 @@
uint8 base = ((garnish_countdown[k] >> 2) ^ 7) << 2;
if (tmp_counter == 4 || tmp_counter == 2 && !player_is_indoors)
base += 0x20;
-
- for (int i = 3; i >= 0; i--) {
+ for (int i = 3; i >= 0; i--, oam++) {
int j = i + base;
- uint16 x = pt.x + kScatterDebris_Draw_X[j];
- oam->x = x;
- oam->y = pt.y + kScatterDebris_Draw_Y[j];
- oam->charnum = (tmp_counter == 0) ? 0x4E : (tmp_counter >= 0x80) ? 0xF2 : kScatterDebris_Draw_Char[j];
- oam->flags = kScatterDebris_Draw_Flags[j] | r5;
- bytewise_extended_oam[oam - oam_buf] = (x >> 8) & 1;
- oam++;
+ SetOamHelper1(oam, pt.x + kScatterDebris_Draw_X[j], pt.y + kScatterDebris_Draw_Y[j],
+ (tmp_counter == 0) ? 0x4E : (tmp_counter >= 0x80) ? 0xF2 : kScatterDebris_Draw_Char[j],
+ kScatterDebris_Draw_Flags[j] | r5, 0);
}
}
@@ -4037,15 +3931,10 @@
OamEnt *oam = GetOamCurPtr();
int base = ((garnish_countdown[k] & 0xf) >> 2) * 3;
- for (int i = 2; i >= 0; i--) {
+ for (int i = 2; i >= 0; i--, oam++) {
int j = i + base;
- uint16 x = pt.x + kScatterDebris_Draw_X2[j];
- oam->x = x;
- oam->y = pt.y + kScatterDebris_Draw_Y2[j];
- oam->charnum = kScatterDebris_Draw_Char2[j];
- oam->flags = kScatterDebris_Draw_Flags2[j] | 0x22;
- bytewise_extended_oam[oam - oam_buf] = (x >> 8) & 1;
- oam++;
+ SetOamHelper1(oam, pt.x + kScatterDebris_Draw_X2[j], pt.y + kScatterDebris_Draw_Y2[j],
+ kScatterDebris_Draw_Char2[j], kScatterDebris_Draw_Flags2[j] | 0x22, 0);
}
}
--- a/sprite.h
+++ b/sprite.h
@@ -55,6 +55,24 @@
bytewise_extended_oam[oam - oam_buf] = big | (x >> 8 & 1);
}
+static inline void SetOamHelper1(OamEnt *oam, uint16 x, uint8 y, uint8 charnum, uint8 flags, uint8 big) {
+ oam->x = x;
+ oam->y = y;
+ oam->charnum = charnum;
+ oam->flags = flags;
+ bytewise_extended_oam[oam - oam_buf] = big | (x >> 8 & 1);
+}
+
+static inline void SetOamPlain(OamEnt *oam, uint8 x, uint8 y, uint8 charnum, uint8 flags, uint8 big) {
+ oam->x = x;
+ oam->y = y;
+ oam->charnum = charnum;
+ oam->flags = flags;
+ bytewise_extended_oam[oam - oam_buf] = big;
+}
+
+
+
extern const uint8 kAbsorptionSfx[15];
extern const uint8 kSpriteInit_BumpDamage[243];
extern const uint16 kSinusLookupTable[256];
--- a/sprite_main.c
+++ b/sprite_main.c
@@ -26,7 +26,7 @@
static const int8 kBadPullDownSwitch_Y[5] = {-3, -3, 0, 5, 5};
static const uint8 kBadPullDownSwitch_Char[5] = {0xd2, 0xd2, 0xc4, 0xe4, 0xe4};
static const uint8 kBadPullDownSwitch_Flags[5] = {0x40, 0, 0, 0x40, 0};
-static const uint8 kBadPullDownSwitch_Ext[5] = {0, 0, 2, 2, 2};
+static const uint8 kBadPullDownSwitch_Big[5] = {0, 0, 2, 2, 2};
static const uint8 kBadPullSwitch_Tab5[6] = {0, 1, 2, 3, 4, 5};
static const uint8 kBadPullSwitch_Tab4[12] = {0, 0, 1, 1, 2, 2, 3, 3, 4, 5, 5, 5};
static const uint8 kThief_Gfx[12] = {11, 8, 2, 5, 9, 6, 0, 3, 10, 7, 1, 4};
@@ -50,7 +50,7 @@
0x40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x40, 0x40, 0x40, 0x40, 0x40, 0,
0x40, 0, 0x40, 0,
};
-static const uint8 kTutorialSoldier_Ext[20] = {
+static const uint8 kTutorialSoldier_Big[20] = {
2, 2, 2, 0, 0, 2, 2, 0, 0, 0, 2, 2, 0, 0, 0, 2,
0, 2, 2, 2,
};
@@ -259,7 +259,7 @@
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x40, 0x40, 0x40, 0x40,
0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,
};
-static const uint8 kSoldier_Draw2_Ext[104] = {
+static const uint8 kSoldier_Draw2_Big[104] = {
2, 2, 0, 0, 2, 2, 0, 0, 2, 2, 0, 0, 2, 2, 0, 0,
0, 0, 2, 2, 0, 0, 2, 2, 0, 0, 2, 2, 0, 0, 2, 2,
0, 0, 2, 2, 0, 0, 2, 2, 0, 0, 2, 2, 0, 0, 2, 2,
@@ -372,7 +372,7 @@
0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0,
0, 0, 0, 0x40, 0x40, 0, 0x40, 0x40,
};
-static const uint8 kFlailTrooperBody_Ext[72] = {
+static const uint8 kFlailTrooperBody_Big[72] = {
2, 2, 0, 2, 2, 0, 2, 2, 0, 2, 2, 0, 2, 2, 0, 2,
2, 0, 2, 2, 0, 2, 2, 0, 2, 2, 0, 2, 2, 0, 2, 2,
0, 2, 2, 0, 2, 2, 0, 2, 2, 0, 2, 2, 0, 2, 2, 0,
@@ -1905,11 +1905,8 @@
int i = sprite_delay_aux1[k] ? kArcheryGame_NumSpr[sprite_delay_aux1[k] >> 3] : archery_game_arrows_left;
i = i * 2 + 7;
do {
- oam->x = info.x - 20 + kArcheryGame_X[i] + 1;
- oam->y = info.y - 48 + kArcheryGame_Y[i] + 1;
- oam->charnum = kArcheryGame_Char[i];
- oam->flags = kArcheryGame_Flags[i];
- bytewise_extended_oam[oam - oam_buf] = 0;
+ SetOamPlain(oam, info.x - 20 + kArcheryGame_X[i] + 1, info.y - 48 + kArcheryGame_Y[i] + 1,
+ kArcheryGame_Char[i], kArcheryGame_Flags[i], 0);
} while (oam++, --i >= 0);
if (archery_game_arrows_left | sprite_delay_aux4[k] |
@@ -1935,12 +1932,10 @@
OamEnt *oam = GetOamCurPtr() + 1;
int b = sprite_B[k];
for (int i = 4; i >= 0; i--, oam++) {
- oam->x = info.x + kGoodArcheryTarget_X[i];
- oam->y = info.y + kGoodArcheryTarget_Y[i];
- oam->charnum = (i == 4) ? kGoodArcheryTarget_Draw_Char4[b - 1] :
- (i == 3) ? kGoodArcheryTarget_Draw_Char3[b - 1] : kGoodArcheryTarget_Draw_Char[i];
- oam->flags = kGoodArcheryTarget_Draw_Flags[i] & (oam->charnum < 0x7c ? 0xff : 0xfe);
- bytewise_extended_oam[oam - oam_buf] = 0;
+ uint8 charnum = (i == 4) ? kGoodArcheryTarget_Draw_Char4[b - 1] :
+ (i == 3) ? kGoodArcheryTarget_Draw_Char3[b - 1] : kGoodArcheryTarget_Draw_Char[i];
+ SetOamPlain(oam, info.x + kGoodArcheryTarget_X[i], info.y + kGoodArcheryTarget_Y[i], charnum,
+ kGoodArcheryTarget_Draw_Flags[i] & (charnum < 0x7c ? 0xff : 0xfe), 0);
}
Sprite_DrawDistress_custom(info.x, info.y, frame_counter);
}
@@ -2032,7 +2027,7 @@
0, 0x40, 0x80, 0xc0, 0, 0x40, 0x80, 0xc0, 0, 0x40, 0x80, 0xc0, 0, 0x40, 0x80, 0xc0,
0, 0x40, 0x80, 0xc0, 0, 0x40, 0x80, 0xc0,
};
- static const uint8 kDebirandoPit_Draw_Ext[6] = {2, 2, 2, 0, 0, 2};
+ static const uint8 kDebirandoPit_Draw_Big[6] = {2, 2, 2, 0, 0, 2};
PrepOamCoordsRet info;
if (Sprite_PrepOamCoordOrDoubleRet(k, &info))
return;
@@ -2040,13 +2035,13 @@
if (g == 6)
return;
OamEnt *oam = GetOamCurPtr();
- uint8 ext = kDebirandoPit_Draw_Ext[g];
+ uint8 big = kDebirandoPit_Draw_Big[g];
for (int i = 3; i >= 0; i--, oam++) {
int j = g * 4 + i;
SetOamHelper0(oam, info.x + kDebirandoPit_Draw_X[j],
info.y + kDebirandoPit_Draw_Y[j],
kDebirandoPit_Draw_Char[j],
- kDebirandoPit_Draw_Flags[j] | info.flags, ext);
+ kDebirandoPit_Draw_Flags[j] | info.flags, big);
}
}
@@ -2103,7 +2098,7 @@
static const int8 kDebirando_Draw_Y[16] = {2, 2, 6, 6, -2, -2, 6, 6, -4, -4, -4, -4, -4, -4, -4, -4};
static const uint8 kDebirando_Draw_Char[16] = {0, 0, 0xd8, 0xd8, 0, 0, 0xd9, 0xd9, 0, 0, 0, 0, 0x20, 0x20, 0x20, 0x20};
static const uint8 kDebirando_Draw_Flags[16] = {1, 0x41, 0, 0x40, 1, 1, 0, 0x40, 1, 1, 1, 1, 1, 1, 1, 1};
- static const uint8 kDebirando_Draw_Ext[16] = {0, 0, 0, 0, 2, 2, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2};
+ static const uint8 kDebirando_Draw_Big[16] = {0, 0, 0, 0, 2, 2, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2};
PrepOamCoordsRet info;
if (Sprite_PrepOamCoordOrDoubleRet(k, &info))
return;
@@ -2117,7 +2112,7 @@
info.y + kDebirando_Draw_Y[j],
kDebirando_Draw_Char[j],
(f ^ info.flags) & ((f & 0xf) == 0 ? 0xf0 : 0xff),
- kDebirando_Draw_Ext[j]);
+ kDebirando_Draw_Big[j]);
}
}
@@ -2995,7 +2990,7 @@
0x25, 0x25, 0x25, 0x25, 0xe5, 0xe5, 0x25, 0x20, 0xe5, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x24,
0x25, 0x25, 0x24, 0x64, 0x20, 0x26, 0x24, 0x64, 0x24, 0x64,
};
- static const uint8 kZora_Draw_Ext[26] = {
+ static const uint8 kZora_Draw_Big[26] = {
0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 0, 0, 2, 0, 0, 0, 0, 0,
};
@@ -3007,7 +3002,7 @@
for (int i = 1; i >= 0; i--, oam++) {
int j = d + i;
uint8 f = kZora_Draw_Flags[j];
- SetOamHelper0(oam, info.x + kZora_Draw_X[j], info.y + kZora_Draw_Y[j], kZora_Draw_Char[j], f | (f & 0xf ? 0 : info.flags), kZora_Draw_Ext[j]);
+ SetOamHelper0(oam, info.x + kZora_Draw_X[j], info.y + kZora_Draw_Y[j], kZora_Draw_Char[j], f | (f & 0xf ? 0 : info.flags), kZora_Draw_Big[j]);
}
}
@@ -3200,11 +3195,8 @@
int g = (sprite_delay_aux2[k] >> 1) & 4;
for (int i = 3; i >= 0; i--, oam++) {
int j = g + i;
- oam->x = kZoraKing_Draw_X1[j] + info.x;
- oam->y = kZoraKing_Draw_Y1[j] + info.y;
- oam->charnum = kZoraKing_Draw_Char1[j];
- oam->flags = kZoraKing_Draw_Flags1[j] | 0x24;
- bytewise_extended_oam[oam - oam_buf] = 2;
+ SetOamPlain(oam, kZoraKing_Draw_X1[j] + info.x, kZoraKing_Draw_Y1[j] + info.y,
+ kZoraKing_Draw_Char1[j], kZoraKing_Draw_Flags1[j] | 0x24, 2);
}
}
@@ -3473,7 +3465,7 @@
0, 0, 0, 0, 0, 0, 0, 0, 0x40, 0, 0xc0, 0x80, 0x40, 0, 0xc0, 0x80,
0x40, 0, 0xc0, 0x80, 0x40, 0, 0xc0, 0x80,
};
- static const uint8 kArmosKnight_Draw_Ext[24] = {
+ static const uint8 kArmosKnight_Draw_Big[24] = {
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 0, 0, 0, 0,
};
@@ -3489,7 +3481,7 @@
int j = g * 4 + i;
SetOamHelper0(oam, info.x + kArmosKnight_Draw_X[j], info.y + kArmosKnight_Draw_Y[j],
kArmosKnight_Draw_Char[j], kArmosKnight_Draw_Flags[j] | info.flags,
- kArmosKnight_Draw_Ext[j]);
+ kArmosKnight_Draw_Big[j]);
}
if (g != 0)
return;
@@ -3502,18 +3494,8 @@
int z = sprite_z[k];
z = ((z >= 32) ? 32 : z) >> 3;
uint16 y = Sprite_GetY(k) - BG2VOFS_copy2;
- oam[4].x = info.x - 8 + z;
- oam[5].x = info.x + 8 - z;
- if ((uint16)(y + 12 + 16) < 0x100) {
- oam[5].y = oam[4].y = y + 12;
- } else {
- oam[5].y = oam[4].y = 0xf0;
- }
- oam[5].charnum = oam[4].charnum = 0xe4;
- oam[4].flags = 0x25;
- oam[5].flags = 0x25 | 0x40;
- bytewise_extended_oam[oam + 4 - oam_buf] = 2;
- bytewise_extended_oam[oam + 5 - oam_buf] = 2;
+ SetOamHelper0(oam + 4, info.x - 8 + z, y + 12, 0xe4, 0x25, 2);
+ SetOamHelper0(oam + 5, info.x + 8 - z, y + 12, 0xe4, 0x25 | 0x40, 2);
}
void Sprite_54_Lanmolas(int k) { // 85a3a2
@@ -3686,18 +3668,15 @@
static const uint8 kLanmola_Draw_Flags2[6] = {0, 0x40, 0, 0x40, 0, 0x40};
Oam_AllocateFromRegionB(4);
OamEnt *oam = GetOamCurPtr();
- oam->x = sprite_x_lo[k] - BG2HOFS_copy2;
- oam->y = sprite_y_lo[k] - BG2VOFS_copy2;
j = kLanmola_Draw_Idx2[sprite_delay_main[k] >> 3];
- oam->charnum = kLanmola_Draw_Char2[j];
- oam->flags = kLanmola_Draw_Flags2[j] | 0x31;
- bytewise_extended_oam[oam - oam_buf] = 2;
+ SetOamPlain(oam, sprite_x_lo[k] - BG2HOFS_copy2, sprite_y_lo[k] - BG2VOFS_copy2,
+ kLanmola_Draw_Char2[j], kLanmola_Draw_Flags2[j] | 0x31, 2);
} else if (sprite_ai_state[k] != 5 && sprite_delay_aux1[k] != 0) {
static const int8 kLanmola_Draw_X4[8] = {-8, 8, -10, 10, -16, 16, -24, 32};
static const int8 kLanmola_Draw_Y4[8] = {0, 0, -1, -1, -1, -1, 3, 3};
static const uint8 kLanmola_Draw_Char4[8] = {0xe8, 0xe8, 0xe8, 0xe8, 0xea, 0xea, 0xea, 0xea};
static const uint8 kLanmola_Draw_Flags4[8] = {0, 0x40, 0, 0x40, 0, 0x40, 0, 0x40};
- static const uint8 kLanmola_Draw_Ext4[8] = {2, 2, 2, 2, 2, 2, 0, 0};
+ static const uint8 kLanmola_Draw_Big4[8] = {2, 2, 2, 2, 2, 2, 0, 0};
if (((sprite_y_vel[k] >> 6) ^ sprite_ai_state[k]) & 2)
Oam_AllocateFromRegionB(8);
@@ -3709,11 +3688,7 @@
uint8 y = sprite_wallcoll[k] - BG2VOFS_copy2;
for (int i = 1; i >= 0; i--, oam++) {
int j = i + r6;
- oam->x = x + kLanmola_Draw_X4[j];
- oam->y = y + kLanmola_Draw_Y4[j];
- oam->charnum = kLanmola_Draw_Char4[j];
- oam->flags = kLanmola_Draw_Flags4[j] | 0x31;
- bytewise_extended_oam[oam - oam_buf] = kLanmola_Draw_Ext4[j];
+ SetOamPlain(oam, x + kLanmola_Draw_X4[j], y + kLanmola_Draw_Y4[j], kLanmola_Draw_Char4[j], kLanmola_Draw_Flags4[j] | 0x31, kLanmola_Draw_Big4[j]);
}
}
}
@@ -4032,7 +4007,7 @@
int j = g * 3 + n;
SetOamHelper0(oam, info->x + kFlailTrooperBody_X[j], info->y + kFlailTrooperBody_Y[j],
kFlailTrooperBody_Char[j], info->flags | kFlailTrooperBody_Flags[j],
- kFlailTrooperBody_Ext[j]);
+ kFlailTrooperBody_Big[j]);
if (n == 2)
oam++;
} while (oam++, --n >= 0);
@@ -4062,24 +4037,17 @@
HIBYTE(dungmap_var8) = r4 - 4 + r12;
BYTE(dungmap_var8) = r6 - 4 + r13;
- oam[0].x = HIBYTE(dungmap_var8) + BYTE(dungmap_var7);
- oam[0].y = BYTE(dungmap_var8) + HIBYTE(dungmap_var7);
-
- oam[0].charnum = 0x2a;
- oam[0].flags = 0x2d;
- bytewise_extended_oam[oam - oam_buf] = 2;
+ SetOamPlain(oam, HIBYTE(dungmap_var8) + BYTE(dungmap_var7), BYTE(dungmap_var8) + HIBYTE(dungmap_var7), 0x2a, 0x2d, 2);
oam++;
for (int i = 3; i >= 0; i--, oam++) {
t = (kFlailTrooperWeapon_Tab4[i] * r14) >> 8;
t = sign8(r4) ? -t : t;
- oam->x = t + BYTE(dungmap_var7) + r12;
- t = (kFlailTrooperWeapon_Tab4[i] * r15) >> 8;
- t = sign8(r6) ? -t : t;
- oam->y = t + HIBYTE(dungmap_var7) + r13;
- oam->charnum = 0x3f;
- oam->flags = 0x2d;
- bytewise_extended_oam[oam - oam_buf] = 0;
+ uint8 x = t + BYTE(dungmap_var7) + r12;
+ uint8 ty = (kFlailTrooperWeapon_Tab4[i] * r15) >> 8;
+ ty = sign8(r6) ? -ty : ty;
+ uint8 y = ty + HIBYTE(dungmap_var7) + r13;
+ SetOamPlain(oam, x, y, 0x3f, 0x2d, 0);
}
Sprite_CorrectOamEntries(k, 4, 0xff);
}
@@ -4309,7 +4277,7 @@
static const uint8 kGerudoMan_Draw_Flags[18] = {
0, 0, 0, 0x40, 0x40, 0x40, 0, 0x40, 0x40, 0, 0x40, 0x40, 0x40, 0x40, 0x40, 0, 0, 0,
};
- static const uint8 kGerudoMan_Draw_Ext[18] = { 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 };
+ static const uint8 kGerudoMan_Draw_Big[18] = { 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 };
PrepOamCoordsRet info;
if (Sprite_PrepOamCoordOrDoubleRet(k, &info))
return;
@@ -4318,7 +4286,7 @@
for (int i = 2; i >= 0; i--, oam++) {
int j = g * 3 + i;
SetOamHelper0(oam, info.x + kGerudoMan_Draw_X[j], info.y + kGerudoMan_Draw_Y[j],
- kGerudoMan_Draw_Char[j], kGerudoMan_Draw_Flags[j] | info.flags, kGerudoMan_Draw_Ext[j]);
+ kGerudoMan_Draw_Char[j], kGerudoMan_Draw_Flags[j] | info.flags, kGerudoMan_Draw_Big[j]);
}
}
@@ -4398,7 +4366,7 @@
static const int8 kToppo_Draw_Y[15] = {8, 8, 8, 8, 8, 8, 0, 8, 8, 0, 0, 0, 0, 0, 0};
static const uint8 kToppo_Draw_Char[15] = {0xc8, 0xc8, 0xc8, 0xca, 0xca, 0xca, 0xc0, 0xc8, 0xc8, 0xc2, 0xc2, 0xc2, 0xc2, 0xc2, 0xc2};
static const uint8 kToppo_Draw_Flags[15] = {0, 0x40, 0x40, 0, 0x40, 0x40, 0, 0, 0x40, 0, 0, 0, 0x40, 0x40, 0x40};
- static const uint8 kToppo_Draw_Ext[15] = {0, 0, 0, 0, 0, 0, 2, 0, 0, 2, 2, 2, 2, 2, 2};
+ static const uint8 kToppo_Draw_Big[15] = {0, 0, 0, 0, 0, 0, 2, 0, 0, 2, 2, 2, 2, 2, 2};
PrepOamCoordsRet info;
if (Sprite_PrepOamCoordOrDoubleRet(k, &info))
@@ -4408,14 +4376,14 @@
uint16 ybase = Sprite_GetY(k) - BG2VOFS_copy2;
for (int i = 2; i >= 0; i--, oam++) {
int j = i + g * 3;
- uint8 ext = kToppo_Draw_Ext[j];
+ uint8 big = kToppo_Draw_Big[j];
uint8 flags = kToppo_Draw_Flags[j] | info.flags;
- if (ext == 0)
+ if (big == 0)
flags = flags & ~0xf | 2;
SetOamHelper0(oam,
info.x + kToppo_Draw_X[j],
- (ext ? info.y : ybase) + kToppo_Draw_Y[j],
- kToppo_Draw_Char[j], flags, ext);
+ (big ? info.y : ybase) + kToppo_Draw_Y[j],
+ kToppo_Draw_Char[j], flags, big);
}
}
@@ -4471,25 +4439,10 @@
if (Sprite_PrepOamCoordOrDoubleRet(k, &info))
return;
OamEnt *oam = GetOamCurPtr();
- int r6 = sprite_graphics[k];
int hd = sprite_head_dir[k];
- uint16 x = info.x;
- uint16 y = info.y - 11;
- oam->x = x;
- oam->y = (uint16)(y + 0x10) < 0x100 ? y : 0xf0;
- oam->charnum = kSoldier_Draw1_Char[hd];
- oam->flags = kSoldier_Draw1_Flags[hd] | info.flags;
- bytewise_extended_oam[oam - oam_buf] = 2 | (x >> 8 & 1);
-
- oam++;
-
- x = info.x + kRecruit_Draw_X[r6];
- y = info.y;
- oam->x = x;
- oam->y = (uint16)(y + 0x10) < 0x100 ? y : 0xf0;
- oam->charnum = kRecruit_Draw_Char[r6];
- oam->flags = kRecruit_Draw_Flags[r6] | info.flags;
- bytewise_extended_oam[oam - oam_buf] = 2 | (x >> 8 & 1);
+ SetOamHelper0(oam + 0, info.x, info.y - 11, kSoldier_Draw1_Char[hd], kSoldier_Draw1_Flags[hd] | info.flags, 2);
+ int r6 = sprite_graphics[k];
+ SetOamHelper0(oam + 1, info.x + kRecruit_Draw_X[r6], info.y, kRecruit_Draw_Char[r6], kRecruit_Draw_Flags[r6] | info.flags, 2);
SpriteDraw_Shadow(k, &info);
}
@@ -4924,13 +4877,9 @@
void Guard_AnimateHead(int k, int oam_offs, const PrepOamCoordsRet *poc) { // 85c6de
OamEnt *oam = GetOamCurPtr() + oam_offs;
- oam->x = poc->x;
int dir = sprite_head_dir[k];
- uint16 y = poc->y - kSoldier_Draw1_Yd[sprite_graphics[k]];
- oam->y = (uint16)(y + 0x10) < 0x100 ? y : 0xf0;
- oam->charnum = kSoldier_Draw1_Char[dir];
- oam->flags = kSoldier_Draw1_Flags[dir] | poc->flags;
- bytewise_extended_oam[oam - oam_buf] = 2 | (poc->x & 0x100) >> 8;
+ SetOamHelper0(oam, poc->x, poc->y - kSoldier_Draw1_Yd[sprite_graphics[k]],
+ kSoldier_Draw1_Char[dir], kSoldier_Draw1_Flags[dir] | poc->flags, 2);
}
void Guard_AnimateBody(int k, int oam_idx, const PrepOamCoordsRet *poc) { // 85ca09
@@ -4939,16 +4888,16 @@
OamEnt *oam = GetOamCurPtr() + oam_idx;
for (int i = 3; i >= 0; i--) {
int j = i + g;
- if (type >= 0x46 && (!kSoldier_Draw2_Ext[j] || i == 3 && kSoldier_Draw2_Char[j] == 0x20))
+ if (type >= 0x46 && (!kSoldier_Draw2_Big[j] || i == 3 && kSoldier_Draw2_Char[j] == 0x20))
continue;
uint8 flags = kSoldier_Draw2_Flags[j] | poc->flags;
if (kSoldier_Draw2_Char[j] == 0x20) {
flags = flags & 0xf1 | 2;
- } else if (kSoldier_Draw2_Ext[j] == 0) {
+ } else if (kSoldier_Draw2_Big[j] == 0) {
flags = flags & 0xf1 | 8;
}
SetOamHelper0(oam, poc->x + kSoldier_Draw2_Xd[j], poc->y + kSoldier_Draw2_Yd[j],
- kSoldier_Draw2_Char[j], flags, kSoldier_Draw2_Ext[j]);
+ kSoldier_Draw2_Char[j], flags, kSoldier_Draw2_Big[j]);
if (oam->charnum == 0x20 && type == 0x46)
oam->y = 0xf0;
oam++;
@@ -4962,14 +4911,10 @@
OamEnt *oam = GetOamCurPtr() + oam_idx;
for (int i = 1; i >= 0; i--, oam++) {
int j = i + g;
- uint16 x = poc->x + kSoldier_Draw3_Xd[j];
- uint16 y = poc->y + kSoldier_Draw3_Yd[j];
- oam->x = x;
- oam->y = (uint16)(y + 0x10) < 0x100 ? y : 0xf0;
dungmap_var8 = kSoldier_Draw3_Xd[j] << 8 | (uint8)kSoldier_Draw3_Yd[j];
- oam->charnum = kSoldier_Draw3_Char[j] + (type < 0x43 ? 3 : 0);
- oam->flags = kSoldier_Draw3_Flags[j] | poc->flags;
- bytewise_extended_oam[oam - oam_buf] = (x & 0x100) >> 8;
+ SetOamHelper0(oam, poc->x + kSoldier_Draw3_Xd[j], poc->y + kSoldier_Draw3_Yd[j],
+ kSoldier_Draw3_Char[j] + (type < 0x43 ? 3 : 0),
+ kSoldier_Draw3_Flags[j] | poc->flags, 0);
}
}
@@ -5423,7 +5368,7 @@
uint8 flags = kTutorialSoldier_Flags[j] | info.flags;
if (kTutorialSoldier_Char[j] < 0x40)
flags = (flags & 0xf1) | 8;
- SetOamHelper0(oam, info.x + kTutorialSoldier_X[j], info.y + kTutorialSoldier_Y[j], kTutorialSoldier_Char[j], flags, kTutorialSoldier_Ext[j]);
+ SetOamHelper0(oam, info.x + kTutorialSoldier_X[j], info.y + kTutorialSoldier_Y[j], kTutorialSoldier_Char[j], flags, kTutorialSoldier_Big[j]);
}
SpriteDraw_Shadow_custom(k, &info, 12);
}
@@ -5486,11 +5431,8 @@
OamEnt *oam = GetOamCurPtr();
uint8 yoff = kBadPullSwitch_Tab5[kBadPullSwitch_Tab4[sprite_graphics[k]]];
for (int i = 4; i >= 0; i--, oam++) {
- oam->x = info.x + kBadPullDownSwitch_X[i];
- oam->y = info.y + kBadPullDownSwitch_Y[i] - (i == 2 ? yoff : 0);
- oam->charnum = kBadPullDownSwitch_Char[i];
- oam->flags = kBadPullDownSwitch_Flags[i] | 0x21;
- bytewise_extended_oam[oam - oam_buf] = kBadPullDownSwitch_Ext[i];
+ SetOamPlain(oam, info.x + kBadPullDownSwitch_X[i], info.y + kBadPullDownSwitch_Y[i] - (i == 2 ? yoff : 0),
+ kBadPullDownSwitch_Char[i], kBadPullDownSwitch_Flags[i] | 0x21, kBadPullDownSwitch_Big[i]);
}
Sprite_CorrectOamEntries(k, 4, 0xff);
}
@@ -6027,29 +5969,22 @@
return;
Oam_AllocateDeferToPlayer(k);
OamEnt *oam = GetOamCurPtr();
- int g = sprite_graphics[k];
+ int g = sprite_graphics[k] * 2;
+ uint8 x = BYTE(dungmap_var7);
+ uint8 y = HIBYTE(dungmap_var7);
- oam[0].x = BYTE(dungmap_var7) + kWitch_DrawDataA[g * 2].x;
- oam[0].y = HIBYTE(dungmap_var7) + kWitch_DrawDataA[g * 2].y;
- WORD(oam[0].charnum) = WORD(info.r4) | WORD(kWitch_DrawDataA[g * 2].charnum);
+ SetOamPlain(oam + 0, x + kWitch_DrawDataA[g + 0].x, y + kWitch_DrawDataA[g + 0].y, info.r4 | kWitch_DrawDataA[g + 0].charnum, info.flags, 0);
+ SetOamPlain(oam + 1, x + kWitch_DrawDataA[g + 1].x, y + kWitch_DrawDataA[g + 1].y, info.r4 | kWitch_DrawDataA[g + 1].charnum, info.flags, 0);
- oam[1].x = BYTE(dungmap_var7) + kWitch_DrawDataA[g * 2 + 1].x;
- oam[1].y = HIBYTE(dungmap_var7) + kWitch_DrawDataA[g * 2 + 1].y;
- WORD(oam[1].charnum) = WORD(info.r4) | WORD(kWitch_DrawDataA[g * 2+1].charnum);
for (int i = 0; i < 3; i++) {
- oam[i+2].x = BYTE(dungmap_var7) + kWitch_DrawDataB[i].x;
- oam[i+2].y = HIBYTE(dungmap_var7) + kWitch_DrawDataB[i].y;
- WORD(oam[i+2].charnum) = WORD(info.r4) ^ WORD(kWitch_DrawDataB[i].charnum);
+ SetOamPlain(&oam[i + 2], x + kWitch_DrawDataB[i].x, y + kWitch_DrawDataB[i].y,
+ info.r4 ^ kWitch_DrawDataB[i].charnum,
+ info.flags ^ kWitch_DrawDataB[i].flags, 2);
}
- int i = (uint16)(g - 3) < 3;
- oam[5].x = BYTE(dungmap_var7) + kWitch_DrawDataC[i].x;
- oam[5].y = HIBYTE(dungmap_var7) + kWitch_DrawDataC[i].y;
- WORD(oam[5].charnum) = WORD(info.r4) | WORD(kWitch_DrawDataC[i].charnum);
-
- int e = oam - oam_buf;
- WORD(bytewise_extended_oam[e]) = 0;
- WORD(bytewise_extended_oam[e+2]) = 0x202;
- WORD(bytewise_extended_oam[e+4]) = 0x202;
+ int i = (uint16)(g - 6) < 6;
+ SetOamPlain(&oam[5], x + kWitch_DrawDataC[i].x, y + kWitch_DrawDataC[i].y,
+ info.r4 | kWitch_DrawDataC[i].charnum,
+ info.flags, 2);
Sprite_CorrectOamEntries(k, 5, 0xff);
}
@@ -9755,25 +9690,14 @@
OamEnt *oam = GetOamCurPtr();
for (int i = 3; i >= 0; i--, oam++) {
- uint16 x = info.x + kThrowableScenery_DrawLarge_X[i];
- uint16 y = info.y + kThrowableScenery_DrawLarge_Y[i];
- oam->x = x;
- oam->y = (uint16)(y + 0x10) < 0x100 ? y : 0xf0;
- oam->charnum = 0x4a;
- oam->flags = kThrowableScenery_DrawLarge_Flags[i] | info.flags;
- bytewise_extended_oam[oam - oam_buf] = 2 | (x >> 8 & 1);
+ SetOamHelper0(oam, info.x + kThrowableScenery_DrawLarge_X[i], info.y + kThrowableScenery_DrawLarge_Y[i],
+ 0x4a, kThrowableScenery_DrawLarge_Flags[i] | info.flags, 2);
}
Oam_AllocateFromRegionB(12);
oam = GetOamCurPtr();
info.y = Sprite_GetY(k) - BG2VOFS_copy2;
for (int i = 2; i >= 0; i--, oam++) {
- uint16 x = info.x + kThrowableScenery_DrawLarge_X2[i];
- uint16 y = info.y + 12;
- oam->x = x;
- oam->y = (uint16)(y + 0x10) < 0x100 ? y : 0xf0;
- oam->charnum = 0x6c;
- oam->flags = 0x24;
- bytewise_extended_oam[oam - oam_buf] = 2 | (x >> 8 & 1);
+ SetOamHelper0(oam, info.x + kThrowableScenery_DrawLarge_X2[i], info.y + 12, 0x6c, 0x24, 2);
}
}
@@ -10691,9 +10615,9 @@
oam[3].flags |= flags;
oam[4].flags |= flags;
- uint8 *ext = &g_ram[oam_ext_cur_ptr];
- ext[0] = ext[1] = ext[2] = ext[3] = 0;
- ext[4] = 2;
+ uint8 *big = &g_ram[oam_ext_cur_ptr];
+ big[0] = big[1] = big[2] = big[3] = 0;
+ big[4] = 2;
Sprite_CorrectOamEntries(k, 4, 0xff);
@@ -11716,7 +11640,7 @@
static const uint8 kFaerieQueen_Draw_Flags[24] = {
0, 0x40, 0, 0, 0x40, 0x40, 0, 0, 0x40, 0x40, 0, 0x40, 0, 0x40, 0, 0, 0x40, 0x40, 0, 0, 0x40, 0x40, 0, 0x40,
};
- static const uint8 kFaerieQueen_Draw_Ext[24] = {
+ static const uint8 kFaerieQueen_Draw_Big[24] = {
2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2,
};
static const DrawMultipleData kFaerieQueen_Dmd[20] = {
@@ -11749,11 +11673,8 @@
int g = sprite_graphics[k];
for (int i = 11; i >= 0; i--, oam++) {
int j = g * 12 + i;
- oam->x = kFaerieQueen_Draw_X[j] + info.x;
- oam->y = kFaerieQueen_Draw_Y[j] + info.y;
- oam->charnum = kFaerieQueen_Draw_Char[j];
- oam->flags = info.flags | kFaerieQueen_Draw_Flags[j];
- bytewise_extended_oam[oam - oam_buf] = kFaerieQueen_Draw_Ext[j];
+ SetOamPlain(oam, kFaerieQueen_Draw_X[j] + info.x, kFaerieQueen_Draw_Y[j] + info.y,
+ kFaerieQueen_Draw_Char[j], info.flags | kFaerieQueen_Draw_Flags[j], kFaerieQueen_Draw_Big[j]);
}
Sprite_CorrectOamEntries(k, 11, 0xff);
} else {
@@ -11855,7 +11776,7 @@
0, 1, 0, 0x40, 6, 0x41, 0x41, 0, 6, 0x41, 0x41, 0, 6, 1, 1, 0,
6, 1, 1, 0, 6, 1, 1, 0,
};
- static const uint8 kLeever_Draw_Ext[56] = {
+ static const uint8 kLeever_Draw_Big[56] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 2, 2, 0, 0, 2, 2, 0, 0, 2, 2, 0, 0,
2, 2, 0, 0, 2, 2, 2, 0, 2, 2, 2, 0, 2, 2, 2, 0,
@@ -11873,7 +11794,7 @@
if (charnum >= 0x60 || charnum == 0x28 || charnum == 0x38)
f &= 0xf0;
SetOamHelper0(oam, info.x + kLeever_Draw_X[j], info.y + kLeever_Draw_Y[j],
- charnum, kLeever_Draw_Flags[j] | f, kLeever_Draw_Ext[j]);
+ charnum, kLeever_Draw_Flags[j] | f, kLeever_Draw_Big[j]);
}
}
@@ -13501,7 +13422,7 @@
static const int8 kArcheryGameGuy_Draw_Y[15] = {0, -10, -10, 0, -10, -3, 0, -10, -10, 0, -10, -10, 0, -10, -10};
static const uint8 kArcheryGameGuy_Draw_Char[15] = {0x26, 6, 6, 8, 6, 0x3a, 0x26, 6, 6, 0x26, 6, 6, 0x26, 6, 6};
static const uint8 kArcheryGameGuy_Draw_Flags[15] = {8, 6, 6, 8, 6, 8, 8, 6, 6, 8, 6, 6, 8, 6, 6};
- static const uint8 kArcheryGameGuy_Draw_Ext[15] = {2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2};
+ static const uint8 kArcheryGameGuy_Draw_Big[15] = {2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2};
Oam_AllocateDeferToPlayer(k);
PrepOamCoordsRet info;
@@ -13510,11 +13431,8 @@
int g = sprite_graphics[k];
for (int i = 2; i >= 0; i--, oam++) {
int j = g * 3 + i;
- oam->x = info.x + kArcheryGameGuy_Draw_X[j];
- oam->y = info.y + kArcheryGameGuy_Draw_Y[j];
- oam->charnum = kArcheryGameGuy_Draw_Char[j];
- oam->flags = kArcheryGameGuy_Draw_Flags[j] | info.flags;
- bytewise_extended_oam[oam - oam_buf] = kArcheryGameGuy_Draw_Ext[j];
+ SetOamPlain(oam, info.x + kArcheryGameGuy_Draw_X[j], info.y + kArcheryGameGuy_Draw_Y[j],
+ kArcheryGameGuy_Draw_Char[j], kArcheryGameGuy_Draw_Flags[j] | info.flags, kArcheryGameGuy_Draw_Big[j]);
}
SpriteDraw_Shadow(k, &info);
}
@@ -15164,11 +15082,8 @@
int g = sprite_graphics[k];
for (int i = 0; i < 12; i++, oam++) {
int j = g * 12 + i;
- oam->x = info.x + kGanon_Draw_X[j];
- oam->y = info.y + kGanon_Draw_Y[j];
- oam->charnum = kGanon_Draw_Char[j];
- oam->flags = info.flags | (kGanon_Draw_Flags[j] & ((info.flags & 0xf) >= 5 ? 0xf0 : 0xff));
- bytewise_extended_oam[oam - oam_buf] = 2;
+ SetOamPlain(oam, info.x + kGanon_Draw_X[j], info.y + kGanon_Draw_Y[j], kGanon_Draw_Char[j],
+ info.flags | (kGanon_Draw_Flags[j] & ((info.flags & 0xf) >= 5 ? 0xf0 : 0xff)), 2);
}
static const uint8 kGanon_SprOffs[17] = {
1, 1, 1, 1, 1, 1, 15, 1, 4, 4, 4, 4, 4, 4, 4, 15, 15,
@@ -16499,11 +16414,7 @@
uint8 xb = sprite_A[k] - sprite_x_lo[k];
uint8 yb = sprite_C[k] - sprite_y_lo[k];
for (int i = 7; i >= 0; i--, oam++) {
- oam->x = info.x + TrinexxMult(xb, kTrinexx_Mults[i]);
- oam->y = info.y + TrinexxMult(yb, kTrinexx_Mults[i]);
- oam->charnum = 0x28;
- oam->flags = info.flags;
- bytewise_extended_oam[oam - oam_buf] = 2;
+ SetOamPlain(oam, info.x + TrinexxMult(xb, kTrinexx_Mults[i]), info.y + TrinexxMult(yb, kTrinexx_Mults[i]), 0x28, info.flags, 2);
}
byte_7E0FB6 = 0x30;
}
@@ -16517,13 +16428,11 @@
uint8 yidx = sprite_subtype2[k] >> 2;
for (int i = 1; i >= 0; i--, oam += 2) {
- oam[0].x = oam[1].x = xb + (i ? -28 : 28) + kTrinexx_Draw_Xoffs[xidx + (1-i) * 8 & 0xf];
- oam[0].y = yb - 8 + kTrinexx_Draw_Yoffs[yidx + i * 8 & 0xf];
- oam[1].y = oam[0].y + 16;
- oam[0].charnum = 0xc;
- oam[1].charnum = 0x2a;
- oam[0].flags = oam[1].flags = info.flags | (i ? 0 : 0x40);
- WORD(bytewise_extended_oam[oam - oam_buf]) = 0x202;
+ uint8 x = xb + (i ? -28 : 28) + kTrinexx_Draw_Xoffs[xidx + (1 - i) * 8 & 0xf];
+ uint8 y = yb - 8 + kTrinexx_Draw_Yoffs[yidx + i * 8 & 0xf];
+ uint8 f = info.flags | (i ? 0 : 0x40);
+ SetOamPlain(oam + 0, x, y, 0xc, f, 2);
+ SetOamPlain(oam + 1, x, y + 16, 0x2a, f, 2);
}
oam = (OamEnt *)&g_ram[0x800] + 91;
@@ -16741,24 +16650,22 @@
for (int m = 0; m < 5; m++) {
BYTE(cur_sprite_x) = info.x + BYTE(dungmap_var7);
- oam->x = BYTE(cur_sprite_x) + kTrinexxHead_FirstPart_X[m];
+ uint8 x = BYTE(cur_sprite_x) + kTrinexxHead_FirstPart_X[m];
BYTE(cur_sprite_y) = info.y + HIBYTE(dungmap_var7);
- oam->y = BYTE(cur_sprite_y) + kTrinexxHead_FirstPart_Y[m] + (m == 4 ? sprite_subtype[k] : 0);
+ uint8 y = BYTE(cur_sprite_y) + kTrinexxHead_FirstPart_Y[m] + (m == 4 ? sprite_subtype[k] : 0);
- oam->charnum = kTrinexxHead_FirstPart_Char[m];
- oam->flags = info.flags | kTrinexxHead_FirstPart_Flags[m];
- bytewise_extended_oam[oam - oam_buf] = 2;
+ SetOamPlain(oam, x, y, kTrinexxHead_FirstPart_Char[m], info.flags | kTrinexxHead_FirstPart_Flags[m], 2);
oam++;
}
Sprite_SetX(k, (sprite_B[k] << 8 | sprite_A[k]) + (int8)BYTE(dungmap_var7));
Sprite_SetY(k, (sprite_G[k] << 8 | sprite_C[k]) + (int8)HIBYTE(dungmap_var7));
} else {
- BYTE(cur_sprite_x) = oam->x = info.x + BYTE(dungmap_var7);
- BYTE(cur_sprite_y) = oam->y = info.y + HIBYTE(dungmap_var7);
- oam->charnum = 8;
- oam->flags = info.flags;
- bytewise_extended_oam[oam - oam_buf] = 2;
+ uint8 x = info.x + BYTE(dungmap_var7);
+ uint8 y = info.y + HIBYTE(dungmap_var7);
+ BYTE(cur_sprite_x) = x;
+ BYTE(cur_sprite_y) = y;
+ SetOamPlain(oam, x, y, 8, info.flags, 2);
oam++;
}
} while (++i != sprite_subtype2[k]);
@@ -17944,12 +17851,12 @@
{ -8, 16, 0x20, 0x84},
{ 8, 16, 0x20, 0xc4},
};
- static const uint8 kChattyAgahnim_Telewarp_Data_Ext[14] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2};
+ static const uint8 kChattyAgahnim_Telewarp_Data_Big[14] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2};
Oam_AllocateFromRegionA(0x38);
const OamEntSigned *data = kChattyAgahnim_Telewarp_Data;
if (!(frame_counter & 2))
data += 14;
- const uint8 *ext_data = kChattyAgahnim_Telewarp_Data_Ext;
+ const uint8 *bigp = kChattyAgahnim_Telewarp_Data_Big;
if (!sprite_subtype2[k])
return;
OamEnt *oam = GetOamCurPtr();
@@ -17957,15 +17864,11 @@
uint8 end = sprite_subtype[k];
uint8 t = end + 1;
oam += t;
- ext_data += t;
+ bigp += t;
data += t;
do {
- oam->x = info->x + data->x;
- oam->y = info->y + data->y - 8;
- oam->charnum = data->charnum;
- oam->flags = data->flags | 0x31;
- bytewise_extended_oam[oam - oam_buf] = *ext_data;
- } while (data++, ext_data++, oam++, --kn != end);
+ SetOamPlain(oam, info->x + data->x, info->y + data->y - 8, data->charnum, data->flags | 0x31, *bigp);
+ } while (data++, bigp++, oam++, --kn != end);
}
void Sprite_CutsceneAgahnim_Zelda(int k) { // 9dd57d
@@ -18132,12 +18035,8 @@
int r6 = sprite_D[k] - 1;
for (int i = 1; i >= 0; i--, oam++, r6 += 2) {
uint16 x = info->x + kGiantMoldorm_Eye_X[r6 & 0xf];
- int y = info->y + (uint16)kGiantMoldorm_Eye_Y[r6 & 0xf];
- oam->x = x;
- oam->y = (uint16)(y + 0x10 + ((y >> 16) & 1)) < 0x100 ? y : 0xf0;
- oam->charnum = kGiantMoldorm_Eye_Char[(r6 + r7) & 0xf];
- oam->flags = info->flags | kGiantMoldorm_Eye_Flags[(r6 + r7) & 0xf];
- bytewise_extended_oam[oam - oam_buf] = 2 | (x >> 8 & 1);
+ uint16 y = info->y + kGiantMoldorm_Eye_Y[r6 & 0xf];
+ SetOamHelper0(oam, x, y, kGiantMoldorm_Eye_Char[(r6 + r7) & 0xf], info->flags | kGiantMoldorm_Eye_Flags[(r6 + r7) & 0xf], 2);
}
}
@@ -19061,7 +18960,7 @@
static const int8 kMoldorm_Draw_Y[16] = {4, 6, 9, 10, 11, 10, 9, 6, 3, 0, -2, -3, -4, -3, -2, 1};
static const uint8 kMoldorm_Draw_Char[3] = {0x5d, 0x62, 0x60};
static const int8 kMoldorm_Draw_XY[3] = {4, 0, 0};
- static const uint8 kMoldorm_Draw_Ext[3] = {0, 2, 2};
+ static const uint8 kMoldorm_Draw_Big[3] = {0, 2, 2};
static const uint8 kMoldorm_Draw_GetOffs[3] = {21, 26, 0};
PrepOamCoordsRet info;
@@ -19070,13 +18969,8 @@
OamEnt *oam = GetOamCurPtr();
uint8 base = sprite_D[k] - 1;
for (int i = 1; i >= 0; i--, oam++, base += 2) {
- uint16 x = info.x + kMoldorm_Draw_X[base & 0xf];
- int y = info.y + (uint16)kMoldorm_Draw_Y[base & 0xf];
- oam->x = x;
- oam->y = (uint16)(y + 0x10 + ((y >> 16) & 1)) < 0x100 ? y : 0xf0;
- oam->charnum = 0x4D;
- oam->flags = info.flags;
- bytewise_extended_oam[oam - oam_buf] = (x >> 8 & 1);
+ SetOamHelper0(oam, info.x + kMoldorm_Draw_X[base & 0xf], info.y + kMoldorm_Draw_Y[base & 0xf],
+ 0x4d, info.flags, 0);
}
oam_cur_ptr += 8;
oam_ext_cur_ptr += 2;
@@ -19091,7 +18985,7 @@
j = ((sprite_subtype2[k] + kMoldorm_Draw_GetOffs[i]) & 0x1f) + k * 32;
uint16 x = (moldorm_x_lo[j] | moldorm_x_hi[j] << 8) - BG2HOFS_copy2 + kMoldorm_Draw_XY[i];
uint16 y = (moldorm_y_lo[j] | moldorm_y_hi[j] << 8) - BG2VOFS_copy2 + kMoldorm_Draw_XY[i];
- SetOamHelper0(oam, x, y, kMoldorm_Draw_Char[i], info.flags, kMoldorm_Draw_Ext[i]);
+ SetOamHelper0(oam, x, y, kMoldorm_Draw_Char[i], info.flags, kMoldorm_Draw_Big[i]);
}
}
@@ -19691,12 +19585,8 @@
oam_cur_ptr += 0x40, oam_ext_cur_ptr += 0x10;
OamEnt *oam = GetOamCurPtr();
for (int i = 1; i >= 0; i--, oam++) {
- oam->x = info->x + kHelmasaurKing_DrawB_X[i];
- oam->y = info->y + 0x14;
int j = overlord_x_lo[4] >> 2 & 7;
- oam->charnum = kHelmasaurKing_DrawB_Char[j];
- oam->flags = kHelmasaurKing_DrawB_Flags[i];
- bytewise_extended_oam[oam - oam_buf] = 0;
+ SetOamPlain(oam, info->x + kHelmasaurKing_DrawB_X[i], info->y + 0x14, kHelmasaurKing_DrawB_Char[j], kHelmasaurKing_DrawB_Flags[i], 0);
}
if (submodule_index)
Sprite_CorrectOamEntries(k, 1, 0);
@@ -19798,14 +19688,11 @@
oam_ext_cur_ptr += 19;
OamEnt *oam = GetOamCurPtr();
for (int i = 3; i >= 0; i--, oam += 2) {
- oam[1].x = oam[0].x = info->x + kHelmasaurKing_DrawE_X[i];
- oam[0].y = info->y + kHelmasaurKing_DrawE_Y[i] + overlord_x_lo[i];
- oam[1].y = oam[0].y + 0x10;
- oam[0].charnum = kHelmasaurKing_DrawE_Char[i];
- oam[1].charnum = oam[0].charnum + 2;
- oam[1].flags = oam[0].flags = kHelmasaurKing_DrawE_Flags[i] ^ info->flags;
- bytewise_extended_oam[oam - oam_buf] = 2;
- bytewise_extended_oam[oam - oam_buf + 1] = 2;
+ uint8 x = info->x + kHelmasaurKing_DrawE_X[i];
+ uint8 y = info->y + kHelmasaurKing_DrawE_Y[i] + overlord_x_lo[i];
+ uint8 f = kHelmasaurKing_DrawE_Flags[i] ^ info->flags;
+ SetOamPlain(oam + 0, x, y, kHelmasaurKing_DrawE_Char[i], f, 2);
+ SetOamPlain(oam + 1, x, y + 16, kHelmasaurKing_DrawE_Char[i] + 2, f, 2);
}
tmp_counter = 0xff;
if (submodule_index) {
@@ -19824,12 +19711,7 @@
uint8 yd = kHelmasaurKing_DrawF_Y[sprite_delay_aux2[k] >> 2];
Oam_AllocateFromRegionB(4);
OamEnt *oam = GetOamCurPtr();
- oam->x = info->x;
- int t = (uint8)info->y + 0x13;
- oam->y = t + (t >> 8) + yd;
- oam->charnum = 0xaa;
- oam->flags = info->flags ^ 0xb;
- bytewise_extended_oam[oam - oam_buf] = 2;
+ SetOamPlain(oam, info->x, info->y + yd + 0x13, 0xaa, info->flags ^ 0xb, 2);
}
void KingHelmasaur_OperateTail(int k, PrepOamCoordsRet *info) { // 9e8920
@@ -23525,11 +23407,7 @@
int8 cosval = GuruguruBarSin((angle + 0x80) & 0x1ff, 0x40);
uint8 flags = (sprite_subtype2[k] << 4 & 0xc0) | info.flags;
for (int i = 3; i >= 0; i--, oam++) {
- oam->x = info.x + sinval * (i + 1) / 4;
- oam->y = info.y + cosval * (i + 1) / 4;
- oam->charnum = 0x28;
- oam->flags = flags;
- bytewise_extended_oam[oam - oam_buf] = 2;
+ SetOamPlain(oam, info.x + sinval * (i + 1) / 4, info.y + cosval * (i + 1) / 4, 0x28, flags, 2);
}
Sprite_CorrectOamEntries(k, 3, 0xff);
if (!((k ^ frame_counter) & 3 | submodule_index | flag_unk1)) {
@@ -23910,7 +23788,7 @@
0xc6, 0xc6, 0xce, 0xcc, 0xc6, 0xc6, 0xc6, 0xc6, 0xce, 0xcc, 0xc6, 0xc6, 0xc6, 0xc6, 0xce, 0xcc,
0xc6, 0xc6, 0xc6, 0xc6,
};
- static const uint8 kAgahnim_Draw_Ext1[36] = {
+ static const uint8 kAgahnim_Draw_Big1[36] = {
0, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 0, 2, 2, 2,
2, 2, 0, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 0, 2,
2, 2, 2, 2,
@@ -23922,11 +23800,9 @@
int g = sprite_graphics[k];
for (int i = 3; i >= 0; i--, oam++) {
int j = g * 4 + i;
- oam->x = info.x + kAgahnim_Draw_X0[j];
- oam->y = info.y + kAgahnim_Draw_Y0[j];
- oam->charnum = kAgahnim_Draw_Char0[j];
- oam->flags = info.flags | kAgahnim_Draw_Flags0[j];
- bytewise_extended_oam[oam - oam_buf] = (j >= 0x40 && j < 0x44) ? 0 : 2;
+ SetOamPlain(oam, info.x + kAgahnim_Draw_X0[j], info.y + kAgahnim_Draw_Y0[j],
+ kAgahnim_Draw_Char0[j], info.flags | kAgahnim_Draw_Flags0[j],
+ (j >= 0x40 && j < 0x44) ? 0 : 2);
}
if (g < 12)
SpriteDraw_Shadow_custom(k, &info, 18);
@@ -23947,11 +23823,8 @@
g = sprite_head_dir[k] - 1;
uint8 flags = (((frame_counter >> 1) & 2) + 2) + 0x31;
for (int i = 1; i >= 0; i--, oam++) {
- oam->x = info.x + kAgahnim_Draw_X1[g * 2 + i];
- oam->y = info.y + kAgahnim_Draw_Y1[g * 2 + i];
- oam->charnum = kAgahnim_Draw_Char1[g];
- oam->flags = flags;
- bytewise_extended_oam[oam - oam_buf] = kAgahnim_Draw_Ext1[g];
+ SetOamPlain(oam, info.x + kAgahnim_Draw_X1[g * 2 + i], info.y + kAgahnim_Draw_Y1[g * 2 + i],
+ kAgahnim_Draw_Char1[g], flags, kAgahnim_Draw_Big1[g]);
}
}
--- a/tagalong.c
+++ b/tagalong.c
@@ -583,6 +583,15 @@
Follower_AnimateMovement_preserved(a, x, y);
}
+static inline void SetOam_Follower(OamEnt *oam, uint16 x, uint16 y, uint8 charnum, uint8 flags, uint8 big) {
+ oam->x = x;
+ oam->y = (uint16)(x + 0x80) < 0x180 && (big |= x >> 8 & 1, (uint16)(y + 0x10) < 0x100) ? y : 0xf0;
+ oam->charnum = charnum;
+ oam->flags = flags;
+ bytewise_extended_oam[oam - oam_buf] = big;
+}
+
+
void Follower_AnimateMovement_preserved(uint8 ain, uint16 xin, uint16 yin) { // 89a959
uint8 yt = 0, av = 0;
@@ -632,24 +641,10 @@
byte_7E02D7 = 0;
}
sk += byte_7E02D7 * 4;
- {
- uint16 y = scrolly + 16, x = scrollx, ext = 0;
- oam->x = x;
- oam->y = (uint16)(x + 0x80) < 0x180 && (ext = x >> 8 & 1, (uint16)(y + 0x10) < 0x100) ? y : 0xf0;
- oam->charnum = sk[0];
- oam->flags = sk[1];
- bytewise_extended_oam[oam - oam_buf] = ext;
- oam++;
-
- ext = 0, x += 8;
- oam->x = x;
- oam->y = (uint16)(x + 0x80) < 0x180 && (ext = x >> 8 & 1, (uint16)(y + 0x10) < 0x100) ? y : 0xf0;
- oam->charnum = sk[2];
- oam->flags = sk[3];
- bytewise_extended_oam[oam - oam_buf] = ext;
- oam++;
- }
- uint8 pal;
+ SetOam_Follower(oam + 0, scrollx, scrolly + 16, sk[0], sk[1], 0);
+ SetOam_Follower(oam + 1, scrollx + 8, scrolly + 16, sk[2], sk[3], 0);
+ oam += 2;
+ uint8 pal;
skip_first_sprites:
pal = kTagalongDraw_Pals[follower_indicator];
if (pal == 7 && overworld_palette_swap_flag)
@@ -662,22 +657,14 @@
const TagalongDmaFlags *sprf = kTagalongDmaAndFlags + frame;
if (follower_indicator != 12 && follower_indicator != 13) {
- uint16 y = scrolly + sprd->y1, x = scrollx + sprd->x1, ext = 0;
- oam->x = x;
- oam->y = (uint16)(x + 0x80) < 0x180 && (ext = x >> 8 & 1, (uint16)(y + 0x10) < 0x100) ? y : 0xf0;
- oam->charnum = 0x20;
- oam->flags = (sprf->flags & 0xf0) | pal << 1 | (oam_priority_value >> 8);
- bytewise_extended_oam[oam - oam_buf] = 2 | ext;
+ SetOam_Follower(oam, scrollx + sprd->x1, scrolly + sprd->y1, 0x20,
+ (sprf->flags & 0xf0) | pal << 1 | (oam_priority_value >> 8), 2);
oam++;
BYTE(dma_var6) = sprf->dma6;
}
{
- uint16 y = scrolly + sprd->y2 + 8, x = scrollx + sprd->x2, ext = 0;
- oam->x = x;
- oam->y = (uint16)(x + 0x80) < 0x180 && (ext = x >> 8 & 1, (uint16)(y + 0x10) < 0x100) ? y : 0xf0;
- oam->charnum = 0x22;
- oam->flags = ((sprf->flags & 0xf) << 4) | pal << 1 | (oam_priority_value >> 8);
- bytewise_extended_oam[oam - oam_buf] = 2 | ext;
+ SetOam_Follower(oam, scrollx + sprd->x2, scrolly + sprd->y2 + 8, 0x22,
+ ((sprf->flags & 0xf) << 4) | pal << 1 | (oam_priority_value >> 8), 2);
BYTE(dma_var7) = sprf->dma7;
}
}
--- a/zelda_cpu_infra.c
+++ b/zelda_cpu_infra.c
@@ -485,6 +485,9 @@
PatchRomBP(rom, 0x6d0c6);
PatchRomBP(rom, 0x1d8f29); // adc instead of add
+ PatchRomBP(rom, 0x1DDBD3); // adc instead of add
+ PatchRomBP(rom, 0x1DF856); // adc instead of add
+ PatchRomBP(rom, 0x1E88DA); // adc instead of add
PatchRomBP(rom, 0x06ED0B);