worked on tsc some more, fixed Surface2Surface, blah blah blah happy birthday to me

This commit is contained in:
cuckydev 2019-01-27 01:28:14 -05:00
parent b41dab1de9
commit 11bbcde9f8
7 changed files with 451 additions and 3 deletions

View file

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

View file

@ -130,7 +130,10 @@ bool MakeSurface(SDL_RWops *fp, int surf_no)
SDL_SetTextureBlendMode(textureAccessible, SDL_BLENDMODE_BLEND);
SDL_SetRenderTarget(gRenderer, textureAccessible);
SDL_SetRenderDrawColor(gRenderer, 0, 0, 0, 0);
SDL_RenderClear(gRenderer);
SDL_RenderCopy(gRenderer, texture, NULL, NULL);
SDL_RenderPresent(gRenderer);
SDL_SetRenderTarget(gRenderer, NULL);
//Set surface's metadata

View file

@ -170,7 +170,7 @@ int JudgeHitMyCharTriangleC(int x, int y)
&& gMC.y + gMC.hit.bottom > (2 * y - 1) << 12)
{
//Clip
gMC.y = (y << 13) - (-0x2000 * x + gMC.x) / 2 - 0x800 + gMC.hit.top;
gMC.y = (y << 13) + (-0x2000 * x + gMC.x) / 2 - 0x800 + gMC.hit.top;
//Halt momentum
if (!(gMC.cond & 2) && gMC.ym < -0x200)

View file

@ -6,8 +6,10 @@
#include "CommonDefines.h"
#include "Tags.h"
#include "NpChar.h"
#include "MyChar.h"
#include "Game.h"
#include "Flags.h"
#include "Sound.h"
#include "NpcTbl.h"
#include "Draw.h"
@ -338,3 +340,264 @@ void ActNpChar()
}
}
}
void ChangeNpCharByEvent(int code_event, int code_char, int dir)
{
for (int n = 0; n < NPC_MAX; n++)
{
if ((gNPC[n].cond & 0x80u) && gNPC[n].code_event == code_event)
{
gNPC[n].bits &= (npc_eventTouch | npc_eventDie | 0x400 | npc_appearSet | npc_altDir | npc_interact | npc_hideSet);
gNPC[n].code_char = code_char;
gNPC[n].bits |= gNpcTable[gNPC[n].code_char].bits;
gNPC[n].exp = gNpcTable[gNPC[n].code_char].exp;
SetUniqueParameter(&gNPC[n]);
gNPC[n].cond |= 0x80u;
gNPC[n].act_no = 0;
gNPC[n].act_wait = 0;
gNPC[n].count1 = 0;
gNPC[n].count2 = 0;
gNPC[n].ani_no = 0;
gNPC[n].ani_wait = 0;
gNPC[n].xm = 0;
gNPC[n].ym = 0;
if (dir != 5)
{
if (dir == 4)
{
if (gNPC[n].x >= gMC.x)
gNPC[n].direct = 0;
else
gNPC[n].direct = 2;
}
else
{
gNPC[n].direct = dir;
}
}
if (gpNpcFuncTbl[code_char] != nullptr)
gpNpcFuncTbl[code_char](&gNPC[n]);
}
}
}
void ChangeCheckableNpCharByEvent(int code_event, int code_char, int dir)
{
for (int n = 0; n < NPC_MAX; n++)
{
if ((gNPC[n].cond & 0x80u) != 0 && gNPC[n].code_event == code_event)
{
gNPC[n].bits &= (npc_eventTouch | npc_eventDie | 0x400 | npc_appearSet | npc_altDir | npc_interact | npc_hideSet);
gNPC[n].bits |= npc_interact;
gNPC[n].code_char = code_char;
gNPC[n].bits |= gNpcTable[gNPC[n].code_char].bits;
gNPC[n].exp = gNpcTable[gNPC[n].code_char].exp;
SetUniqueParameter(&gNPC[n]);
gNPC[n].cond |= 0x80u;
gNPC[n].act_no = 0;
gNPC[n].act_wait = 0;
gNPC[n].count1 = 0;
gNPC[n].count2 = 0;
gNPC[n].ani_no = 0;
gNPC[n].ani_wait = 0;
gNPC[n].xm = 0;
gNPC[n].ym = 0;
if (dir != 5)
{
if (dir == 4)
{
if (gNPC[n].x >= gMC.x)
gNPC[n].direct = 0;
else
gNPC[n].direct = 2;
}
else
{
gNPC[n].direct = dir;
}
}
if (gpNpcFuncTbl[code_char] != nullptr)
gpNpcFuncTbl[code_char](&gNPC[n]);
}
}
}
void SetNpCharActionNo(int code_event, int act_no, int dir)
{
for (int n = 0; n < NPC_MAX; n++)
{
if ((gNPC[n].cond & 0x80) && gNPC[n].code_event == code_event)
{
gNPC[n].act_no = act_no;
if (dir != 5)
{
if (dir == 4)
{
if (gNPC[n].x >= gMC.x)
gNPC[n].direct = 0;
else
gNPC[n].direct = 2;
}
else
{
gNPC[n].direct = dir;
}
}
break;
}
}
}
void MoveNpChar(int code_event, int x, int y, int dir)
{
for (int n = 0; n < NPC_MAX; n++)
{
if ((gNPC[n].cond & 0x80) && gNPC[n].code_event == code_event)
{
gNPC[n].x = x;
gNPC[n].y = y;
if (dir != 5)
{
if (dir == 4)
{
if (gNPC[n].x >= gMC.x)
gNPC[n].direct = 0;
else
gNPC[n].direct = 2;
}
else
{
gNPC[n].direct = dir;
}
}
break;
}
}
}
void BackStepMyChar(int code_event)
{
gMC.cond &= ~1;
gMC.ym = -0x200;
if (code_event)
{
if (code_event == 2)
{
gMC.direct = 2;
gMC.xm = -0x200;
}
else
{
for (int n = 0; n < NPC_MAX; n++)
{
if ((gNPC[n].cond & 0x80) && gNPC[n].code_event == code_event)
{
if (gNPC[n].x >= gMC.x)
{
gMC.direct = 2;
gMC.xm = -0x200;
}
else
{
gMC.direct = 0;
gMC.xm = 0x200;
}
}
}
}
}
else
{
gMC.direct = 0;
gMC.xm = 0x200;
}
}
void DeleteNpCharEvent(int code)
{
for (int i = 0; i < NPC_MAX; i++)
{
if ((gNPC[i].cond & 0x80) && gNPC[i].code_event == code)
{
gNPC[i].cond = 0;
SetNPCFlag(gNPC[i].code_flag);
}
}
}
void DeleteNpCharCode(int code, bool bSmoke)
{
for (int n = 0; n < NPC_MAX; n++)
{
if ((gNPC[n].cond & 0x80) && gNPC[n].code_char == code)
{
gNPC[n].cond = 0;
SetNPCFlag(gNPC[n].code_flag);
if (bSmoke)
{
PlaySoundObject(gNPC[n].destroy_voice, 1);
switch (gNPC[n].size)
{
case 2:
SetDestroyNpChar(gNPC[n].x, gNPC[n].y, gNPC[n].view.back, 8);
break;
case 3:
SetDestroyNpChar(gNPC[n].x, gNPC[n].y, gNPC[n].view.back, 16);
break;
case 1:
SetDestroyNpChar(gNPC[n].x, gNPC[n].y, gNPC[n].view.back, 4);
break;
}
}
}
}
}
void GetNpCharPosition(int *x, int *y, int i)
{
*x = gNPC[i].x;
*y = gNPC[i].y;
}
bool IsNpCharCode(int code)
{
for (int i = 0; i < NPC_MAX; i++)
{
if ((gNPC[i].cond & 0x80) && gNPC[i].code_char == code)
return true;
}
return false;
}
bool GetNpCharAlive(int code_event)
{
for (int i = 0; i < NPC_MAX; i++)
{
if ((gNPC[i].cond & 0x80) && gNPC[i].code_event == code_event)
return true;
}
return false;
}
int CountAliveNpChar()
{
int count = 0;
for (int n = 0; n < NPC_MAX; ++n)
{
if (gNPC[n].cond & 0x80)
++count;
}
return count;
}

View file

@ -83,3 +83,14 @@ bool SetBulletObject(int x, int y, int val);
void VanishNpChar(NPCHAR *npc);
void PutNpChar(int fx, int fy);
void ActNpChar();
void ChangeNpCharByEvent(int code_event, int code_char, int dir);
void ChangeCheckableNpCharByEvent(int code_event, int code_char, int dir);
void SetNpCharActionNo(int code_event, int act_no, int dir);
void MoveNpChar(int code_event, int x, int y, int dir);
void BackStepMyChar(int code_event);
void DeleteNpCharEvent(int code);
void DeleteNpCharCode(int code, bool bSmoke);
void GetNpCharPosition(int *x, int *y, int i);
bool IsNpCharCode(int code);
bool GetNpCharAlive(int code_event);
int CountAliveNpChar();

View file

@ -71,7 +71,6 @@ bool TransferStage(int no, int w, int x, int y)
SetMyCharPosition(x << 13, y << 13);
bool bError = false;
bool result;
//Get path
char path_dir[20];

View file

@ -1,7 +1,6 @@
#include <stdint.h>
#include <string>
#include <SDL_messagebox.h>
#include "WindowsWrapper.h"
#include "CommonDefines.h"
@ -410,6 +409,61 @@ void PutTextScript()
rect.bottom = rect.top + 11;
CortBox(&rect, 0xFFFFFE);
}
//Draw GIT
RECT rcItemBox1 = {0, 0, 72, 16};
RECT rcItemBox2 = {0, 8, 72, 24};
RECT rcItemBox3 = {240, 0, 244, 8};
RECT rcItemBox4 = {240, 8, 244, 16};
RECT rcItemBox5 = {240, 16, 244, 24};
if (gTS.item)
{
PutBitmap3(&grcFull, (WINDOW_WIDTH - 80) / 2, WINDOW_HEIGHT - 112, &rcItemBox1, 26);
PutBitmap3(&grcFull, (WINDOW_WIDTH - 80) / 2, WINDOW_HEIGHT - 96, &rcItemBox2, 26);
PutBitmap3(&grcFull, (WINDOW_WIDTH + 64) / 2, WINDOW_HEIGHT - 112, &rcItemBox3, 26);
PutBitmap3(&grcFull, (WINDOW_WIDTH + 64) / 2, WINDOW_HEIGHT - 104, &rcItemBox4, 26);
PutBitmap3(&grcFull, (WINDOW_WIDTH + 64) / 2, WINDOW_HEIGHT - 96, &rcItemBox4, 26);
PutBitmap3(&grcFull, (WINDOW_WIDTH + 64) / 2, WINDOW_HEIGHT - 88, &rcItemBox5, 26);
if (gTS.item_y < WINDOW_HEIGHT - 104)
++gTS.item_y;
RECT rect;
if (gTS.item >= 1000)
{
rect.left = 32 * ((gTS.item - 1000) % 8);
rect.right = 32 * ((gTS.item - 1000) % 8) + 32;
rect.top = 16 * ((gTS.item - 1000) / 8);
rect.bottom = 16 * ((gTS.item - 1000) / 8) + 16;
PutBitmap3(&grcFull, (WINDOW_WIDTH - 40) / 2, gTS.item_y, &rect, 8);
}
else
{
rect.left = 16 * (gTS.item % 16);
rect.right = 16 * (gTS.item % 16) + 16;
rect.top = 16 * (gTS.item / 16);
rect.bottom = 16 * (gTS.item / 16) + 16;
PutBitmap3(&grcFull, (WINDOW_WIDTH - 24) / 2, gTS.item_y, &rect, 12);
}
}
//Draw Yes / No selection
RECT rect_yesno = {152, 48, 244, 80};
RECT rect_cur = {112, 88, 128, 104};
if (gTS.mode == 6 )
{
int i;
if (gTS.wait > 1)
i = WINDOW_HEIGHT - 96;
else
i = WINDOW_HEIGHT - 88 - gTS.wait * 4;
PutBitmap3(&grcFull, (WINDOW_WIDTH + 112) / 2, i, &rect_yesno, 26);
if (gTS.wait == 16)
PutBitmap3(&grcFull, 41 * gTS.select + (WINDOW_WIDTH + 102) / 2, 154, &rect_cur, 26);
}
}
}
@ -559,6 +613,23 @@ int TextScriptProc()
if (!TransferStage(z, w, x, y))
return 0;
}
else if (IS_COMMAND('M','O','V'))
{
int x = GetTextScriptNo(gTS.p_read + 4);
int y = GetTextScriptNo(gTS.p_read + 9);
SetMyCharPosition(x << 13, y << 13);
gTS.p_read += 13;
}
else if (IS_COMMAND('H','M','C'))
{
ShowMyChar(false);
gTS.p_read += 4;
}
else if (IS_COMMAND('S','M','C'))
{
ShowMyChar(true);
gTS.p_read += 4;
}
else if (IS_COMMAND('F','L','+'))
{
int z = GetTextScriptNo(gTS.p_read + 4);
@ -666,6 +737,26 @@ int TextScriptProc()
gTS.p_read += 4;
gTS.flags |= 0x40;
}
else if (IS_COMMAND('C','L','O'))
{
gTS.flags &= ~0x33;
gTS.p_read += 4;
}
else if (IS_COMMAND('E','V','E'))
{
int z = GetTextScriptNo(gTS.p_read + 4);
JumpTextScript(z);
}
else if (IS_COMMAND('Y','N','J'))
{
gTS.next_event = GetTextScriptNo(gTS.p_read + 4);
gTS.p_read += 8;
gTS.mode = 6;
PlaySoundObject(5, 1);
gTS.wait = 0;
gTS.select = 0;
bExit = true;
}
else if (IS_COMMAND('F','L','J'))
{
int x = GetTextScriptNo(gTS.p_read + 4);
@ -729,6 +820,87 @@ int TextScriptProc()
ReCallMusic();
gTS.p_read += 4;
}
else if (IS_COMMAND('D','N','P'))
{
int z = GetTextScriptNo(gTS.p_read + 4);
DeleteNpCharEvent(z);
gTS.p_read += 8;
}
else if (IS_COMMAND('D','N','A'))
{
int z = GetTextScriptNo(gTS.p_read + 4);
DeleteNpCharCode(z, 1);
gTS.p_read += 8;
}
else if (IS_COMMAND('C','N','P'))
{
int x = GetTextScriptNo(gTS.p_read + 4);
int y = GetTextScriptNo(gTS.p_read + 9);
int z = GetTextScriptNo(gTS.p_read + 14);
ChangeNpCharByEvent(x, y, z);
gTS.p_read += 18;
}
else if (IS_COMMAND('A','N','P'))
{
int x = GetTextScriptNo(gTS.p_read + 4);
int y = GetTextScriptNo(gTS.p_read + 9);
int z = GetTextScriptNo(gTS.p_read + 14);
SetNpCharActionNo(x, y, z);
gTS.p_read += 18;
}
else if (IS_COMMAND('I','N','P'))
{
int x = GetTextScriptNo(gTS.p_read + 4);
int y = GetTextScriptNo(gTS.p_read + 9);
int z = GetTextScriptNo(gTS.p_read + 14);
ChangeCheckableNpCharByEvent(x, y, z);
gTS.p_read += 18;
}
else if (IS_COMMAND('S','N','P'))
{
int w = GetTextScriptNo(gTS.p_read + 4);
int x = GetTextScriptNo(gTS.p_read + 9);
int y = GetTextScriptNo(gTS.p_read + 14);
int z = GetTextScriptNo(gTS.p_read + 19);
SetNpChar(w, x << 13, y << 13, 0, 0, z, 0, 0x100);
gTS.p_read += 23;
}
else if (IS_COMMAND('M','N','P'))
{
int w = GetTextScriptNo(gTS.p_read + 4);
int x = GetTextScriptNo(gTS.p_read + 9);
int y = GetTextScriptNo(gTS.p_read + 14);
int z = GetTextScriptNo(gTS.p_read + 19);
MoveNpChar(w, x << 13, y << 13, z);
gTS.p_read += 23;
}
else if (IS_COMMAND('F','A','C'))
{
int z = GetTextScriptNo(gTS.p_read + 4);
if (gTS.face != z)
{
gTS.face = z;
gTS.face_x = (gTS.rcText.left - 48) << 9;
}
gTS.p_read += 8;
}
else if (IS_COMMAND('F','A','C'))
{
int z = GetTextScriptNo(gTS.p_read + 4);
if (gTS.face != z)
{
gTS.face = z;
gTS.face_x = (gTS.rcText.left - 48) << 9;
}
gTS.p_read += 8;
}
else if (IS_COMMAND('G','I','T'))
{
int z = GetTextScriptNo(gTS.p_read + 4);
gTS.item = z;
gTS.item_y = WINDOW_HEIGHT - 112;
gTS.p_read += 8;
}
else
{
printf("Unimplemented command: <%c%c%c\n", (char)gTS.data[gTS.p_read + 1], (char)gTS.data[gTS.p_read + 2], (char)gTS.data[gTS.p_read + 3]);