[net.micro.apple] Hackers delight - AppleII question

jrh@bunker.UUCP (Jeff Hagen) (09/04/85)

Question, Apple II[+-], workings of 80 column cards.

Scenario:
You enter the monitor. Call -151. You type  3^P return with your 80
column card in slot 3. The monitor pokes locations $36 and $37 with
 $C300. It displays the prompt with a call through $36. $C300 gets 
executed. Among other things, the ROM code at $C300 selects the
80column video display. Your screen flips. It pokes location $36
with the usual entry point for output characters. (like 07) It
also pokes $38 and $39 for the input routine that will allow
lower case and other things. The monitor works like a champ in 80 
columns, but you have lost your hook to DOS. 3EAG fixes that.

Now here is the big if. If I have ROM selected in the upper 12K
and I do a 0^P or a PR#0 the screen gets flipped back to the 40
column mode.  If I have RAM selected it fails. The $36-$39 vectors
are set properly, but the 80 column screen is still showing.
Assume ROM and RAM have the same code in them.

Question:
Is the above scenario a hardware bug in my cheapie 80col card?
Or more generally, how does the 80 column card know when to flip
back to 40 column mode since a PR# or a 0^P only pokes the
 $36 through $39 bytes? Is it actually monitoring the bus?
Or is its input routine scanning the input?

I'm baffled.
Any ideas?
Thanks.

                     Jeff Hagen
                     decvax!ittvax!bunker!jrh

flaps@utcs.uucp (Alan J Rosenthal) (09/19/85)

DOS circumvents most of the properties of the normal system I/O.  In
particular, it requires that the input and output hooks in $3[6-9] point
to DOS rather than COUT or whatever.  So 3^P screws this up because it
changes them.
You should do a PR#3 instead.  Even from the monitor.  PR# is a basic
command, yes, but it is also a DOS command.  And that takes precedence
when DOS is installed.  DOS will change its own hooks to the 80-column
card, but leave the monitor hooks pointing to DOS so that DOS gets
first crack at all the I/O.
And from a basic program, you should do
	PRINT CHR$(4);"PR#3"
not
	PR#3
.  And from an assembly language program you should output the sequence
PR#3^M to $FDED.

Alan J Rosenthal
{decvax|ihnp4|cbosgd|etc}!utzoo!utcs!flaps

bcx@eeg.UUCP ( Bryan Costales) (09/21/85)

> .  And from an assembly language program you should output the sequence
> PR#3^M to $FDED.
> 
> Alan J Rosenthal

No, no. From the assembly language level, you should:

	jsr $C300	; Turn on 80 col card in slot 3
	jsr $3EA	; Reconnect DOS 3.3

Using DOS commands from assembly language programs by printing those
commands thru $FDED is very tricky. You must trick the DOS 
interpreter into thinking that your assembly language program is
a running BASIC program. See "Beneath DOS", Lisa 1.5 source, The
Randy Hyde Book, etc.
-- 
----
	Bryan Costales, EEG Systems Laboratory
	1855 Folsom St, San Francisco, Ca 94103 (415) 621-8343
	{ihnp4,dual,qantel}!ptsfa!eeg!bcx