; A program that says where it came from. ; ; The dullest thing on the disk, and that is the point of it: osWhereAmI and pathBeside are ; what an application with assets stands on, and both are much easier to check now, with ; nothing depending on them, than later inside a game that has gone quiet. ; ; Where says the path it was loaded from ; Where splash.tune says that, and the path of splash.tune beside it ; ; ---- The thing worth checking ---- ; ; The answer follows the PROGRAM and not the person. Run this from the root and it says one ; thing; walk somewhere else and run the same copy and it says the same thing, because the ; system worked it out when the program started and a program's own place cannot move under ; it. A working directory is where the person is standing, and it is what the argument means: ; "Where notes.txt" asks about a notes.txt in the program's place, not in yours, which is ; exactly the distinction an application needs and the reason cwd could not serve both. #Include services.asm #Program #Base 0x5000 start: SETD.0 MyPath INIB 0d192 SWI osWhereAmI SETD.0 FromText SWI osPrintString SETD.0 MyPath SWI osPrintString CALL newLine ; With nothing after it, that is the whole of what it has to say. SETD.0 Given INIB 0d64 SWI osArgument SETD.0 Given LDA.0 BRA whereDone SETD.0 MyPath SETD.1 Given SETD.2 Beside INIB 0d192 CALL pathBeside BNQ whereTooLong SETD.0 BesideText SWI osPrintString SETD.0 Beside SWI osPrintString CALL newLine whereDone: RSTA SWI osExit whereTooLong: ; A path that did not fit is a wrong answer, and saying it would be worse than saying so. SETD.0 TooLongText SWI osPrintString CALL newLine INIA 0x01 SWI osExit newLine: SETD.0 NewLine SWI osPrintString RET #Data #Base 0x3000 FromText: "loaded from " BesideText: "beside it: " TooLongText: "that path would not fit" NewLine: 0x0A 0x00 MyPath: #Reserve 0d192 Beside: #Reserve 0d192 Given: #Reserve 0d64 ; ---- Included last, after both segments have been based ---- ; ; A #Base says where a whole segment begins and so has to be the first thing in it, and a ; library brings code and data of its own. Put in front, its #Data would be the first thing ; in the Data Segment and this program's own #Base would be too late. This is where Lander ; keeps its seven, for the same reason. #Include path.asm