From 8a569b127f58dbc508a2f69029776bf7a64fa1a8 Mon Sep 17 00:00:00 2001 From: Clownacy Date: Mon, 8 Apr 2019 16:32:44 +0100 Subject: [PATCH] Made MapName.cpp ASM-accurate --- src/MapName.cpp | 96 +++++++++++++++++++++++++++++++++++++++---------- src/MapName.h | 4 ++- 2 files changed, 80 insertions(+), 20 deletions(-) diff --git a/src/MapName.cpp b/src/MapName.cpp index 4d29389a..e48016a3 100644 --- a/src/MapName.cpp +++ b/src/MapName.cpp @@ -5,47 +5,105 @@ #include "CommonDefines.h" #include "Draw.h" +#include "WindowsWrapper.h" MAP_NAME gMapName; RECT rc = { 0, 0, 160, 12 }; void ReadyMapName(const char *str) { + int a; + + //Handle "Studio Pixel presents" text in the intro + unsigned char presentText[24] = { + #ifdef JAPANESE + // "開発室Pixel presents" + 0x8A-1, // 開 + 0x4A-1, + 0x94-1, // 発 + 0xAD-1, + 0x8E-1, // 室 + 0xBA-1, + 'P'-1, + 'i'-1, + 'x'-1, + 'e'-1, + 'l'-1, + ' '-1, + 'p'-1, + 'r'-1, + 'e'-1, + 's'-1, + 'e'-1, + 'n'-1, + 't'-1, + 's'-1, + #else + // " Studio Pixel presents" + ' '-1, + ' '-1, + 'S'-1, + 't'-1, + 'u'-1, + 'd'-1, + 'i'-1, + 'o'-1, + ' '-1, + 'P'-1, + 'i'-1, + 'x'-1, + 'e'-1, + 'l'-1, + ' '-1, + 'p'-1, + 'r'-1, + 'e'-1, + 's'-1, + 'e'-1, + 'n'-1, + 't'-1, + 's'-1, + #endif + 0xFF + }; + //Reset map name flags gMapName.flag = 0; gMapName.wait = 0; - - //Handle "Studio Pixel presents" text in the intro - #ifdef JAPANESE - char presentText[24] = "開発室Pixel presents"; - #else - char presentText[24] = " Studio Pixel presents"; - #endif - + if (!strcmp(str, "u")) { - /*for (i = 0; i < strlen(presentText); i++) //No need for this, we aren't encrypting the text - ++studio_pixel_presents_string[i];*/ - str = presentText; + for (a = 0; a < (int)sizeof(presentText); ++a) + presentText[a] = presentText[a] + 1; + + str = (char*)presentText; } //Copy map's name to the MapName strcpy(gMapName.name, str); //Draw the text to the surface - int len = (int)strlen(gMapName.name); - + a = (int)strlen(gMapName.name); + CortBox2(&rc, 0, SURFACE_ID_ROOM_NAME); - PutText2((-6 * len + 160) / 2 + 6, 1, gMapName.name, RGB(0x11, 0x00, 0x22), SURFACE_ID_ROOM_NAME); - PutText2((-6 * len + 160) / 2 + 6, 0, gMapName.name, RGB(0xFF, 0xFF, 0xFE), SURFACE_ID_ROOM_NAME); + PutText2((160 - 6 * a) / 2 + 6, 1, gMapName.name, RGB(0x11, 0x00, 0x22), SURFACE_ID_ROOM_NAME); + PutText2((160 - 6 * a) / 2 + 6, 0, gMapName.name, RGB(0xFF, 0xFF, 0xFE), SURFACE_ID_ROOM_NAME); } -void PutMapName(bool bMini) +void PutMapName(BOOL bMini) { + // 'unused_rect' isn't the original name. The Linux port optimised this out, so there's no name for it. + RECT unused_rect = {0, 0, 160, 16}; + if (bMini) { //Map system - RECT rcBack = {0, 7, WINDOW_WIDTH, 24}; + RECT rcBack; + rcBack.left = 0; + rcBack.right = WINDOW_WIDTH; + rcBack.top = 7; + rcBack.bottom = 24; + CortBox(&rcBack, 0x000000); PutBitmap3(&grcGame, (WINDOW_WIDTH - 172) / 2, 10, &rc, SURFACE_ID_ROOM_NAME); } @@ -69,6 +127,6 @@ void RestoreMapName() int len = (int)strlen(gMapName.name); CortBox2(&rc, 0, SURFACE_ID_ROOM_NAME); - PutText2((-6 * len + 160) / 2 + 6, 1, gMapName.name, RGB(0x11, 0x00, 0x22), SURFACE_ID_ROOM_NAME); - PutText2((-6 * len + 160) / 2 + 6, 0, gMapName.name, RGB(0xFF, 0xFF, 0xFE), SURFACE_ID_ROOM_NAME); + PutText2((160 - 6 * len) / 2 + 6, 1, gMapName.name, RGB(0x11, 0x00, 0x22), SURFACE_ID_ROOM_NAME); + PutText2((160 - 6 * len) / 2 + 6, 0, gMapName.name, RGB(0xFF, 0xFF, 0xFE), SURFACE_ID_ROOM_NAME); } diff --git a/src/MapName.h b/src/MapName.h index 92933f77..1aa7b710 100644 --- a/src/MapName.h +++ b/src/MapName.h @@ -1,5 +1,7 @@ #pragma once +#include "WindowsWrapper.h" + struct MAP_NAME { int flag; @@ -8,6 +10,6 @@ struct MAP_NAME }; void ReadyMapName(const char *str); -void PutMapName(bool bMini); +void PutMapName(BOOL bMini); void StartMapName(); void RestoreMapName();