It is currently Mon Oct 20, 2014 4:48 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Tue Mar 13, 2012 9:45 am 
Offline
 Profile

Joined: Tue Mar 13, 2012 9:21 am
Posts: 2
Location: Tauranga, New Zealand
I'm - slowly - looking at why Eagle Empire doesn't work in BeebEm. As part of that I'm going back to square one and working out how it works from the ground up (as a learning experience, and getting back into the swing of Acorn things!)

A lot of the below is incidential to the question - just putting it all here in case anyone asks - what's that missing bit do?

So, to begin - part of the loading process loads & runs EAG#1:

EAG#1 0700 070A 00A0

Code:
0700  45 41 47 23 32 0D 0D 59 22 0D AD 0E 02 85 70 AD EAG#2..Y".....p.
0710  0F 02 85 71 A9 85 8D 0E 02 A9 07 8D 0F 02 A9 00 ...q............
0720  85 80 85 82 85 86 A9 07 85 81 A9 30 85 83 A2 80 ...........0....
0730  A0 00 A9 03 8D 58 02 A9 FF 20 DD FF A5 70 8D 0E .....X... ...p..
0740  02 A5 71 8D 0F 02 A9 00 85 72 A9 30 85 73 A9 00 ..q......r.0.s..
0750  85 70 A9 30 85 71 A9 03 8D 58 02 A2 2B A0 00 B1 .p.0.q...X..+...
0760  70 49 0E 91 72 88 D0 F7 E6 71 E6 73 CA D0 EE A9 pI..r....q.s....
0770  03 8D 58 02 A9 00 85 81 85 83 85 85 85 87 A9 04 ..X.............
0780  85 86 4C 21 5A C9 3F D0 02 A9 20 6C 70 00 00 00 ..L!Z.?... lp...
0790  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
Execution starts at 070A

The first thing we do is preserve the existing OSWRCH vectors, and then we set up our own OSWRCH routine, at &0785:
Code:
070A AD 0E 02  LDA 020E   
070D 85 70     STA 70   
070F AD 0F 02  LDA 020F   
0712 85 71     STA 71   
0714 A9 85     LDA #85   
0716 8D 0E 02  STA 020E   
0719 A9 07     LDA #07   
071B 8D 0F 02  STA 020F
We load EAG#2 ... (not relevant to this discussion)
Code:
071E A9 00     LDA #00   
0720 85 80     STA 80   
0722 85 82     STA 82   
0724 85 86     STA 86   
0726 A9 07     LDA #07   
0728 85 81     STA 81   
072A A9 30     LDA #30   
072C 85 83     STA 83   
072E A2 80     LDX #80   
0730 A0 00     LDY #00   
0732 A9 03     LDA #03   
0734 8D 58 02  STA 0258   
0737 A9 FF     LDA #FF   
0739 20 DD FF  JSR FFDD   
We then restore the original OSWRCH vector, so our routine only during the OSFILE operation.
Code:
073C A5 70     LDA 70   
073E 8D 0E 02  STA 020E   
0741 A5 71     LDA 71   
0743 8D 0F 02  STA 020F
The next chunk is decoding the loaded file (not relevant here.)
Code:
0746 A9 00     LDA #00
0748 85 72     STA 72
074A A9 30     LDA #30
074C 85 73     STA 73
074E A9 00     LDA #00
0750 85 70     STA 70
0752 A9 30     LDA #30
0754 85 71     STA 71
0756 A9 03     LDA #03
0758 8D 58 02  STA 0258
075B A2 2B     LDX #2B
075D A0 00     LDY #00
075F B1 70     LDA (70),Y
0761 49 0E     EOR #0E
0763 91 72     STA (72),Y
0765 88        DEY
0766 D0 F7     BNE 075F
0768 E6 71     INC 71
076A E6 73     INC 73
076C CA        DEX
076D D0 EE     BNE 075D
076F A9 03     LDA #03
0771 8D 58 02  STA 0258
0774 A9 00     LDA #00
0776 85 81     STA 81
0778 85 83     STA 83
077A 85 85     STA 85
077C 85 87     STA 87
077E A9 04     LDA #04
0780 85 86     STA 86
... and then we jump to the decoded game ...
Code:
0782 4C 21 5A  JMP 5A21
After the JMP is our new OSWRCH routine
Code:
0785 C9 3F     CMP #3F
0787 D0 02     BNE 078B
0789 A9 20     LDA #20
078B 6C 70 00  JMP (0070)
So - if I read that OSWRCH routine correctly - if the character requested for write is &3f (?) then convert to &20 (space). But WHY would you do that?

I wondered if it was loading from a tape and you got question marks in the status messages, they'd be blanked out ... but again ... why?

Or have I misread what is going on - it's been a long time!

(As I type this - I wonder - maybe the original game had some sort of copy protection that has been removed and now this code makes no sense? Have I answered my own question?)


Top
 
PostPosted: Tue Mar 13, 2012 5:18 pm 
Offline
User avatar
 Profile

Joined: Mon Jan 07, 2008 6:46 pm
Posts: 380
Location: Málaga, Spain
The main code file is actually called "EAG#2"+CHR$(195), i.e. it contains a non-standard character at the end of the name, which the OS displays as a question mark when loading.

My guess is that the OSWRCH code is to turn the question mark into a space, so it looks like the file is simply called "EAG#2" as it loads. Quite what the point in any of this is, I have no idea, as the file can be trivially loaded from tape just using *LOAD without a filename.

Seems like a rather pointless attempt at obfuscation to me.

Edit: to say, I just tried it now, and actually the file won't *LOAD without a filename (it aborts with the rather curious error "Bad address"). So that's entirely the point: just a bit of basic protection to stop the code from being trivially *LOADed.


Last edited by RichTW on Tue Mar 13, 2012 5:38 pm, edited 1 time in total.

Top
 
PostPosted: Tue Mar 13, 2012 5:32 pm 
Offline
User avatar
 Profile

Joined: Mon Jan 07, 2008 6:46 pm
Posts: 380
Location: Málaga, Spain
Just to add, I noticed that in the hex dump you posted above, EAG#1 starts like this:
Code:
0700  45 41 47 23 32 0D 0D 59 22 0D AD 0E 02 85 70 AD EAG#2..Y".....p.

whilst in the tape image on the STH site, it looks like this:
Code:
0700  45 41 47 23 32 C3 0D 59 22 0D AD 0E 02 85 70 AD EAG#2..Y".....p.

In your version, the file has been renamed to remove the CHR$(195), i.e. the C3 byte in the filename, as it's not valid on disc. This doesn't seem to have anything to do with the crashing though, as it still happens on the tape image from STH.


Top
 
PostPosted: Tue Mar 13, 2012 8:58 pm 
Offline
 Profile

Joined: Tue Mar 13, 2012 9:21 am
Posts: 2
Location: Tauranga, New Zealand
Ahhhh, I missed that completely - that makes a lot of sense ... I guess the version I dumped (the disc version from STH ... I think, I did try a few!) had the "illegal" character removed (either in a disc version as sold, or someone moved it to disc and removed that part.)

I know it is not related to the crashing later on - but it's just been BUGGING me as to what the goal might have been.

But what you said makes a lot of sense - someone will try to *LOAD EAG#2 ... and it will get told there's no such file. You'd have to write a special loader to load the file (as they did) - but no need to do that if the special character has been knocked out - which more than likely explains why the file name has two terminating &0Ds - one the original, and one to knock out the &C3.

Thank you!


Top
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron