Groups | Search | Server Info | Keyboard shortcuts | Login | Register


Groups > comp.sys.apple2.programmer > #85

Re: Need example of IIgs code to set BRK vector

From Charlie <charlieDOTd@verEYEzon.net>
Newsgroups comp.sys.apple2.programmer
Subject Re: Need example of IIgs code to set BRK vector
Date 2012-01-03 15:10 -0500
Organization A noiseless patient Spider
Message-ID <jdvnac$c8a$1@dont-email.me> (permalink)
References <6875625a-f276-4d22-8cf3-895f9cceb506@k28g2000yqn.googlegroups.com> <jdtsqs$p5p$1@dont-email.me> <d145e45d-a59c-4d48-8ccf-448db65edee9@p13g2000yqd.googlegroups.com> <jdu379$ie3$1@dont-email.me> <8125b173-cd82-442f-9c26-5573a342f061@l24g2000yqm.googlegroups.com>

Show all headers | View raw


On 1/3/2012 12:46 AM, datawiz wrote:
> I'm certain that the BRK is the problem here, as I've fixed similar
> issues in other non-friendly IIgs games.
>
> On the IIe, the IRQ/BRK vector at FFFF/FFFE is set to point at $9300
> (via bank switching) and then uses BRK instructions throughout the
> code to return to $9300 over and over again. On an Apple II, it's not
> a problem but here's what happens on a IIgs when it encounters the
> first BRK instruction (trace file from Sweet 16):
>
> 00/4037: A9 F5          LDA #$F5           A=0000 X=0000 Y=0000 e=1
> m=1 x=1
> 00/4039: 85 51          STA $51            A=00F5 X=0000 Y=0000 e=1
> m=1 x=1
> 00/403B: FD 7A 40       SBC $407A,x        A=00F5 X=0000 Y=0000 e=1
> m=1 x=1
> 00/403E: 00 10          BRK $10            A=0047 X=0000 Y=0000 e=1
> m=1 x=1
> 00/C074: B8             CLV                A=0047 X=0000 Y=0000 e=1
> m=1 x=1
> 00/C075: 5C 10 00 E1    JMP $E10010        A=0047 X=0000 Y=0000 e=1
> m=1 x=1
> E1/0010: 5C CC B7 FF    JMP $FFB7CC        A=0047 X=0000 Y=0000 e=1
> m=1 x=1
> FF/B7CC: 18             CLC                A=0047 X=0000 Y=0000 e=1
> m=1 x=1
>
> At 00/403E the first BRK instruction is encountered, and it appears to
> jmp to E1/0010-- perhaps it understands the BRK index ($10) and
> vectors to $E1/0000+index? But it's certainly not following the same
> behavior as the 8-bit Apple.

I really have no idea what's going on here and apparently I'm wrong 
about the vectors not being set up when booting to an 8 bit OS.

On a IIgs 00/C071 to 00/C07F is a ROM interrupt jump table (why its in 
the I/O area I don't know).  E10010 is the vector for the main system 
interrupt manager.  It can be patched so I guess what you are asking is 
how to do that.

> My idea was to patch in at the first stage boot a code snippet to:
> 1: detect if we are running on a IIgs
> 2: if so, set the IIgs BRK vector to 00/9300

Assumming that your code is 8-bit (emulation mode) then to patch the 
vector you would need to switch to native mode and back:

CLC
XCE 		;switches on native mode
REP #$110000 	; make the regs 16 bit

LDA #$5C00	; patch the vector
STA $E10010
LDA #$9300
STA $E10012

SEC
XCE		;back to emulation mode (8 bit)

Keep in mind that I haven't done any coding for the IIgs in many years 
so don't take this code as gospel.

> 3: continue with standard boot

I think the problem is going to be when you now come back from this 
patched vector you will probably be in the wrong mode.  Native instead 
of emulation.  At the very least you are going to have to add some code 
(and store it somewhere) to make sure you come back in the same mode you 
left.  You'll also probably have to ensure that the machine registers, 
stack pointer, etc. are in the same state as when the BRK occurred. 
Take a look at the code at $FFB7CC to see how the IIgs is handling it.

Charlie

Back to comp.sys.apple2.programmer | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Need example of IIgs code to set BRK vector datawiz <rich.martin@gmail.com> - 2012-01-02 17:55 -0800
  Re: Need example of IIgs code to set BRK vector Charlie <charlieDOTd@verEYEzon.net> - 2012-01-02 22:32 -0500
    Re: Need example of IIgs code to set BRK vector datawiz <rich.martin@gmail.com> - 2012-01-02 20:01 -0800
      Re: Need example of IIgs code to set BRK vector Charlie <charlieDOTd@verEYEzon.net> - 2012-01-03 00:21 -0500
        Re: Need example of IIgs code to set BRK vector datawiz <rich.martin@gmail.com> - 2012-01-02 21:46 -0800
          Re: Need example of IIgs code to set BRK vector Charlie <charlieDOTd@verEYEzon.net> - 2012-01-03 15:10 -0500
            Re: Need example of IIgs code to set BRK vector datawiz <rich.martin@gmail.com> - 2012-01-03 13:56 -0800
  Re: Need example of IIgs code to set BRK vector "Anton Treuenfels" <teamtempest@yahoo.com> - 2012-01-03 20:17 -0600
    Re: Need example of IIgs code to set BRK vector datawiz <rich.martin@gmail.com> - 2012-01-04 06:55 -0800
      Re: Need example of IIgs code to set BRK vector datawiz <rich.martin@gmail.com> - 2012-01-04 07:10 -0800
        Re: Need example of IIgs code to set BRK vector magnusfalkirk <dean.phares@gmail.com> - 2012-01-04 09:05 -0800

csiph-web