Jump to content

Recommended Posts

Here's a funny little perl script I made that tries to find the offset in the OS ROM of all values between 0-FFFF, generating the required equates.

It expects that a binary file with the TI-99/4A OS ROM (not GROM!) is available in the current directory.

 

NOTE: Due to lincense issues, I can't share the TI-99/4A ROM image. However if you are using MESS for emulating the TI-99/4A you already have it.

 

Click on the spoiler button for viewing the source code.

 

 


#!/usr/bin/perl

use strict;
use warnings;

our $tirom; # RAW ROM image
our (%hstore, %dstore);


ReadROMfile();
FillHash();

foreach my $key (sort keys %hstore) {
my $human = $key;
$human =~ s/^0+//;
$human = '0' if ($human eq '');
printf("H%-5s EQU \>%s ; --%d--\n",$human,$hstore{$key},hex($key));
}


foreach my $key (sort keys %dstore) {
my $human = $key;
$human =~ s/^0+//;
$human = '0' if ($human eq '');
printf("D%-5s EQU \>%s ; --%s--\n",$human,$dstore{$key},$human);
}



exit;


sub FillHash {
for (my $addr=0; $addr < length($tirom); $addr+=2) {
my $word = GetWord($addr,1);
my $hkey = sprintf("%04X",$word);
my $dkey = sprintf("%05d",$word);
my $memloc = sprintf("%04X",$addr);
$hstore{"$hkey"} = $memloc unless exists $hstore{"$hkey"};
$dstore{"$dkey"} = $memloc unless exists $dstore{"$dkey"};
}
}

sub ReadROMfile {
my $rom = "994arom.bin";
open (TIROM, "<", $rom) || die("Couldn't open $rom for reading.");
binmode(TIROM) && read(TIROM,$tirom,8000);
close(TIROM) || die("Couldn't close $rom.");
return;
}


###################################################################
# Get Word
#------------------------------------------------------------------
# P3 = Offset of word to display
# P4 = Swap bytes if 1
###################################################################
sub GetWord {
my $P3 = shift; ## P3
my $P4 = shift || 0; ## P4
my $mask = "x" . $P3 . (($P4 == 1) ? "nn" : "vv");
return unpack($mask, $tirom);
}

 

EDIT: Somehow the formatting gets screwed when copying it into atariage, stange. Oh well, you get the idea.

 

I tried it using activestate perl on windows, but suppose it should run the same with plain vanilla perl on linux.

 

So what is this good for? It can save you a few data statements in your assembly language program, if the value you want to access is already present in the OS ROM.

Also due to the fact that the OS ROM is 16bit, there is no speed penalty. The main reason for me implementing this is to make the spectra2 library a bit smaller by removing unnecessary data statements, squeezing the most out of the 8K cartridge ROM space.

 

The below equates files were produced by the script. The first one is the hex version and the second one is the decimal version. In the value range 0-FFFF, 1632 mathing values were found. Not bad considering this is only a 8K ROM.

 

tiromequh.asm

tiromequd.asm

 

Note that the Asm994a assembler chokes with a "Out of symbol table space" when both files are included, but works fine if only using one of both.

 

As far as I know all TI-99/4A revisions used the same OS ROM, this was already discussed here on Atariage about a year ago.

Edited by retroclouds
  • Like 1
Link to comment
https://forums.atariage.com/topic/200559-values-in-ti-994a-rom/
Share on other sites

Why not use the AMS card space so you do not run out of space?

 

Good question ;-)

 

The idea is to let the program (in my case the Tutankham game) run on a bare TI-99/4A console. So no 32K expansion memory or AMS card space.

I am using bank-switching for the game. But to keep it simple I'm trying to keep as much of the spectra2 library available at all times.

Edited by retroclouds

I think it's a cool idea. It might be nice if the game does test one or two locations at startup so it can complain if the ROM doesn't actually match. I don't remember on the 99/4 (not that it's a big deal, I think they are collector-only these days) and I don't know on the Geneve, but I am quite sure you are right that all 99/4As are the same. At any rate, complaining is nicer than crashing on the remote chance there's a different ROM installed. :)

  • Like 1

Very nice. Beside the Word values, I guess the Byte values would count too. Page 1 and 2 alone of the TI Invaders source might suggest saving as much as 90 bytes.

 

I’ve used the 8K ROM heavily as an injection with my random number routine(s) - back in the eighties and recreated later. Establishing that the ROM must be identical with 99% of the TI-99/4A’s is nice. I guess I could rely on seeding and getting predicted values (big saver for level creation and progress control - like level 1 seed >0009, level 2 seed >0003 etc. - programming method is like “play and categorize”).

I think it's a cool idea. It might be nice if the game does test one or two locations at startup so it can complain if the ROM doesn't actually match. I don't remember on the 99/4 (not that it's a big deal, I think they are collector-only these days) and I don't know on the Geneve, but I am quite sure you are right that all 99/4As are the same. At any rate, complaining is nicer than crashing on the remote chance there's a different ROM installed. :)

 

When GPL is started on the Geneve it makes a few small patches to the Rom area, so you would have to check for those patched areas. The GPL source files clearly show where those patches are made.

Edited by Gazoo

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...