Jump to content

Photo

Source (or explanation) of Autorun.Sys for Basic?


28 replies to this topic

#1 Larry OFFLINE  

Larry

    River Patroller

  • 4,036 posts
  • Location:U.S. -- Midwest

Posted Fri Feb 10, 2012 6:12 AM

There are many Autorun.Sys files that run Basic programs at boot-up, but I cannot find one with the source code so I could better understand what is going on.

Does anyone have one (or a link) that has commented source code or could add some comments as to what is happening in the prog?

Thanks,
Larry

#2 Rybags OFFLINE  

Rybags

    Quadrunner

  • 15,852 posts
  • Location:Australia

Posted Fri Feb 10, 2012 6:28 AM

There's a few ways you could do it.

1. Put RUN "program.bas" onscreen then either set forced input on (AUX1=$0D) or put a Return into the keypress buffer. To keep the user in the dark as to what's going on you could set the text colour = background colour and disable key/Break processing.

2. "Inject" the program into memory, set Basic's zero-page pointers appropriately and call the routine in Basic ROM to run the program.

3. Do a direct call to the Basic ROM with the RUN "program.bas" parameter set up.

The Basic Source book might have more info. As for programs to do this sort of thing, there'd be dozens of them around.

Edited by Rybags, Fri Feb 10, 2012 6:29 AM.


#3 flashjazzcat ONLINE  

flashjazzcat

    Quadrunner

  • 13,921 posts
  • Location:United Kingdom

Posted Fri Feb 10, 2012 6:30 AM

Here are a couple with commented source code. The basic (no pun intended) idea is to intercept the CIO when the "Ready" prompt is printed or when BASIC asks the screen editor for a new line. It's probably possible to use "forced read" mode, but I think the idea in these examples is that the CIO get byte routine is temporarily redefined to simply pull the name of the BASIC program a character at a time and return it to the screen editor, so BASIC thinks the user actually typed it.

#4 Larry OFFLINE  

Larry

    River Patroller

  • Topic Starter
  • 4,036 posts
  • Location:U.S. -- Midwest

Posted Fri Feb 10, 2012 7:48 AM

Thanks Guys!

Googling did no good for me on this one, but I did find another good explanation with source code in Analog #66 (Nov. 1988) page 68: "Autorun.Sys Secrets." The gist of it is what you said FJC.

Article is found in the scans here: http://analog.katorlegaz.com/

-Larry

#5 flashjazzcat ONLINE  

flashjazzcat

    Quadrunner

  • 13,921 posts
  • Location:United Kingdom

Posted Fri Feb 10, 2012 8:30 AM

I Googled "Atari autorun.sys basic" and the wiki article was top of the second page of results. :)

#6 Larry OFFLINE  

Larry

    River Patroller

  • Topic Starter
  • 4,036 posts
  • Location:U.S. -- Midwest

Posted Fri Feb 10, 2012 9:17 AM

I went 3 pages deep and at least didn't see it. It seems like they do not always come up in the same order (except paid results). I did find a Compute! article listed that looked promising, but Atari Magazines doesn't have that issue's text --just the index for that issue.
-Larry

#7 Rybags OFFLINE  

Rybags

    Quadrunner

  • 15,852 posts
  • Location:Australia

Posted Fri Feb 10, 2012 9:35 AM

I reckon you won't get much tighter than the one Jon linked to.

Maybe alter it to disable the Break key, other than that it looks ready to roll.

Or you could have it use an external file as the input rather than the imbedded text.

#8 JAC! OFFLINE  

JAC!

    Stargunner

  • 1,745 posts
  • Always looking for GFX and MSX for my demos
  • Location:Lebach, Germany

Posted Fri Feb 10, 2012 10:37 AM

Here mine which uses case 1 Rybags mentioned.
It also works correctly if BASIC was disabled before which is something many modfied OS do by default (experienced user do automatically because they don't expect BASIC programs ;.)


; Switches on BASIC, re-opens the editor, checks the RBAM and autoruns "AUTORUN.BAS"
; Save executable as "AUTORUN.SYS"
; JAC! - 2010


iocb = $340 ;IOCB base address
iocom = iocb+2 ;IOCB command
ioadr = iocb+4 ;IOCB buffer address
ioaux1 = iocb+10 ;IOCB auxilary byte 1
ioaux2 = iocb+11 ;IOCB auxilary byte 1

ciov = $e456 ;CIO vector

open = $03 ;Command: OPEN
close = $0c ;Command: CLOSE

rw = 12
rwauto = 13

* = $600

start
cld
clc
lda $d301 ;Enable BASIC
and #$fd
sta $d301

ldx #0 ;Channel 0

lda #close ;Close editor
sta iocom,x
jsr ciov

lda #open ;Open editor to ensure memtop is correct
sta iocom,x
lda #<editor
sta ioadr,x
lda #>editor
sta ioadr+1,x
lda #rw ;read and write
sta ioaux1,x
lda #0
sta ioaux2,x
jsr ciov

lda #rwauto ;Switch to automatic input mode
sta ioaux1,x


lda #0 ;Screen off, will be switch on by the next GRAPHICS statement
sta 559

wait lda 20 ;Wait until screen is off
cmp 20
beq wait

ldx #[lineend-line]-1
ldy #[lineend-line]-1+2
copyline
lda line,x
sta (88),y
dey
dex
bpl copyline
rts



editor .byte "E:",$9b

; Disable automatic input mode
line .sbyte "POKE 842,12:RUN ",34,"D1:AUTORUN.BAS",34
lineend


* = $2e0
.word test


#9 Rybags OFFLINE  

Rybags

    Quadrunner

  • 15,852 posts
  • Location:Australia

Posted Fri Feb 10, 2012 10:57 AM

You'd need to set the Ramtop ($6A) OS variable there. If Basic is off then it = $C0 and you'd need to set to $A0.

A quick/dirty way to Close an IOCB is to set the Dev Index (ICHID $340) to $FF.

Edited by Rybags, Fri Feb 10, 2012 10:59 AM.


#10 Larry OFFLINE  

Larry

    River Patroller

  • Topic Starter
  • 4,036 posts
  • Location:U.S. -- Midwest

Posted Fri Feb 10, 2012 2:23 PM

Thanks, Jac!

Nicely commented and easy to follow! That's just the kind of assembler code I need! ;)

-Larry

#11 JAC! OFFLINE  

JAC!

    Stargunner

  • 1,745 posts
  • Always looking for GFX and MSX for my demos
  • Location:Lebach, Germany

Posted Fri Feb 10, 2012 2:36 PM

As Rybags mentioned:

lda $d301 ;Enable BASIC
and #$fd
sta $d301

lda #>$a000 ; Set RAMTOP to begin of BASIC ROM $a000
sta $6a


Edited by JAC!, Fri Feb 10, 2012 2:36 PM.


#12 russg OFFLINE  

russg

    Stargunner

  • 1,646 posts
  • Location:Cleveland, Ohio

Posted Sat Feb 18, 2012 4:03 PM

There's a really neat program called 'fast fingers' that makes an autorun.sys that
types anything you want. It is from Antic 1984, February. You run the BASIC
program, type what you want to happen at bootup, and then hit CNTRL-3 to save
it to AUTORUN.SYS.

Attached Files


Edited by russg, Sat Feb 18, 2012 4:04 PM.


#13 russg OFFLINE  

russg

    Stargunner

  • 1,646 posts
  • Location:Cleveland, Ohio

Posted Sun Feb 19, 2012 7:15 AM

There's a really neat program called 'fast fingers' that makes an autorun.sys that
types anything you want. It is from Antic 1984, February. You run the BASIC
program, type what you want to happen at bootup, and then hit CNTRL-3 to save
it to AUTORUN.SYS.

It doesn't have to be AUTORUN.SYS, you can re-name it anything you want if you
just want to 'type' something often ie. it is a normal binary load.

Edited by russg, Sun Feb 19, 2012 7:16 AM.


#14 Larry OFFLINE  

Larry

    River Patroller

  • Topic Starter
  • 4,036 posts
  • Location:U.S. -- Midwest

Posted Mon Feb 20, 2012 5:42 PM

Thanks, Russ. I remember this program from Antic many years ago. ____ Chamberlin, author (or something like that) according to my rusty memory. (?)
(I didn't look it up, if by chance I'm right...)
-Larry

There's a really neat program called 'fast fingers' that makes an autorun.sys that
types anything you want. It is from Antic 1984, February. You run the BASIC
program, type what you want to happen at bootup, and then hit CNTRL-3 to save
it to AUTORUN.SYS.

It doesn't have to be AUTORUN.SYS, you can re-name it anything you want if you
just want to 'type' something often ie. it is a normal binary load.



#15 russg OFFLINE  

russg

    Stargunner

  • 1,646 posts
  • Location:Cleveland, Ohio

Posted Mon Feb 20, 2012 6:13 PM

Thanks, Russ. I remember this program from Antic many years ago. ____ Chamberlin, author (or something like that) according to my rusty memory. (?)
(I didn't look it up, if by chance I'm right...)
-Larry
Right, Craig Chamberlain. It is easy to read the article, if you download the Antic torrent,
pdfs and atrs. I'm not going to post the 113 megabyte pdf of the 02/84 Antic.
( I also have the original magazine, but it is easier to look in the torrent and dig it out
than dig it out of my Antic boxes.)

Edited by russg, Mon Feb 20, 2012 6:14 PM.


#16 ascrnet OFFLINE  

ascrnet

    Chopper Commander

  • 172 posts
  • Location:Santiago, Chile

Posted Mon Jul 9, 2018 6:50 PM


; Switches on BASIC, re-opens the editor, checks the RBAM and autoruns "AUTORUN.BAS"
; Save executable as "AUTORUN.SYS"
; JAC! - 2010


iocb = $340 ;IOCB base address
iocom = iocb+2 ;IOCB command
ioadr = iocb+4 ;IOCB buffer address
ioaux1 = iocb+10 ;IOCB auxilary byte 1
ioaux2 = iocb+11 ;IOCB auxilary byte 1

ciov = $e456 ;CIO vector

open = $03 ;Command: OPEN
close = $0c ;Command: CLOSE

rw = 12
rwauto = 13

* = $600

start
cld
clc
lda $d301 ;Enable BASIC
and #$fd
sta $d301

ldx #0 ;Channel 0

lda #close ;Close editor
sta iocom,x
jsr ciov

lda #open ;Open editor to ensure memtop is correct
sta iocom,x
lda #<editor
sta ioadr,x
lda #>editor
sta ioadr+1,x
lda #rw ;read and write
sta ioaux1,x
lda #0
sta ioaux2,x
jsr ciov

lda #rwauto ;Switch to automatic input mode
sta ioaux1,x


lda #0 ;Screen off, will be switch on by the next GRAPHICS statement
sta 559

wait lda 20 ;Wait until screen is off
cmp 20
beq wait

ldx #[lineend-line]-1
ldy #[lineend-line]-1+2
copyline
lda line,x
sta (88),y
dey
dex
bpl copyline
rts



editor .byte "E:",$9b

; Disable automatic input mode
line .sbyte "POKE 842,12:RUN ",34,"D1:AUTORUN.BAS",34
lineend


* = $2e0
.word test

Hi JAC!,

thanks for your example, I wanted to consult to use it in mads that I have to change?

since I made some changes but it does not work, a POKE 842,12:POKE 710,0 is not executed


regards


Edited by ascrnet, Mon Jul 9, 2018 6:50 PM.


#17 JAC! OFFLINE  

JAC!

    Stargunner

  • 1,745 posts
  • Always looking for GFX and MSX for my demos
  • Location:Lebach, Germany

Posted Tue Jul 10, 2018 1:10 AM

.byte "E:" must be 'E:' instead.
* = ... word ... must be run test

#18 ascrnet OFFLINE  

ascrnet

    Chopper Commander

  • 172 posts
  • Location:Santiago, Chile

Posted Tue Jul 10, 2018 8:31 PM

.byte "E:" must be 'E:' instead.
* = ... word ... must be run test

 

just change that and I left it like that

editor 
	.byte 'E:',$9b

line	
	.byte "POKE 842,12:POKE 710,0"
lineend

	run start

prints the line in basic and the cursor goes down many times, but the line is not executed. there is my doubt that I am doing wrong or that I am missing. :?



#19 JAC! OFFLINE  

JAC!

    Stargunner

  • 1,745 posts
  • Always looking for GFX and MSX for my demos
  • Location:Lebach, Germany

Posted Wed Jul 11, 2018 6:50 AM

Maybe the cursor starts in the 2nd line. Different OS? Will check when I have access to an Atari environment again next week.

#20 baktra OFFLINE  

baktra

    Dragonstomper

  • 533 posts
  • Location:Czech republic

Posted Wed Jul 11, 2018 8:56 AM

Shouldn't you disable screen DMA before enabling the BASIC ROM?

What if the screen memory or display list happens to be in the A000-BFFF area?



#21 flashjazzcat ONLINE  

flashjazzcat

    Quadrunner

  • 13,921 posts
  • Location:United Kingdom

Posted Wed Jul 11, 2018 10:49 AM

I was surprised to see the method of actually patching HATABS in order to redirect E: input via a custom GET routine wasn't mentioned. It's the method used by the SIDE XEX loader and is fairly resilient. 



#22 ascrnet OFFLINE  

ascrnet

    Chopper Commander

  • 172 posts
  • Location:Santiago, Chile

Posted Wed Jul 11, 2018 9:14 PM

Maybe the cursor starts in the 2nd line. Different OS? Will check when I have access to an Atari environment again next week.

 

part of the first line, but it does not run. use DOS 2.5 no problem in waiting

foto.png

 

 

 



#23 ascrnet OFFLINE  

ascrnet

    Chopper Commander

  • 172 posts
  • Location:Santiago, Chile

Posted Wed Jul 11, 2018 9:22 PM

Shouldn't you disable screen DMA before enabling the BASIC ROM?

What if the screen memory or display list happens to be in the A000-BFFF area?

 

I deactivated it to see what happened on the screen with the basic

I use the A000 memory as recommended.

 

regards



#24 phaeron OFFLINE  

phaeron

    River Patroller

  • 2,597 posts
  • Location:Bay Area, CA, USA

Posted Fri Jul 13, 2018 11:24 PM

Missing character is because of the direct screen write on top of the cursor, so it gets stomped by the space that's already saved by the Display Handler in OLDCHR. That's a moot issue though because the text needs to be drawn two lines down. Honestly, I wouldn't use direct screen writes, just do one big put command to draw the text and move the cursor back up with control chars.



#25 Rybags OFFLINE  

Rybags

    Quadrunner

  • 15,852 posts
  • Location:Australia

Posted Sat Jul 14, 2018 12:31 AM

I really like the HATABS idea that Jon suggested - it sticks to programming etiquette and you could use a counter or special EOF character to instruct the handler to put things back to default.  Plus you don't need any screen trickery to hide what's going on.






0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users