| www.retrosoftware.co.uk http://www.retrosoftware.co.uk/forum/ |
|
| Eagle Empire - what's the point of this code? http://www.retrosoftware.co.uk/forum/viewtopic.php?f=73&t=750 |
Page 1 of 1 |
| Author: | richardtoohey [ Tue Mar 13, 2012 9:45 am ] |
| Post subject: | Eagle Empire - what's the point of this code? |
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. Execution starts at 070A0710 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 ................ 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 We load EAG#2 ... (not relevant to this discussion)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 Code: 071E A9 00 LDA #00 We then restore the original OSWRCH vector, so our routine only during the OSFILE operation.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 Code: 073C A5 70 LDA 70 The next chunk is decoding the loaded file (not relevant here.)073E 8D 0E 02 STA 020E 0741 A5 71 LDA 71 0743 8D 0F 02 STA 020F Code: 0746 A9 00 LDA #00 ... and then we jump to the decoded game ...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 Code: 0782 4C 21 5A JMP 5A21 After the JMP is our new OSWRCH routineCode: 0785 C9 3F CMP #3F 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?0787 D0 02 BNE 078B 0789 A9 20 LDA #20 078B 6C 70 00 JMP (0070) 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?) |
|
| Author: | RichTW [ Tue Mar 13, 2012 5:18 pm ] |
| Post subject: | Re: Eagle Empire - what's the point of this code? |
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. |
|
| Author: | RichTW [ Tue Mar 13, 2012 5:32 pm ] |
| Post subject: | Re: Eagle Empire - what's the point of this code? |
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. |
|
| Author: | richardtoohey [ Tue Mar 13, 2012 8:58 pm ] |
| Post subject: | Re: Eagle Empire - what's the point of this code? |
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! |
|
| Page 1 of 1 | All times are UTC [ DST ] |
| Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |
|