6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Wed Sep 25, 2024 4:30 am

All times are UTC




Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: Sun Dec 02, 2012 2:45 am 
Offline
User avatar

Joined: Sat Sep 29, 2012 10:15 pm
Posts: 899
I had a few days while my FPGA Playground PCB is being manufactured, so for a change of pace I revived an older project:

GameInjector

This is a tiny Linux program (20K executable) that loads one of 271 games into my Apple IIc over the serial port. There are a couple of other attempts to do so on the Internet, but none of them worked well enough for me. The code is a little rough, but works (Apple IIc only! right now). It loads Apple Panic in 6 seconds.

http://apple2.x10.mx/GameInjector/GameInjector.zip

To compile:
Code:
gcc -o inject2c inject2c.c


To run (substitute your device instead of /dev/ttyUSB0):
Code:
sudo inject2c /dev/ttyUSB0


Follow the prompts. The program will sit there and try to load a monitor into the Apple IIc. As soon as you type in "IN#2" the process will start and a second later you will see a game menu with 271 items on your Linux box (resize the console to fit). Enter the number of the game, and a few seconds later you can play it.

If anything goes wrong, just reset the Apple with <CONTROL><RESET> or reboot with <OPENAPPLE><CONTROL><RESET> and reset it again to get to the ] prompt. "IN#2" will do it. If all else fails, <CTRL><C> the Linux program and the Apple, and start over. Some games don't run on my machine.

Enjoy!

P.S. The bootstrapping process is pretty cool. There is more info at http://apple2.x10.mx

_________________
In theory, there is no difference between theory and practice. In practice, there is. ...Jan van de Snepscheut


Last edited by enso on Mon Dec 03, 2012 5:32 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
PostPosted: Mon Dec 03, 2012 9:37 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10938
Location: England
Hi enso - I like the sound of this bootstrapping, but didn't see any more on your wiki: must I read your code?
Cheers
Ed


Top
 Profile  
Reply with quote  
PostPosted: Mon Dec 03, 2012 4:09 pm 
Offline
User avatar

Joined: Sat Sep 29, 2012 10:15 pm
Posts: 899
BigEd wrote:
Hi enso - I like the sound of this bootstrapping, but didn't see any more on your wiki: must I read your code?
Cheers
Ed
No, that would be cruel and unusual!

I will briefly walk through the bootstrap process. It is really amazing to see programs like this one or ADT start up a few seconds after typing "IN#2" and really points out to how flexible the Apple II is.

So the host sets up a serial port to 300 baud (for Apple IIc). Once per second (or more often) it sends a "PR#2" on the serial port and watches for input. As soon as you enter "IN#2" on the Apple, the PR#2 command will be accepted and both input and output connected to the host via the serial port.

At this point the host will detect the "]" prompt on the wire. The host sends "CALL-151" to enter the monitor, and sends a small program in hex:
Code:
300:a9 10 8d ab c0 a9 0b 8d aa c0 ad a8 c0 60

This bumps the Apple IIc serial port to 115.2 Kbaud:
Code:
0300-   A9 10       LDA  #$10
0302-   8D AB C0    STA  $C0AB
0305-   A9 0B       LDA  #$0B
0307-   8D AA C0    STA  $C0AA
030A-   AD A8 C0    STA  $C0A8
030D-   60            RTS


The host issues a "300G" to run this code and sets up its own port to 115.2Kbaud. The monitor prompt "*" should arrive in the fast mode.
Now the host loads the "serial loader" into the Apple II; this one loads a game verifying checksums etc. The host displays a menu of games and sends the game you select.

After loading the game (while you are playing) the host keeps checking the port as described above. When you are done, reset the Apple and enter "IN#2" and a second later the link is back up.

I use a similar technique in my interactive environment "HazMat". Instead of sending games, I send lines of assembled/compiled/BASIC code. It's like Apple's mini-assembler, but with symbols and a full-screen editor on the host side. When I press <CTRL><RETURN>, the line of code the cursor is on is assembled and sent to the Apple II monitor. For BASIC I just pass the line through without assembling. I've made many Forths for microcontrollers that use the same technique.

_________________
In theory, there is no difference between theory and practice. In practice, there is. ...Jan van de Snepscheut


Last edited by enso on Mon Dec 03, 2012 5:29 pm, edited 3 times in total.

Top
 Profile  
Reply with quote  
PostPosted: Mon Dec 03, 2012 4:15 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10938
Location: England
Great - thanks! My notes on the Beeb tell me this:
Code:
On boot, the beeb needs at minimum
 *fx7,8
to set the baud rate (although we could connect initially at 300 and
set it from outside)
 *fx2,1
to accept input from rs423 instead of keyboard

Then we need
 *fx8,8
to set the output speed
 *fx3,5
to send output to rs423 as well as screen
 *fx181
to set raw mode (can send escape to end AUTO mode for example)
and set an early stop-sending to prevent overrun:
 *fx203,50,0

So the absolute minimum would be hte *fx2,1 - not a great deal more difficult than IN#2

Cheers
Ed


Top
 Profile  
Reply with quote  
PostPosted: Mon Dec 03, 2012 4:37 pm 
Offline
User avatar

Joined: Sat Sep 29, 2012 10:15 pm
Posts: 899
Yes, it should work! How fast can you set the port to? Apple IIc officially is much lower, but can go to 115.2 kilobits which makes the game loading much faster than the floppy.

_________________
In theory, there is no difference between theory and practice. In practice, there is. ...Jan van de Snepscheut


Top
 Profile  
Reply with quote  
PostPosted: Mon Dec 03, 2012 4:40 pm 
Offline
User avatar

Joined: Sat Sep 29, 2012 10:15 pm
Posts: 899
Also, hardware handshaking is something I never got to work. The games are sent in block mode with packets small enough to guarantee delivery and checksummed. For line-based development in HazMat I [the host] watch the echo for each character - it's a little slower but fast enough for my needs. I just have to be careful when sending largish blocks of text/code as syntax errors mess things up.

_________________
In theory, there is no difference between theory and practice. In practice, there is. ...Jan van de Snepscheut


Top
 Profile  
Reply with quote  
PostPosted: Mon Dec 03, 2012 4:56 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10938
Location: England
Sadly, 19200 is the max for the serial port - though you can bit bang the user port up to half-duplex 115200.
Even at 19200, handshaking seems to be obligatory.


Top
 Profile  
Reply with quote  
PostPosted: Mon Dec 03, 2012 5:25 pm 
Offline
User avatar

Joined: Sat Sep 29, 2012 10:15 pm
Posts: 899
BigEd wrote:
Sadly, 19200 is the max for the serial port - though you can bit bang the user port up to half-duplex 115200.
Even at 19200, handshaking seems to be obligatory.


That may be the case for Apple computers as well with the exception of newer IIc and GS...

Without handshaking, there are variable delays on Apple machines. For instance, after the space just past the BASIC line number there is a delay that will swallow characters. When Apple starts a new line on the screen (>40 characters sent) there is a delay. That delay becomes enormously long when the screen is scrolled...

19200 is workable for most things, and half-duplex is not a problem either, although the bootstrap will take a little longer.

_________________
In theory, there is no difference between theory and practice. In practice, there is. ...Jan van de Snepscheut


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 17 guests


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: