Skip to content

Commit

Permalink
Bytes lost warning reworked by Busy.
Browse files Browse the repository at this point in the history
  • Loading branch information
z00m128 committed Jan 9, 2019
1 parent 023da90 commit 5c2fc5a
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 34 deletions.
43 changes: 33 additions & 10 deletions sjasm/directives.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,12 @@ void dirINCTRD() {
}

void dirSAVESNA() {

if (pass != LASTPASS) {
SkipParam(lp);
return;
}

bool exec = true;

if (!DeviceID) {
Expand Down Expand Up @@ -835,6 +841,12 @@ void dirEMPTYTAP() {
}

void dirSAVETAP() {

if (pass != LASTPASS) {
SkipParam(lp);
return;
}

bool exec = true, realtapeMode = false;
int headerType = -1;
aint val;
Expand Down Expand Up @@ -1059,6 +1071,11 @@ void dirSAVEBIN() {
}

void dirSAVEHOB() {

if (pass != LASTPASS) {
SkipParam(lp);
return;
}
aint val;
char* fnaam, * fnaamh;
int start = -1,length = -1;
Expand Down Expand Up @@ -1136,6 +1153,12 @@ void dirEMPTYTRD() {
}

void dirSAVETRD() {

if (pass != LASTPASS) {
SkipParam(lp);
return;
}

bool exec = true;

if (!DeviceID) {
Expand Down Expand Up @@ -1543,7 +1566,7 @@ void dirIFDEF() {
*/
EReturn res;
if (!(id = GetID(lp))) {
Error("[IFDEF] Illegal identifier", 0, PASS1); return;
Error("[IFDEF] Illegal identifier", 0); return;
}

if (DefineTable.FindDuplicate(id)) {
Expand Down Expand Up @@ -1594,7 +1617,7 @@ void dirIFNDEF() {
*/
EReturn res;
if (!(id = GetID(lp))) {
Error("[IFNDEF] Illegal identifier", 0, PASS1); return;
Error("[IFNDEF] Illegal identifier", 0); return;
}

if (!DefineTable.FindDuplicate(id)) {
Expand Down Expand Up @@ -1796,7 +1819,7 @@ void dirMACRO() {
char* n;
//if (!(n=GetID(lp))) { Error("Illegal macroname",0,PASS1); return; }
if (!(n = GetID(lp))) {
Error("[MACRO] Illegal macroname", 0, PASS1); return;
Error("[MACRO] Illegal macroname", 0); return;
}
MacroTable.Add(n, lp);
}
Expand Down Expand Up @@ -1933,7 +1956,7 @@ void dirSTRUCT() {
}

if (!(naam = GetID(lp)) || !strlen(naam)) {
Error("[STRUCT] Illegal structure name", 0, PASS1); return;
Error("[STRUCT] Illegal structure name", 0); return;
}
if (comma(lp)) {
IsLabelNotFound = 0;
Expand All @@ -1948,7 +1971,7 @@ void dirSTRUCT() {
ListFile();
while ('o') {
if (!ReadLine()) {
Error("[STRUCT] Unexpected end of structure", 0, PASS1); break;
Error("[STRUCT] Unexpected end of structure", 0); break;
}
lp = line; /*if (White()) { SkipBlanks(lp); if (*lp=='.') ++lp; if (cmphstr(lp,"ends")) break; }*/
SkipBlanks(lp);
Expand Down Expand Up @@ -2311,17 +2334,17 @@ void dirINCLUDELUA() {
fnaam = GetFileName(lp);
int error;

if (pass != 1) {
if (pass == LASTPASS && !FileExists(fnaam)) {
Error("[INCLUDELUA] File doesn't exist", fnaam);
return;
}

//WinExec ( "C:\\path\\to\\program.exe", SW_SHOWNORMAL );

if (!FileExists(fnaam)) {
Error("[INCLUDELUA] File doesn't exist", fnaam, PASS1);
if (pass != 1) {
return;
}

//WinExec ( "C:\\path\\to\\program.exe", SW_SHOWNORMAL );

LuaLine = CurrentLocalLine;
error = luaL_loadfile(LUA, fnaam) || lua_pcall(LUA, 0, 0, 0);
if (error) {
Expand Down
4 changes: 2 additions & 2 deletions sjasm/parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -932,11 +932,11 @@ void ParseStructMember(CStructure* st) {
switch (GetStructMemberId(lp)) {
case SMEMBBLOCK:
if (!ParseExpression(lp, len)) {
len = 1; Error("[STRUCT] Expression expected", 0, PASS1);
len = 1; Error("[STRUCT] Expression expected", 0);
}
if (comma(lp)) {
if (!ParseExpression(lp, val)) {
val = 0; Error("[STRUCT] Expression expected", 0, PASS1);
val = 0; Error("[STRUCT] Expression expected", 0);
}
} else {
val = 0;
Expand Down
34 changes: 23 additions & 11 deletions sjasm/reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,32 +257,44 @@ char* getinstr(char*& p) {

/* changes applied from SjASM 0.39g */
int check8(aint val, bool error) {
if (val != (val & 255) && ~val > 127 && error) {
Error("Bytes lost", 0); return 0;
if ((val < -256 || val > 255) && error) {
char buffer[32];
sprintf(buffer, "Bytes lost (0x%X)", val);
Warning(buffer, 0, LASTPASS);
return 0;
}
return 1;
}

/* changes applied from SjASM 0.39g */
int check8o(long val) {
if (val < -128 || val > 127) {
Error("Offset out of range", 0); return 0;
char buffer[32];
sprintf(buffer,"Offset out of range (%+i)", val);
Error(buffer, 0, LASTPASS);
return 0;
}
return 1;
}

/* changes applied from SjASM 0.39g */
int check16(aint val, bool error) {
if (val != (val & 65535) && ~val > 32767 && error) {
Error("Bytes lost", 0); return 0;
if ((val < -65536 || val > 65535) && error) {
char buffer[32];
sprintf(buffer, "Bytes lost (0x%X)", val);
Warning(buffer, 0, LASTPASS);
return 0;
}
return 1;
}

/* changes applied from SjASM 0.39g */
int check24(aint val, bool error) {
if (val != (val & 16777215) && ~val > 8388607 && error) {
Error("Bytes lost", 0); return 0;
if ((val < -16777216 || val > 16777215) && error) {
char buffer[32];
sprintf(buffer, "Bytes lost (0x%X)", val);
Warning(buffer, 0, LASTPASS);
return 0;
}
return 1;
}
Expand Down Expand Up @@ -668,10 +680,10 @@ char* GetFileName(char*& p, bool convertslashes) {
if (*p == '"') {
++p;
} else {
Error("No closing '\"'", 0);
Error("No closing '\"'", 0, LASTPASS);
}
} else if (*p && o == 2 && *p != '>') {
Error("No closing '>'", 0);
Error("No closing '>'", 0, LASTPASS);
} else if (*p) {
++p;
}
Expand Down Expand Up @@ -718,10 +730,10 @@ char* GetHobetaFileName(char*& p) {
if (*p == '"') {
++p;
} else {
Error("No closing '\"'", 0);
Error("No closing '\"'", 0, LASTPASS);
}
} else if (*p && o == 2 && *p != '>') {
Error("No closing '>'", 0);
Error("No closing '>'", 0, LASTPASS);
} else if (*p) {
++p;
}
Expand Down
8 changes: 4 additions & 4 deletions sjasm/sjio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,17 +191,17 @@ void Warning(const char* fout, const char* bd, int type) {
return;
}

++WarningCount;
count = new char[25];
SPRINTF1(count, 25, "%d", WarningCount);
DefineTable.Replace("_WARNINGS", count);

delete[] count;

if (type == LASTPASS && pass != 3) {
return;
}

++WarningCount;

if (pass > LASTPASS) {
SPRINTF1(ep, LINEMAX2, "warning: %s", fout);
} else {
Expand Down Expand Up @@ -238,15 +238,15 @@ void CheckRamLimitExceeded()
if (CurAddress >= 0x10000)
{
char buf[64];
SPRINTF2(buf, 1024, "RAM limit exceeded 0x%X by %s", CurAddress, PseudoORG ? "DISP":"ORG");
SPRINTF2(buf, 1024, "RAM limit exceeded 0x%X by %s", (unsigned int)CurAddress, PseudoORG ? "DISP":"ORG");
Warning(buf, 0, LASTPASS);
CurAddress &= 0xFFFF;
}

if (PseudoORG) if (adrdisp >= 0x10000)
{
char buf[64];
SPRINTF1(buf, 1024, "RAM limit exceeded 0x%X by ORG", adrdisp);
SPRINTF1(buf, 1024, "RAM limit exceeded 0x%X by ORG", (unsigned int)adrdisp);
Warning(buf, 0, LASTPASS);
adrdisp &= 0xFFFF;
}
Expand Down
4 changes: 2 additions & 2 deletions sjasm/sjio.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ extern FILE* FP_UnrealList, * FP_Input;
void OpenDest(int);
void NewDest(char* newfilename, int mode);
int FileExists(char* filename);
void Error(const char*, const char*, int = PASS2);
void Warning(const char*, const char*, int = PASS2);
void Error(const char*, const char*, int = LASTPASS);
void Warning(const char*, const char*, int = LASTPASS);
void ListFile();
void ListFileSkip(char*);
void CheckPage();
Expand Down
10 changes: 5 additions & 5 deletions sjasm/z80.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -950,7 +950,7 @@ namespace Z80 {
b = (signed) callad;
e[1] = callad & 255; e[2] = (callad >> 8) & 255;
if (b > 65535) {
Error("[CALL] Bytes lost", 0);
Warning("[CALL] Bytes lost", 0, LASTPASS);
}
EmitBytes(e);
/* (begin add) */
Expand Down Expand Up @@ -1173,8 +1173,8 @@ namespace Z80 {
jmp = nad - CurAddress - 2;
if (jmp < -128 || jmp > 127) {
char el[LINEMAX];
SPRINTF1(el, LINEMAX, "[DJNZ] Target out of range (%i)", jmp);
Error(el, 0); jmp = 0;
SPRINTF1(el, LINEMAX, "[DJNZ] Target out of range (%+i)", jmp);
Error(el, 0, LASTPASS); jmp = 0;
}
e[0] = 0x10; e[1] = jmp < 0 ? 256 + jmp : jmp;
EmitBytes(e);
Expand Down Expand Up @@ -1557,7 +1557,7 @@ namespace Z80 {
b = (signed) jpad;
e[1] = jpad & 255; e[2] = (jpad >> 8) & 255;
if (b > 65535) {
Error("[JP] Bytes lost", 0);
Warning("[JP] Bytes lost", 0, LASTPASS);
}
}
EmitBytes(e);
Expand Down Expand Up @@ -1613,7 +1613,7 @@ namespace Z80 {
/*if (pass == LASTPASS) {
_COUT "AAAAAAA:" _CMDL jmp _CMDL " " _CMDL jrad _CMDL " " _CMDL CurAddress _ENDL;
}*/
SPRINTF1(el, LINEMAX, "[JR] Target out of range (%i)", jmp);
SPRINTF1(el, LINEMAX, "[JR] Target out of range (%+i)", jmp);
Error(el, 0, LASTPASS);
jmp = 0;
}
Expand Down

0 comments on commit 5c2fc5a

Please sign in to comment.