summaryrefslogtreecommitdiff
path: root/source/zx81.c
diff options
context:
space:
mode:
Diffstat (limited to 'source/zx81.c')
-rw-r--r--source/zx81.c106
1 files changed, 61 insertions, 45 deletions
diff --git a/source/zx81.c b/source/zx81.c
index a8620c3..00d6015 100644
--- a/source/zx81.c
+++ b/source/zx81.c
@@ -226,40 +226,28 @@ static void RomPatch(void)
static Z80Byte FromASCII(char c)
{
- switch(c)
- {
- case '\'':
- case '"':
- return 11;
-
- case '(':
- return 16;
-
- case ')':
- return 17;
+ static const char *charset =
+ /* 0123456789 */
+ " _________"
+ "_\"#$:?()><"
+ "=+-*/:,.01"
+ "23456789ab"
+ "cdefghijkl"
+ "mnopqrstuv"
+ "wxyz";
- case '-':
- return 22;
-
- case '*':
- return 23;
+ int f;
- case ',':
- return 26;
+ c = tolower(c);
- case '.':
- return 27;
+ for(f = 0; charset[f]; f++)
+ {
+ if (charset[f] == c)
+ {
+ return f;
+ }
}
- if (c>='0' && c<='9')
- return (c-'0')+28;
-
- if (c>='a' && c<='z')
- return (c-'a')+38;
-
- if (c>='A' && c<='Z')
- return (c-'A')+38;
-
return 0;
}
@@ -1028,6 +1016,10 @@ void ZX81SuspendDisplay(void)
void ZX81ResumeDisplay(void)
{
ClearText();
+
+ /* Reset last_I to force hi/lo res detection
+ */
+ last_I = 0;
}
@@ -1081,27 +1073,51 @@ void ZX81Reconfigure(void)
void ZX81SaveSnapshot(FILE *fp)
{
- STRPUT(fp, mem);
- STRPUT(fp, matrix);
- STRPUT(fp, waitkey);
- STRPUT(fp, started);
- STRPUT(fp, RAMBOT);
- STRPUT(fp, RAMTOP);
- STRPUT(fp, prev_lk1);
- STRPUT(fp, prev_lk2);
+ int f;
+
+ for(f=0; f<sizeof mem; f++)
+ {
+ PUT_Byte(fp, mem[f]);
+ }
+
+ for(f=0; f<sizeof matrix; f++)
+ {
+ PUT_Byte(fp, matrix[f]);
+ }
+
+ PUT_Long(fp, waitkey);
+ PUT_Long(fp, started);
+
+ PUT_ULong(fp, RAMBOT);
+ PUT_ULong(fp, RAMTOP);
+
+ PUT_ULong(fp, prev_lk1);
+ PUT_ULong(fp, prev_lk2);
}
void ZX81LoadSnapshot(FILE *fp)
{
- STRGET(fp, mem);
- STRGET(fp, matrix);
- STRGET(fp, waitkey);
- STRGET(fp, started);
- STRGET(fp, RAMBOT);
- STRGET(fp, RAMTOP);
- STRGET(fp, prev_lk1);
- STRGET(fp, prev_lk2);
+ int f;
+
+ for(f=0; f<sizeof mem; f++)
+ {
+ mem[f] = GET_Byte(fp);
+ }
+
+ for(f=0; f<sizeof matrix; f++)
+ {
+ matrix[f] = GET_Byte(fp);
+ }
+
+ waitkey = GET_Long(fp);
+ started = GET_Long(fp);
+
+ RAMBOT = GET_ULong(fp);
+ RAMTOP = GET_ULong(fp);
+
+ prev_lk1 = GET_ULong(fp);
+ prev_lk2 = GET_ULong(fp);
/* Reset last_I to force hi/lo res detection
*/