Skip to content

Commit

Permalink
Fix bugs in bios without logo to make version 1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
vircon32 committed Jul 24, 2024
1 parent 30f34c1 commit 60bc42f
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 74 deletions.
85 changes: 80 additions & 5 deletions Bios/BiosWithoutLogo/BiosWithoutLogo.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include "video.h"
#include "time.h"
#include "string.h"
#include "misc.h"

// include project libraries
#include "ErrorInfo.h"
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 ] );
Expand Down Expand Up @@ -210,7 +285,7 @@ void main( void )
if( !cartridge_connected() )
{
request_cartridge();
exit();
asm{ "hlt" }
}

// ensure that any video parameters we might have used
Expand Down
2 changes: 1 addition & 1 deletion Bios/BiosWithoutLogo/BiosWithoutLogo.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<rom-definition version="1.0">
<rom type="bios" title="Vircon32 BIOS without logo" version="1.0" />
<rom type="bios" title="Vircon32 BIOS without logo" version="1.1" />
<binary path="obj/BiosWithoutLogo.vbin" />
<textures>
<texture path="obj/BiosNoLogoTexture.vtex" />
Expand Down
68 changes: 1 addition & 67 deletions Bios/BiosWithoutLogo/ErrorInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ enum error_codes


// ---------------------------------------------------------
// MESSAGES FOR EACH ERROR
// MESSAGES STORED FOR EACH ERROR
// ---------------------------------------------------------


Expand All @@ -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."
}
};
6 changes: 5 additions & 1 deletion Bios/BiosWithoutLogo/Readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.

------------------------------------------------------------

Expand All @@ -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
Expand Down

0 comments on commit 60bc42f

Please sign in to comment.