mirror of
https://github.com/QB64-Phoenix-Edition/QB64pe.git
synced 2024-07-04 04:50:22 +00:00
Add QB64 error constants
This commit is contained in:
parent
c2bdb61c4a
commit
ced74fb82e
|
@ -96,6 +96,102 @@
|
|||
# define QB_FALSE 0
|
||||
# define QB_TRUE -1
|
||||
|
||||
# define QB_ERROR_NEXT_WITHOUT_FOR 1
|
||||
# define QB_ERROR_SYNTAX_ERROR 2
|
||||
# define QB_ERROR_RETURN_WITHOUT_GOSUB 3
|
||||
# define QB_ERROR_OUT_OF_DATA 4
|
||||
# define QB_ERROR_ILLEGAL_FUNCTION_CALL 5
|
||||
# define QB_ERROR_OVERFLOW 6
|
||||
# define QB_ERROR_OUT_OF_MEMORY 7
|
||||
# define QB_ERROR_LABEL_NOT_DEFINED 8
|
||||
# define QB_ERROR_SUBSCRIPT_OUT_OF_RANGE 9
|
||||
# define QB_ERROR_DUPLICATE_DEFINITION 10
|
||||
# define QB_ERROR_DIVISION_BY_ZERO 11
|
||||
# define QB_ERROR_ILLEGAL_IN_DIRECT_MODE 12
|
||||
# define QB_ERROR_TYPE_MISMATCH 13
|
||||
# define QB_ERROR_OUT_OF_STRING_SPACE 14
|
||||
# define QB_ERROR_STRING_FORMULA_TOO_COMPLEX 16
|
||||
# define QB_ERROR_CANNOT_CONTINUE 17
|
||||
# define QB_ERROR_FUNCTION_NOT_DEFINED 18
|
||||
# define QB_ERROR_NO_RESUME 19
|
||||
# define QB_ERROR_RESUME_WITHOUT_ERROR 20
|
||||
# define QB_ERROR_DEVICE_TIMEOUT 24
|
||||
# define QB_ERROR_DEVICE_FAULT 25
|
||||
# define QB_ERROR_FOR_WITHOUT_NEXT 26
|
||||
# define QB_ERROR_OUT_OF_PAPER 27
|
||||
# define QB_ERROR_WHILE_WITHOUT_WEND 29
|
||||
# define QB_ERROR_WEND_WITHOUT_WHILE 30
|
||||
# define QB_ERROR_DUPLICATE_LABEL 33
|
||||
# define QB_ERROR_SUBPROGRAM_NOT_DEFINED 35
|
||||
# define QB_ERROR_ARGUMENT_COUNT_MISMATCH 37
|
||||
# define QB_ERROR_ARRAY_NOT_DEFINED 38
|
||||
# define QB_ERROR_VARIABLE_REQUIRED 40
|
||||
# define QB_ERROR_FIELD_OVERFLOW 50
|
||||
# define QB_ERROR_INTERNAL_ERROR 51
|
||||
# define QB_ERROR_BAD_FILE_NAME_OR_NUMBER 52
|
||||
# define QB_ERROR_FILE_NOT_FOUND 53
|
||||
# define QB_ERROR_BAD_FILE_MODE 54
|
||||
# define QB_ERROR_FILE_ALREADY_OPEN 55
|
||||
# define QB_ERROR_FIELD_STATEMENT_ACTIVE 56
|
||||
# define QB_ERROR_DEVICE_IO_ERROR 57
|
||||
# define QB_ERROR_FILE_ALREADY_EXISTS 58
|
||||
# define QB_ERROR_BAD_RECORD_LENGTH 59
|
||||
# define QB_ERROR_DISK_FULL 61
|
||||
# define QB_ERROR_INPUT_PAST_END_OF_FILE 62
|
||||
# define QB_ERROR_BAD_RECORD_NUMBER 63
|
||||
# define QB_ERROR_BAD_FILE_NAME 64
|
||||
# define QB_ERROR_TOO_MANY_FILES 67
|
||||
# define QB_ERROR_DEVICE_UNAVAILABLE 68
|
||||
# define QB_ERROR_COMMUNICATION_BUFFER_OVERFLOW 69
|
||||
# define QB_ERROR_PERMISSION_DENIED 70
|
||||
# define QB_ERROR_DISK_NOT_READY 71
|
||||
# define QB_ERROR_DISK_MEDIA_ERROR 72
|
||||
# define QB_ERROR_FEATURE_UNAVAILABLE 73
|
||||
# define QB_ERROR_RENAME_ACROSS_DISKS 74
|
||||
# define QB_ERROR_PATH_FILE_ACCESS_ERROR 75
|
||||
# define QB_ERROR_PATH_NOT_FOUND 76
|
||||
# define QB_ERROR_OUT_OF_STACK_SPACE 256
|
||||
# define QB_ERROR_OUT_OF_MEMORY_FATAL 257
|
||||
# define QB_ERROR_INVALID_HANDLE 258
|
||||
# define QB_ERROR_CANNOT_FIND_DYNAMIC_LIBRARY_FILE 259
|
||||
# define QB_ERROR_FUNCTION_NOT_FOUND_IN_DYNAMIC_LIBRARY 260
|
||||
# define QB_ERROR_FUNCTION_NOT_FOUND_IN_DYNAMIC_LIBRARY_261 261
|
||||
# define QB_ERROR_GL_COMMAND_OUTSIDE_SUB_GL_SCOPE 270
|
||||
# define QB_ERROR_END_SYSTEM_IN_SUB_GL_SCOPE 271
|
||||
# define QB_ERROR_MEMORY_REGION_OUT_OF_RANGE 300
|
||||
# define QB_ERROR_INVALID_SIZE 301
|
||||
# define QB_ERROR_SOURCE_MEMORY_REGION_OUT_OF_RANGE 302
|
||||
# define QB_ERROR_DESTINATION_MEMORY_REGION_OUT_OF_RANGE 303
|
||||
# define QB_ERROR_BOTH_MEMORY_REGIONS_OUT_OF_RANGE 304
|
||||
# define QB_ERROR_SOURCE_MEMORY_FREED 305
|
||||
# define QB_ERROR_DESTINATION_MEMORY_FREED 306
|
||||
# define QB_ERROR_MEMORY_ALREADY_FREED 307
|
||||
# define QB_ERROR_MEMORY_HAS_BEEN_FREED 308
|
||||
# define QB_ERROR_MEMORY_NOT_INITIALIZED 309
|
||||
# define QB_ERROR_SOURCE_MEMORY_NOT_INITIALIZED 310
|
||||
# define QB_ERROR_DESTINATION_MEMORY_NOT_INITIALIZED 311
|
||||
# define QB_ERROR_BOTH_MEMORY_NOT_INITIALIZED 312
|
||||
# define QB_ERROR_BOTH_MEMORY_FREED 313
|
||||
# define QB_ERROR_ASSERT_FAILED 314
|
||||
# define QB_ERROR_ASSERT_FAILED_WITH_DESCRIPTION 315
|
||||
# define QB_ERROR_OUT_OF_MEMORY_FATAL_502 502
|
||||
# define QB_ERROR_OUT_OF_MEMORY_FATAL_503 503
|
||||
# define QB_ERROR_OUT_OF_MEMORY_FATAL_504 504
|
||||
# define QB_ERROR_OUT_OF_MEMORY_FATAL_505 505
|
||||
# define QB_ERROR_OUT_OF_MEMORY_FATAL_506 506
|
||||
# define QB_ERROR_OUT_OF_MEMORY_FATAL_507 507
|
||||
# define QB_ERROR_OUT_OF_MEMORY_FATAL_508 508
|
||||
# define QB_ERROR_OUT_OF_MEMORY_FATAL_509 509
|
||||
# define QB_ERROR_OUT_OF_MEMORY_FATAL_510 510
|
||||
# define QB_ERROR_OUT_OF_MEMORY_FATAL_511 511
|
||||
# define QB_ERROR_OUT_OF_MEMORY_FATAL_512 512
|
||||
# define QB_ERROR_OUT_OF_MEMORY_FATAL_513 513
|
||||
# define QB_ERROR_OUT_OF_MEMORY_FATAL_514 514
|
||||
# define QB_ERROR_OUT_OF_MEMORY_FATAL_515 515
|
||||
# define QB_ERROR_OUT_OF_MEMORY_FATAL_516 516
|
||||
# define QB_ERROR_OUT_OF_MEMORY_FATAL_517 517
|
||||
# define QB_ERROR_OUT_OF_MEMORY_FATAL_518 518
|
||||
|
||||
// QB64 string descriptor structure
|
||||
struct qbs_field {
|
||||
int32 fileno;
|
||||
|
|
|
@ -58,7 +58,7 @@ qbs *func__cwd() {
|
|||
}
|
||||
|
||||
final = qbs_new(0, 1);
|
||||
error(7);
|
||||
error(QB_ERROR_INTERNAL_ERROR);
|
||||
|
||||
return final;
|
||||
}
|
||||
|
@ -425,7 +425,7 @@ qbs *func__dir(qbs *qbsContext) {
|
|||
}
|
||||
|
||||
auto size = path.size();
|
||||
qbs *final = qbs_new(size, 1);
|
||||
auto final = qbs_new(size, 1);
|
||||
memcpy(final->chr, &path[0], size);
|
||||
|
||||
return final;
|
||||
|
@ -473,7 +473,7 @@ int32_t func__fileexists(qbs *path) {
|
|||
/// @brief Return the startup directory
|
||||
/// @return A qbs containing the directory path
|
||||
qbs *func__startdir() {
|
||||
qbs *temp = qbs_new(0, 1);
|
||||
auto temp = qbs_new(0, 1);
|
||||
|
||||
qbs_set(temp, g_startDir);
|
||||
|
||||
|
@ -489,7 +489,7 @@ void sub_chdir(qbs *str) {
|
|||
std::string pathName(reinterpret_cast<char *>(str->chr), str->len);
|
||||
|
||||
if (chdir(filepath_fix_directory(pathName)) == -1)
|
||||
error(76); // assume errno == ENOENT; path not found
|
||||
error(QB_ERROR_PATH_NOT_FOUND); // assume errno == ENOENT; path not found
|
||||
}
|
||||
|
||||
/// @brief Checks if s is an empty string (either NULL or zero length)
|
||||
|
@ -647,7 +647,7 @@ qbs *func__files(qbs *qbsFileSpec, int32_t passed) {
|
|||
if (FS_IsStringEmpty(entry)) {
|
||||
// This is per MS BASIC PDS 7.1 and VBDOS 1.0 behavior
|
||||
final = qbs_new(0, 1);
|
||||
error(53);
|
||||
error(QB_ERROR_FILE_NOT_FOUND);
|
||||
return final;
|
||||
}
|
||||
} else {
|
||||
|
@ -726,7 +726,7 @@ qbs *func__FQN(qbs *qbsPathName) {
|
|||
qbs *temp;
|
||||
|
||||
if (!qbsPathName->len) {
|
||||
error(5);
|
||||
error(QB_ERROR_ILLEGAL_FUNCTION_CALL);
|
||||
temp = qbs_new(0, 1);
|
||||
return temp;
|
||||
}
|
||||
|
@ -736,7 +736,7 @@ qbs *func__FQN(qbs *qbsPathName) {
|
|||
|
||||
if (!FS_DirectoryExists(pathName.c_str()) && !FS_FileExists(pathName.c_str())) {
|
||||
// Path not found
|
||||
error(76);
|
||||
error(QB_ERROR_PATH_NOT_FOUND);
|
||||
temp = qbs_new(0, 1);
|
||||
return temp;
|
||||
}
|
||||
|
@ -799,7 +799,7 @@ void sub_files(qbs *str, int32_t passed) {
|
|||
|
||||
if (!directory.size()) {
|
||||
// Invalid filespec
|
||||
error(5);
|
||||
error(QB_ERROR_ILLEGAL_FUNCTION_CALL);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -814,7 +814,7 @@ void sub_files(qbs *str, int32_t passed) {
|
|||
|
||||
if (FS_IsStringEmpty(entry)) {
|
||||
// File not found
|
||||
error(53);
|
||||
error(QB_ERROR_FILE_NOT_FOUND);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -883,7 +883,7 @@ void sub_kill(qbs *str) {
|
|||
// Check if we have exhausted the entries without ever finding a file
|
||||
if (FS_IsStringEmpty(entry)) {
|
||||
// This behavior is per QBasic 1.1
|
||||
error(53);
|
||||
error(QB_ERROR_FILE_NOT_FOUND);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -895,16 +895,16 @@ void sub_kill(qbs *str) {
|
|||
auto i = errno;
|
||||
|
||||
if (i == ENOENT) {
|
||||
error(53);
|
||||
error(QB_ERROR_FILE_NOT_FOUND);
|
||||
return;
|
||||
} // file not found
|
||||
|
||||
if (i == EACCES) {
|
||||
error(75);
|
||||
error(QB_ERROR_PATH_FILE_ACCESS_ERROR);
|
||||
return;
|
||||
} // path / file access error
|
||||
|
||||
error(64); // bad file name (assumed)
|
||||
error(QB_ERROR_BAD_FILE_NAME); // bad file name (assumed)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -928,11 +928,11 @@ void sub_mkdir(qbs *str) {
|
|||
#endif
|
||||
{
|
||||
if (errno == EEXIST) {
|
||||
error(75);
|
||||
error(QB_ERROR_PATH_FILE_ACCESS_ERROR);
|
||||
return;
|
||||
} // path / file access error
|
||||
|
||||
error(76); // assume errno == ENOENT; path not found
|
||||
error(QB_ERROR_PATH_NOT_FOUND); // assume errno == ENOENT; path not found
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -949,21 +949,21 @@ void sub_name(qbs *oldname, qbs *newname) {
|
|||
auto i = errno;
|
||||
|
||||
if (i == ENOENT) {
|
||||
error(53);
|
||||
error(QB_ERROR_FILE_NOT_FOUND);
|
||||
return;
|
||||
} // file not found
|
||||
|
||||
if (i == EINVAL) {
|
||||
error(64);
|
||||
error(QB_ERROR_BAD_FILE_NAME);
|
||||
return;
|
||||
} // bad file name
|
||||
|
||||
if (i == EACCES) {
|
||||
error(75);
|
||||
error(QB_ERROR_PATH_FILE_ACCESS_ERROR);
|
||||
return;
|
||||
} // path / file access error
|
||||
|
||||
error(5); // illegal function call (assumed)
|
||||
error(QB_ERROR_ILLEGAL_FUNCTION_CALL); // illegal function call (assumed)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -977,10 +977,10 @@ void sub_rmdir(qbs *str) {
|
|||
|
||||
if (rmdir(filepath_fix_directory(pathName)) == -1) {
|
||||
if (errno == ENOTEMPTY) {
|
||||
error(75);
|
||||
error(QB_ERROR_PATH_FILE_ACCESS_ERROR);
|
||||
return;
|
||||
} // path/file access error; not an empty directory
|
||||
|
||||
error(76); // assume errno == ENOENT; path not found
|
||||
error(QB_ERROR_PATH_NOT_FOUND); // assume errno == ENOENT; path not found
|
||||
}
|
||||
}
|
||||
|
|
|
@ -767,7 +767,7 @@ class PSG {
|
|||
if (processedChar == 'X') { // "X" + VARPTR$()
|
||||
// A minimum of 3 bytes is need to read the address
|
||||
if (currentState.length < 3) {
|
||||
error(5);
|
||||
error(QB_ERROR_ILLEGAL_FUNCTION_CALL);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -789,12 +789,12 @@ class PSG {
|
|||
continue;
|
||||
} else if (currentChar == '=') { // "=" + VARPTR$()
|
||||
if (dots) {
|
||||
error(5);
|
||||
error(QB_ERROR_ILLEGAL_FUNCTION_CALL);
|
||||
return;
|
||||
}
|
||||
|
||||
if (numberEntered) {
|
||||
error(5);
|
||||
error(QB_ERROR_ILLEGAL_FUNCTION_CALL);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -814,7 +814,7 @@ class PSG {
|
|||
*/
|
||||
|
||||
if (currentState.length < 3) {
|
||||
error(5);
|
||||
error(QB_ERROR_ILLEGAL_FUNCTION_CALL);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -866,14 +866,14 @@ class PSG {
|
|||
default:
|
||||
// bit type?
|
||||
if ((currentChar & 64) == 0) {
|
||||
error(5);
|
||||
error(QB_ERROR_ILLEGAL_FUNCTION_CALL);
|
||||
return;
|
||||
}
|
||||
|
||||
auto x2 = currentChar & 63;
|
||||
|
||||
if (x2 > 56) {
|
||||
error(5);
|
||||
error(QB_ERROR_ILLEGAL_FUNCTION_CALL);
|
||||
return;
|
||||
} // valid number of bits?
|
||||
|
||||
|
@ -895,7 +895,7 @@ class PSG {
|
|||
}
|
||||
|
||||
if (d > 2147483647.0 || d < -2147483648.0) {
|
||||
error(5); // out of range value!
|
||||
error(QB_ERROR_ILLEGAL_FUNCTION_CALL); // out of range value!
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -904,7 +904,7 @@ class PSG {
|
|||
continue;
|
||||
} else if (currentChar >= '0' && currentChar <= '9') {
|
||||
if (dots || numberEntered == 2) {
|
||||
error(5);
|
||||
error(QB_ERROR_ILLEGAL_FUNCTION_CALL);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -918,7 +918,7 @@ class PSG {
|
|||
continue;
|
||||
} else if (currentChar == '.') {
|
||||
if (followUp != 7 && followUp != 1 && followUp != 4) {
|
||||
error(5);
|
||||
error(QB_ERROR_ILLEGAL_FUNCTION_CALL);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -930,14 +930,14 @@ class PSG {
|
|||
follow_up:
|
||||
if (followUp == 10) { // Q...
|
||||
if (!numberEntered) {
|
||||
error(5);
|
||||
error(QB_ERROR_ILLEGAL_FUNCTION_CALL);
|
||||
return;
|
||||
}
|
||||
|
||||
numberEntered = 0;
|
||||
|
||||
if (number > 100) { // 0 - 100 ms
|
||||
error(5);
|
||||
error(QB_ERROR_ILLEGAL_FUNCTION_CALL);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -948,14 +948,14 @@ class PSG {
|
|||
break;
|
||||
} else if (followUp == 9) { // @...
|
||||
if (!numberEntered) {
|
||||
error(5);
|
||||
error(QB_ERROR_ILLEGAL_FUNCTION_CALL);
|
||||
return;
|
||||
}
|
||||
|
||||
numberEntered = 0;
|
||||
|
||||
if ((WaveformType)number <= WaveformType::NONE || (WaveformType)number >= WaveformType::COUNT) {
|
||||
error(5);
|
||||
error(QB_ERROR_ILLEGAL_FUNCTION_CALL);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -967,14 +967,14 @@ class PSG {
|
|||
break;
|
||||
} else if (followUp == 8) { // V...
|
||||
if (!numberEntered) {
|
||||
error(5);
|
||||
error(QB_ERROR_ILLEGAL_FUNCTION_CALL);
|
||||
return;
|
||||
}
|
||||
|
||||
numberEntered = 0;
|
||||
|
||||
if (number > MAX_MML_VOLUME) {
|
||||
error(5);
|
||||
error(QB_ERROR_ILLEGAL_FUNCTION_CALL);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -988,7 +988,7 @@ class PSG {
|
|||
if (numberEntered) {
|
||||
numberEntered = 0;
|
||||
if (number < 1 || number > 64) {
|
||||
error(5);
|
||||
error(QB_ERROR_ILLEGAL_FUNCTION_CALL);
|
||||
return;
|
||||
}
|
||||
duration = 1.0 / (tempo / 60.0) * (4.0 / ((double)number));
|
||||
|
@ -1025,7 +1025,7 @@ class PSG {
|
|||
break;
|
||||
} else if (followUp == 6) { // T...
|
||||
if (!numberEntered) {
|
||||
error(5);
|
||||
error(QB_ERROR_ILLEGAL_FUNCTION_CALL);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1043,7 +1043,7 @@ class PSG {
|
|||
break;
|
||||
} else if (followUp == 5) { // M...
|
||||
if (numberEntered) {
|
||||
error(5);
|
||||
error(QB_ERROR_ILLEGAL_FUNCTION_CALL);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1071,7 +1071,7 @@ class PSG {
|
|||
background = false;
|
||||
break;
|
||||
default:
|
||||
error(5);
|
||||
error(QB_ERROR_ILLEGAL_FUNCTION_CALL);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1080,14 +1080,14 @@ class PSG {
|
|||
continue;
|
||||
} else if (followUp == 4) { // N...
|
||||
if (!numberEntered) {
|
||||
error(5);
|
||||
error(QB_ERROR_ILLEGAL_FUNCTION_CALL);
|
||||
return;
|
||||
}
|
||||
|
||||
numberEntered = 0;
|
||||
|
||||
if (number > 84) {
|
||||
error(5);
|
||||
error(QB_ERROR_ILLEGAL_FUNCTION_CALL);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1096,14 +1096,14 @@ class PSG {
|
|||
goto follow_up_1;
|
||||
} else if (followUp == 3) { // O...
|
||||
if (!numberEntered) {
|
||||
error(5);
|
||||
error(QB_ERROR_ILLEGAL_FUNCTION_CALL);
|
||||
return;
|
||||
}
|
||||
|
||||
numberEntered = 0;
|
||||
|
||||
if (number > MAX_OCTAVE) {
|
||||
error(5);
|
||||
error(QB_ERROR_ILLEGAL_FUNCTION_CALL);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1115,14 +1115,14 @@ class PSG {
|
|||
break;
|
||||
} else if (followUp == 2) { // L...
|
||||
if (!numberEntered) {
|
||||
error(5);
|
||||
error(QB_ERROR_ILLEGAL_FUNCTION_CALL);
|
||||
return;
|
||||
}
|
||||
|
||||
numberEntered = 0;
|
||||
|
||||
if (number < MIN_LENGTH || number > MAX_LENGTH) {
|
||||
error(5);
|
||||
error(QB_ERROR_ILLEGAL_FUNCTION_CALL);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1135,7 +1135,7 @@ class PSG {
|
|||
} else if (followUp == 1) { // A-G...
|
||||
if (currentChar == '-') {
|
||||
if (noteShifted || numberEntered) {
|
||||
error(5);
|
||||
error(QB_ERROR_ILLEGAL_FUNCTION_CALL);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1146,7 +1146,7 @@ class PSG {
|
|||
}
|
||||
if (currentChar == '+' || currentChar == '#') {
|
||||
if (noteShifted || numberEntered) {
|
||||
error(5);
|
||||
error(QB_ERROR_ILLEGAL_FUNCTION_CALL);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1161,7 +1161,7 @@ class PSG {
|
|||
numberEntered = 0;
|
||||
|
||||
if (number < 0 || number > 64) {
|
||||
error(5);
|
||||
error(QB_ERROR_ILLEGAL_FUNCTION_CALL);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1274,12 +1274,12 @@ class PSG {
|
|||
continue;
|
||||
}
|
||||
|
||||
error(5);
|
||||
error(QB_ERROR_ILLEGAL_FUNCTION_CALL);
|
||||
return;
|
||||
}
|
||||
|
||||
if (numberEntered || followUp) {
|
||||
error(5); // unhandled data
|
||||
error(QB_ERROR_ILLEGAL_FUNCTION_CALL); // unhandled data
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1586,13 +1586,13 @@ void sub_sound(double frequency, double lengthInClockTicks, double volume, doubl
|
|||
return;
|
||||
|
||||
if ((frequency < 37.0 && frequency != 0) || frequency > 32767.0 || lengthInClockTicks < 0.0 || lengthInClockTicks > 65535.0) {
|
||||
error(5);
|
||||
error(QB_ERROR_ILLEGAL_FUNCTION_CALL);
|
||||
return;
|
||||
}
|
||||
|
||||
if (passed & 1) {
|
||||
if (volume < PSG::MIN_VOLUME || volume > PSG::MAX_VOLUME) {
|
||||
error(5);
|
||||
error(QB_ERROR_ILLEGAL_FUNCTION_CALL);
|
||||
return;
|
||||
}
|
||||
audioEngine.psg->SetAmplitude(volume);
|
||||
|
@ -1600,7 +1600,7 @@ void sub_sound(double frequency, double lengthInClockTicks, double volume, doubl
|
|||
|
||||
if (passed & 2) {
|
||||
if (panning < PSG::PAN_LEFT || panning > PSG::PAN_RIGHT) {
|
||||
error(5);
|
||||
error(QB_ERROR_ILLEGAL_FUNCTION_CALL);
|
||||
return;
|
||||
}
|
||||
audioEngine.psg->SetPanning((float)panning);
|
||||
|
@ -1608,7 +1608,7 @@ void sub_sound(double frequency, double lengthInClockTicks, double volume, doubl
|
|||
|
||||
if (passed & 4) {
|
||||
if ((PSG::WaveformType)waveform <= PSG::WaveformType::NONE || (PSG::WaveformType)waveform >= PSG::WaveformType::COUNT) {
|
||||
error(5);
|
||||
error(QB_ERROR_ILLEGAL_FUNCTION_CALL);
|
||||
return;
|
||||
}
|
||||
audioEngine.psg->SetWaveformType((PSG::WaveformType)waveform);
|
||||
|
|
|
@ -1018,7 +1018,7 @@ int32_t func__UFontHeight(int32_t qb64_fh, int32_t passed) {
|
|||
if (passed) {
|
||||
// Check if a valid font handle was passed
|
||||
if (!IS_VALID_QB64_FONT_HANDLE(qb64_fh)) {
|
||||
error(258);
|
||||
error(QB_ERROR_INVALID_HANDLE);
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
|
@ -1056,7 +1056,7 @@ int32_t func__UPrintWidth(const qbs *text, int32_t utf_encoding, int32_t qb64_fh
|
|||
// Check UTF argument
|
||||
if (passed & 1) {
|
||||
if (!IS_VALID_UTF_ENCODING(utf_encoding)) {
|
||||
error(5);
|
||||
error(QB_ERROR_ILLEGAL_FUNCTION_CALL);
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
|
@ -1066,7 +1066,7 @@ int32_t func__UPrintWidth(const qbs *text, int32_t utf_encoding, int32_t qb64_fh
|
|||
// Check if a valid font handle was passed
|
||||
if (passed & 2) {
|
||||
if (!IS_VALID_QB64_FONT_HANDLE(qb64_fh)) {
|
||||
error(258);
|
||||
error(QB_ERROR_INVALID_HANDLE);
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
|
@ -1122,7 +1122,7 @@ int32_t func__ULineSpacing(int32_t qb64_fh, int32_t passed) {
|
|||
if (passed) {
|
||||
// Check if a valid font handle was passed
|
||||
if (!IS_VALID_QB64_FONT_HANDLE(qb64_fh)) {
|
||||
error(258);
|
||||
error(QB_ERROR_INVALID_HANDLE);
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
|
@ -1160,7 +1160,7 @@ void sub__UPrintString(int32_t start_x, int32_t start_y, const qbs *text, int32_
|
|||
|
||||
// Check if we are in text mode and generate an error if we are
|
||||
if (write_page->text) {
|
||||
error(5);
|
||||
error(QB_ERROR_ILLEGAL_FUNCTION_CALL);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1177,7 +1177,7 @@ void sub__UPrintString(int32_t start_x, int32_t start_y, const qbs *text, int32_
|
|||
// Check UTF argument
|
||||
if (passed & 2) {
|
||||
if (!IS_VALID_UTF_ENCODING(utf_encoding)) {
|
||||
error(5);
|
||||
error(QB_ERROR_ILLEGAL_FUNCTION_CALL);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
|
@ -1187,7 +1187,7 @@ void sub__UPrintString(int32_t start_x, int32_t start_y, const qbs *text, int32_
|
|||
// Check if a valid font handle was passed
|
||||
if (passed & 4) {
|
||||
if (!IS_VALID_QB64_FONT_HANDLE(qb64_fh)) {
|
||||
error(258);
|
||||
error(QB_ERROR_INVALID_HANDLE);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
|
@ -1488,7 +1488,7 @@ int32_t func__UCharPos(const qbs *text, void *arr, int32_t utf_encoding, int32_t
|
|||
// Check UTF argument
|
||||
if (passed & 2) {
|
||||
if (!IS_VALID_UTF_ENCODING(utf_encoding)) {
|
||||
error(5);
|
||||
error(QB_ERROR_ILLEGAL_FUNCTION_CALL);
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
|
@ -1498,7 +1498,7 @@ int32_t func__UCharPos(const qbs *text, void *arr, int32_t utf_encoding, int32_t
|
|||
// Check if a valid font handle was passed
|
||||
if (passed & 4) {
|
||||
if (!IS_VALID_QB64_FONT_HANDLE(qb64_fh)) {
|
||||
error(258);
|
||||
error(QB_ERROR_INVALID_HANDLE);
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -49,13 +49,6 @@
|
|||
// This is returned to the caller if something goes wrong while loading the image
|
||||
#define INVALID_IMAGE_HANDLE -1
|
||||
|
||||
// TODO: We should have QB64 error code enums in some common place
|
||||
// Maybe consolidate error() & friends, and these enums
|
||||
#define ERROR_ILLEGAL_FUNCTION_CALL 5
|
||||
#define ERROR_INTERNAL_ERROR 51
|
||||
#define ERROR_BAD_FILE_NAME 64
|
||||
#define ERROR_INVALID_HANDLE 258
|
||||
|
||||
#ifdef QB64_WINDOWS
|
||||
# define ZERO_VARIABLE(_v_) ZeroMemory(&(_v_), sizeof(_v_))
|
||||
#else
|
||||
|
@ -573,7 +566,7 @@ int32_t func__loadimage(qbs *qbsFileName, int32_t bpp, qbs *qbsRequirements, int
|
|||
|
||||
if ((bpp != 32) && (bpp != 256)) { // invalid BPP?
|
||||
IMAGE_DEBUG_PRINT("Invalid bpp (0x%X)", bpp);
|
||||
error(5);
|
||||
error(QB_ERROR_ILLEGAL_FUNCTION_CALL);
|
||||
return INVALID_IMAGE_HANDLE;
|
||||
}
|
||||
} else {
|
||||
|
@ -726,7 +719,7 @@ void sub__saveimage(qbs *qbsFileName, int32_t imageHandle, qbs *qbsRequirements,
|
|||
|
||||
if (!qbsFileName->len) { // empty file names not allowed
|
||||
IMAGE_DEBUG_PRINT("Empty file name");
|
||||
error(ERROR_BAD_FILE_NAME);
|
||||
error(QB_ERROR_BAD_FILE_NAME);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -741,11 +734,11 @@ void sub__saveimage(qbs *qbsFileName, int32_t imageHandle, qbs *qbsRequirements,
|
|||
imageHandle = -imageHandle;
|
||||
|
||||
if (imageHandle >= nextimg) {
|
||||
error(ERROR_INVALID_HANDLE);
|
||||
error(QB_ERROR_INVALID_HANDLE);
|
||||
return;
|
||||
}
|
||||
if (!img[imageHandle].valid) {
|
||||
error(ERROR_INVALID_HANDLE);
|
||||
error(QB_ERROR_INVALID_HANDLE);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -757,11 +750,11 @@ void sub__saveimage(qbs *qbsFileName, int32_t imageHandle, qbs *qbsRequirements,
|
|||
|
||||
// Safety
|
||||
if (imageHandle >= nextimg) {
|
||||
error(ERROR_INVALID_HANDLE);
|
||||
error(QB_ERROR_INVALID_HANDLE);
|
||||
return;
|
||||
}
|
||||
if (!img[imageHandle].valid) {
|
||||
error(ERROR_INVALID_HANDLE);
|
||||
error(QB_ERROR_INVALID_HANDLE);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -914,7 +907,7 @@ void sub__saveimage(qbs *qbsFileName, int32_t imageHandle, qbs *qbsRequirements,
|
|||
stbi_write_png_compression_level = 100;
|
||||
if (!stbi_write_png(fileName.c_str(), width, height, sizeof(uint32_t), pixels.data(), 0)) {
|
||||
IMAGE_DEBUG_PRINT("stbi_write_png() failed");
|
||||
error(ERROR_ILLEGAL_FUNCTION_CALL);
|
||||
error(QB_ERROR_ILLEGAL_FUNCTION_CALL);
|
||||
}
|
||||
} break;
|
||||
|
||||
|
@ -927,28 +920,28 @@ void sub__saveimage(qbs *qbsFileName, int32_t imageHandle, qbs *qbsRequirements,
|
|||
|
||||
if (!qoi_write(fileName.c_str(), pixels.data(), &desc)) {
|
||||
IMAGE_DEBUG_PRINT("qoi_write() failed");
|
||||
error(ERROR_ILLEGAL_FUNCTION_CALL);
|
||||
error(QB_ERROR_ILLEGAL_FUNCTION_CALL);
|
||||
}
|
||||
} break;
|
||||
|
||||
case SaveFormat::BMP: {
|
||||
if (!stbi_write_bmp(fileName.c_str(), width, height, sizeof(uint32_t), pixels.data())) {
|
||||
IMAGE_DEBUG_PRINT("stbi_write_bmp() failed");
|
||||
error(ERROR_ILLEGAL_FUNCTION_CALL);
|
||||
error(QB_ERROR_ILLEGAL_FUNCTION_CALL);
|
||||
}
|
||||
} break;
|
||||
|
||||
case SaveFormat::TGA: {
|
||||
if (!stbi_write_tga(fileName.c_str(), width, height, sizeof(uint32_t), pixels.data())) {
|
||||
IMAGE_DEBUG_PRINT("stbi_write_tga() failed");
|
||||
error(ERROR_ILLEGAL_FUNCTION_CALL);
|
||||
error(QB_ERROR_ILLEGAL_FUNCTION_CALL);
|
||||
}
|
||||
} break;
|
||||
|
||||
case SaveFormat::JPG: {
|
||||
if (!stbi_write_jpg(fileName.c_str(), width, height, sizeof(uint32_t), pixels.data(), 100)) {
|
||||
IMAGE_DEBUG_PRINT("stbi_write_jpg() failed");
|
||||
error(ERROR_ILLEGAL_FUNCTION_CALL);
|
||||
error(QB_ERROR_ILLEGAL_FUNCTION_CALL);
|
||||
}
|
||||
} break;
|
||||
|
||||
|
@ -973,12 +966,12 @@ void sub__saveimage(qbs *qbsFileName, int32_t imageHandle, qbs *qbsRequirements,
|
|||
|
||||
if (!stbi_write_hdr(fileName.c_str(), width, height, HDRComponents, HDRPixels.data())) {
|
||||
IMAGE_DEBUG_PRINT("stbi_write_hdr() failed");
|
||||
error(ERROR_ILLEGAL_FUNCTION_CALL);
|
||||
error(QB_ERROR_ILLEGAL_FUNCTION_CALL);
|
||||
}
|
||||
} break;
|
||||
|
||||
default:
|
||||
IMAGE_DEBUG_PRINT("Save handler not implemented");
|
||||
error(ERROR_INTERNAL_ERROR);
|
||||
error(QB_ERROR_INTERNAL_ERROR);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue