Jump to content
IGNORED

Cleanly running a bootable .xex from a TBXL program


OxC0FFEE

Recommended Posts

Similar to @phoney's question here, but in TBXL not FB. I have a menu disk I wrote in TurboBasic XL, and I'd like to cleanly launch executables (tiny, self-contained bootable .xex-es) from it. I'm using `BRUN`, and running into crashing and obvious memory loading issues. I've looked through De Re Atari, but the Atari memory map is still a bit of an eldritch art to me, so forgive me. Is there a more solid way of doing this, that doesn't crash? (specifically, these seem to crash when a key is pressed after they execute. I tried it in both A8MXa and Altirra, cofigs attached; don't have real hw to try it on). I think the underlying issue is that these expect a clean system to boot into, not to be loaded from TBXL; so is there a way to make this work better, like load it into a different part of memory, or reset memory to default before loading it? I've set up a Gr.8 screen and PMG in my menu, both of which use a bunch of RAM, so...

 

I attached my current menu disk effort as an ATR for testing along with the basic file. Any ideas?

 

Note I also tried a different way or executing the entries, which worked even less well:

 

REM the old fragile basic executable loader way (even more fragile):
xex$(len(xex$)+1)=chr$(155)
poke 5534,0
poke 5535,192
x=adr(xex$)
y=int(x/256)
poke 853,y
poke 852,x-256*y
x=USR(ADR(["hL~)~{bbar}"]))

 

atari800macx-config.png

altirra-config.png

atascii23 compo menu - ntsc version.atr atascii23 compo menu - ntsc version.bas

Link to comment
Share on other sites

I probably misunderstood because there is a trivial solution - look at the Basic program that runs a dozen or so programs loaded from disk. the code is based on the XIO instruction and you can see the effect here: https://forums.atariage.com/applications/core/interface/file/attachment.php?id=1078500&key=0c1653877a2dc105bb8227123b66f4ec

 

200 gos.500:IF PEEK(764)=33 THEN 490
210 gos.500:XIO 40,#1,0,0,"D:01.obx"
211 IF PEEK(764)=255 THEN 211
212 XIO 40,#1,0,0,"D:COSMICHO.DAT"
213 XIO 40,#1,0,0,"D:DARKLIGH.DAT"
220 gos.500:XIO 40,#1,0,0,"D:02.obx"
221 IF PEEK(764)=255 THEN 221
222 XIO 40,#1,0,0,"D:EVE.DAT"
223 XIO 40,#1,0,0,"D:EVEREDUX.DAT"
230 gos.500:XIO 40,#1,0,0,"D:03.obx"
231 IF PEEK(764)=255 THEN 231
232 XIO 40,#1,0,0,"D:JOURNEY.DAT"
233 XIO 40,#1,0,0,"D:MADASHEL.DAT"
240 gos.500:XIO 40,#1,0,0,"D:04.obx"
241 IF PEEK(764)=255 THEN 241
242 XIO 40,#1,0,0,"D:SUPER70S.DAT"
243 XIO 40,#1,0,0,"D:TRICEROP.DAT"
244 XIO 40,#1,0,0,"D:05.obx"
245 XIO 40,#1,0,0,"D:TRITONE.OBX"
490 ?:?"Loading: RoadSong by Artem Flo":XIO 40,#1,0,0,"D:BONUS.XEX"
500 POKE 764,255:FOR LOOP=1 TO 250:NEXT LOOP: return
 

 

---

 

I think that the problem you are encountering is not your fault - tell the coder that it should return from the assembly program like this:

LDY #1
RTS

Link to comment
Share on other sites

1 hour ago, OxC0FFEE said:

I think the underlying issue is that these expect a clean system to boot into, not to be loaded from TBXL;

TBXL 1.5 occupies 5.5k of RAM from $2080 to $3629, when an executable you want to run (no matter by what means) loads to that area, you will get a crash when trying to return to the interpreter.

Link to comment
Share on other sites

Looking at one of the XEXs with ATRImageExplorer, I see a couple segments. I don't know much about segments and loading; is it possible to modify a value to load into a more compatible place in memory? If so, how?

 

Here's an example of the first part of one of the XEXs:

 

EARTHRISXEX
(1249 bytes) Executable
; xex file EARTHRIS.XEX is 1249 bytes
; xex segment 006E at 2000:206D
; Disassembly of 2000 to 206D
2000   A9 4C      LDA #$4C
2002   8D 30 02   STA $0230 ; SDLSTL SAVE DISPLAY LIST (LOW)
2005   A9 20      LDA #$20
2007   8D 31 02   STA $0231 ; SDLSTH SAVE DISPLAY LIST (HIGH)
200A   AD 00 30   LDA $3000
200D   8D C8 02   STA $02C8 ; COLOR4 BACKGROUND
2010   AD 01 30   LDA $3001
2013   8D C6 02   STA $02C6 ; COLOR2 
2016   AD 02 30   LDA $3002
2019   8D C5 02   STA $02C5 ; COLOR1 
201C   AD 10 D0   LDA $D010 ; TRIG0 
201F   F0 13      BEQ $2034
2021   AD 11 D0   LDA $D011 ; TRIG1 
2024   F0 0E      BEQ $2034
2026   AD 1F D0   LDA $D01F ; CONSOL 
2029   29 01      AND #$01
202B   F0 07      BEQ $2034
202D   AD 0F D2   LDA $D20F ; SKSTAT 
2030   29 04      AND #$04
2032   D0 E8      BNE $201C
2034   A9 00      LDA #$00
2036   8D 1D D0   STA $D01D ; GRACTL 
2039   AA         TAX
203A   9D 00 D0   STA $D000,X ; M0PF 
203D   E8         INX
203E   D0 FA      BNE $203A
2040   A9 FF      LDA #$FF
2042   8D 01 D3   STA $D301 ; PORTB 
2045   A9 40      LDA #$40
2047   8D 0E D4   STA $D40E ; NMIEN 
204A   58         CLI
204B   60         RTS

204C   70 42      BVS $2090
204E   03         ???
204F   30 02      BMI $2053
2051   02         ???
2052   02         ???
2053   02         ???
2054   02         ???
2055   02         ???
2056   02         ???
2057   02         ???
2058   02         ???
2059   02         ???
205A   02         ???
205B   02         ???
205C   02         ???
205D   02         ???
205E   02         ???
205F   02         ???
2060   02         ???
2061   02         ???
2062   02         ???
2063   02         ???
2064   02         ???
2065   02         ???
2066   02         ???
2067   02         ???
2068   02         ???
2069   02         ???
206A   02         ???
206B   41 4C      EOR ($4C,X) ; DSTAT DISPLAY STATUS
206D   20 00 00   JSR $0000 ; LINZBS LINBUG STORAGE
; xex segment 0002 at 02E0:02E1
; run at 2000

; xex segment 0463 at 3000:3462
; Disassembly of 3000 to 3462
3000   00         BRK
; Data 3001 to 31A8 (424 bytes)
3001  00 0C 00 00 00 00 00 00 00 00 00 00 00 00 00 
3010  00 0E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
3020  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
3030  00 0E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
3040  00 00 00 00 0E 00 00 00 00 00 00 00 00 00 00 00 
3050  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
3060  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
3070  00 00 00 0E 00 00 00 00 00 00 00 00 00 00 00 00 
3080  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
3090  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
30A0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
30B0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
30C0  00 00 00 00 00 0E 00 00 00 00 00 00 00 00 00 00 
30D0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
30E0  00 00 00 00 00 00 00 00 00 0E 00 00 00 00 00 00 
30F0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
3100  00 00 00 00 00 00 00 3F 00 00 00 00 00 00 00 00 
3110  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
3120  00 00 00 00 00 00 00 00 00 00 00 00 00 49 8D 8A 
3130  5B 4F 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
3140  00 00 00 0E 00 00 00 00 00 00 00 00 00 00 00 00 
3150  00 00 00 00 00 D6 80 8C BE C2 00 00 00 00 00 00 
3160  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
3170  00 00 00 00 0E 00 00 00 00 00 00 00 00 BC 8C 86 
3180  85 C7 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
3190  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
31A0  00 00 00 00 00 4B C0 84 83 

31A9   4C 00 00   JMP $0000 ; LINZBS LINBUG STORAGE

31AC   00         BRK
31AD   00         BRK
...
a bunch more of this until EOF (atascii screen data, presumably)

 

Link to comment
Share on other sites

Given that disassembled code I posted from one XEX above, after it displays the entry, is it looping and waiting for key? If so, and then on key it's trying to return, and hence crashing, would it be possible to add/subsitute something to cause it to coldboot instead? ASM is not my forte sadly.

 

If this is possible then it's not ideal but presumably I could edit each XEX to do this to avoid crashing.

Link to comment
Share on other sites

JMP $E477 will coldstart.  Only 3 bytes to add or patch.  But you usually don't want to just do it without warning as you potentially just boot into the same situation again.

 

Also, "Bootable Xex" - there's no such thing really aside from Autorun.sys which can be chained by a Dos.

Link to comment
Share on other sites

Agreed, the XEXs aren't bootable. The menu disk ATR autoruns turbobasic and loads the menu, which then BRUNs the XEXs.

 

Any clue where to patch this attached XEX, for instance? I'm assuming it waits for keypress after displaying the atascii data, then returns to the OS, but I can't figure that out from the disassembly that the ATR explorer tool gives me.

 

How would we substitute "4CE477" (or is "4C77E4" the proper byte order in the file?) for the part that returns to the OS?

earthrise copy.xex

Link to comment
Share on other sites

36 minutes ago, OxC0FFEE said:

How would we substitute "4CE477" (or is "4C77E4" the proper byte order in the file?) for the part that returns to the OS?

This is a jump to the coldstart vector JMP COLDSV which means that the computer reboots.

 

To return to DOS you could try JMP (DOSVEC) which translates to 6C0A00.

Link to comment
Share on other sites

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...