diff --git a/Bios/BiosWithoutLogo/BiosWithoutLogo.c b/Bios/BiosWithoutLogo/BiosWithoutLogo.c index 10e753c..3285097 100644 --- a/Bios/BiosWithoutLogo/BiosWithoutLogo.c +++ b/Bios/BiosWithoutLogo/BiosWithoutLogo.c @@ -3,7 +3,6 @@ #include "video.h" #include "time.h" #include "string.h" -#include "misc.h" // include project libraries #include "ErrorInfo.h" @@ -63,9 +62,18 @@ void draw_message_screen( error_message* message ) void print_hex_value( int x, int y, int* name, int value ) { - // convert the number to hex - int[ 10 ] hex_string; - itoa( value, hex_string, 16 ); + // convert the number to hex, always + // showing the full 8 hex digits + int[ 16+1 ] hex_characters = "0123456789ABCDEF"; + int[ 8+1 ] hex_string; + + for( int Digit = 7; Digit >= 0; Digit-- ) + { + hex_string[ Digit ] = hex_characters[ value & 15 ]; + value >>= 4; + } + + hex_string[ 8 ] = 0; // join all text parts int[ 60 ] text; @@ -144,6 +152,73 @@ void error_handler() // ensure everything gets drawn end_frame(); + // all possible error messages; do NOT store this as + // global variables, since it may collide with globals + // defined in the programs running from the cartridge + error_message[ 12 ] error_messages = + { + { + "ERROR: INVALID MEMORY READ", + "Program attempted to read from a memory address\n" + "that does not exist or is in a write-only device." + }, + { + "ERROR: INVALID MEMORY WRITE", + "Program attempted to write on a memory address\n" + "that does not exist or is in a read-only device." + }, + { + "ERROR: INVALID PORT READ", + "Program attempted to read from a port number\n" + "that does not exist or is set as write-only." + }, + { + "ERROR: INVALID PORT WRITE", + "Program attempted to write on a port number\n" + "that does not exist or is set as read-only." + }, + { + "ERROR: STACK OVERFLOW", + "Program pushed too many values in the stack\n" + "and available RAM memory was exhausted." + }, + { + "ERROR: STACK UNDERFLOW", + "Program popped too many values from the stack\n" + "and all data stored in stack was exhausted." + }, + { + "ERROR: DIVISION BY ZERO", + "Program attempted to perform a division or\n" + "modulus operation where the divisor was zero." + }, + { + "ERROR: ARC COSINE OUT OF RANGE", + "Program attempted to perform an arc cosine\n" + "operation when the argument was not in [-1,+1]." + }, + { + "ERROR: ARC TANGENT NOT DEFINED", + "Program attempted to perform an arc tangent\n" + "operation when both of the arguments were 0." + }, + { + "ERROR: LOGARITHM OUT OF RANGE", + "Program attempted to perform a logarithm\n" + "operation when the argument is not positive." + }, + { + "ERROR: POWER HAS NO REAL SOLUTION", + "Program attempted to perform a power operation\n" + "when base was negative and exponent non integer." + }, + { + "UNKNOWN ERROR", + "Program caused a hardware error with an error\n" + "code that was not recognized by the BIOS." + } + }; + // write the appropriate message for this error code if( error_code >= 0 && error_code < (int)error_unknown ) draw_message_screen( &error_messages[ error_code ] ); @@ -210,7 +285,7 @@ void main( void ) if( !cartridge_connected() ) { request_cartridge(); - exit(); + asm{ "hlt" } } // ensure that any video parameters we might have used diff --git a/Bios/BiosWithoutLogo/BiosWithoutLogo.xml b/Bios/BiosWithoutLogo/BiosWithoutLogo.xml index 83ebf64..fc5a1ec 100644 --- a/Bios/BiosWithoutLogo/BiosWithoutLogo.xml +++ b/Bios/BiosWithoutLogo/BiosWithoutLogo.xml @@ -1,6 +1,6 @@ - + diff --git a/Bios/BiosWithoutLogo/ErrorInfo.h b/Bios/BiosWithoutLogo/ErrorInfo.h index 2c82f43..a487115 100644 --- a/Bios/BiosWithoutLogo/ErrorInfo.h +++ b/Bios/BiosWithoutLogo/ErrorInfo.h @@ -21,7 +21,7 @@ enum error_codes // --------------------------------------------------------- -// MESSAGES FOR EACH ERROR +// MESSAGES STORED FOR EACH ERROR // --------------------------------------------------------- @@ -30,69 +30,3 @@ struct error_message int[ 50 ] title; int[ 150 ] description; }; - -// --------------------------------------------------------- - -error_message[ 12 ] error_messages = -{ - { - "ERROR: INVALID MEMORY READ", - "Program attempted to read from a memory address\n" - "that does not exist or is in a write-only device." - }, - { - "ERROR: INVALID MEMORY WRITE", - "Program attempted to write on a memory address\n" - "that does not exist or is in a read-only device." - }, - { - "ERROR: INVALID PORT READ", - "Program attempted to read from a port number\n" - "that does not exist or is set as write-only." - }, - { - "ERROR: INVALID PORT WRITE", - "Program attempted to write on a port number\n" - "that does not exist or is set as read-only." - }, - { - "ERROR: STACK OVERFLOW", - "Program pushed too many values in the stack\n" - "and available RAM memory was exhausted." - }, - { - "ERROR: STACK UNDERFLOW", - "Program popped too many values from the stack\n" - "and all data stored in stack was exhausted." - }, - { - "ERROR: DIVISION BY ZERO", - "Program attempted to perform a division or\n" - "modulus operation where the divisor was zero." - }, - { - "ERROR: ARC COSINE OUT OF RANGE", - "Program attempted to perform an arc cosine\n" - "operation when the argument was not in [-1,+1]." - }, - { - "ERROR: ARC TANGENT NOT DEFINED", - "Program attempted to perform an arc tangent\n" - "operation when both of the arguments were 0." - }, - { - "ERROR: LOGARITHM OUT OF RANGE", - "Program attempted to perform a logarithm\n" - "operation when the argument is not positive." - }, - { - "ERROR: POWER HAS NO REAL SOLUTION", - "Program attempted to perform a power operation\n" - "when base was negative and exponent non integer." - }, - { - "UNKNOWN ERROR", - "Program caused a hardware error with an error\n" - "code that was not recognized by the BIOS." - } -}; diff --git a/Bios/BiosWithoutLogo/Readme.txt b/Bios/BiosWithoutLogo/Readme.txt index 6f63759..caf11dd 100644 --- a/Bios/BiosWithoutLogo/Readme.txt +++ b/Bios/BiosWithoutLogo/Readme.txt @@ -12,6 +12,10 @@ What is this? to developers, who will often do frequent changes and tests. This BIOS will save them the time of waiting for the logo every single time they do a new test. + + Current version is 1.1. Previous version incorrectly + used global variables and had a but showing hex numbers + in CPU error messages. Both issues have been fixed now. ------------------------------------------------------------ @@ -28,7 +32,7 @@ License This program is free and open source. It is offered under the 3-Clause BSD License, which full text is the following: - Copyright 2023 Carra. + Copyright 2023-2024 Carra. All rights reserved. Redistribution and use in source and binary forms, with or