Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.sys.apple2.programmer > #2605 > unrolled thread

Activating Soft-Switches in Assembly

Started byalxmist@aol.com
First post2016-03-29 09:00 -0700
Last post2016-03-31 12:28 -0700
Articles 20 on this page of 25 — 10 participants

Back to article view | Back to comp.sys.apple2.programmer


Contents

  Activating Soft-Switches in Assembly alxmist@aol.com - 2016-03-29 09:00 -0700
    Re: Activating Soft-Switches in Assembly Michael Pohoreski <michael.pohoreski@gmail.com> - 2016-03-29 15:14 -0700
    Re: Activating Soft-Switches in Assembly Michael Pohoreski <michael.pohoreski@gmail.com> - 2016-03-29 15:28 -0700
      Re: Activating Soft-Switches in Assembly Michael Pohoreski <michael.pohoreski@gmail.com> - 2016-03-29 15:32 -0700
        Re: Activating Soft-Switches in Assembly alxmist@aol.com - 2016-03-30 09:31 -0700
          Re: Activating Soft-Switches in Assembly Antoine Vignau <antoine.vignau@laposte.net> - 2016-03-30 10:58 -0700
            Re: Activating Soft-Switches in Assembly alxmist@aol.com - 2016-03-30 11:23 -0700
              Re: Activating Soft-Switches in Assembly D Finnigan <dog_cow@macgui.com> - 2016-03-30 18:28 +0000
                Re: Activating Soft-Switches in Assembly Michael J. Mahon <mjmahon@aol.com> - 2016-03-30 23:46 -0500
                Re: Activating Soft-Switches in Assembly mmphosis <mmphosis@macgui.com> - 2016-03-31 16:07 +0000
              Re: Activating Soft-Switches in Assembly Michael Pohoreski <michael.pohoreski@gmail.com> - 2016-03-30 14:10 -0700
          Re: Activating Soft-Switches in Assembly gids.rs@sasktel.net - 2016-03-30 13:06 -0700
            Re: Activating Soft-Switches in Assembly Michael Pohoreski <michael.pohoreski@gmail.com> - 2016-03-30 14:13 -0700
              Re: Activating Soft-Switches in Assembly gids.rs@sasktel.net - 2016-03-31 08:25 -0700
                Re: Activating Soft-Switches in Assembly alxmist@aol.com - 2016-03-31 08:52 -0700
                  Re: Activating Soft-Switches in Assembly Michael J. Mahon <mjmahon@aol.com> - 2016-03-31 11:30 -0500
                  Re: Activating Soft-Switches in Assembly Michael Pohoreski <michael.pohoreski@gmail.com> - 2016-03-31 12:33 -0700
                    Re: Activating Soft-Switches in Assembly Michael Pohoreski <michael.pohoreski@gmail.com> - 2016-03-31 12:59 -0700
                    Re: Activating Soft-Switches in Assembly Mark Calderbank <noname@test.com> - 2016-04-01 15:54 +0100
                      Re: Activating Soft-Switches in Assembly Mark Calderbank <mark@zoot.loggytronic.net> - 2016-04-01 16:36 +0100
                        Re: Activating Soft-Switches in Assembly alxmist@aol.com - 2016-04-01 09:58 -0700
                          Re: Activating Soft-Switches in Assembly Michael J. Mahon <mjmahon@aol.com> - 2016-04-01 17:07 -0500
                      Re: Activating Soft-Switches in Assembly Michael Pohoreski <michael.pohoreski@gmail.com> - 2016-04-01 17:45 -0700
                        Re: Activating Soft-Switches in Assembly alxmist@aol.com - 2016-04-05 08:59 -0700
              Re: Activating Soft-Switches in Assembly "Michael J. Mahon" <mjmahon@aol.com> - 2016-03-31 12:28 -0700

Page 1 of 2  [1] 2  Next page →


#2605 — Activating Soft-Switches in Assembly

Fromalxmist@aol.com
Date2016-03-29 09:00 -0700
SubjectActivating Soft-Switches in Assembly
Message-ID<634b1674-1319-4795-b04c-37e52130c2b0@googlegroups.com>
Does anyone have a list of the subroutines used to activate the soft-switches for all the text and graphics modes? So far I only know of one: $FB04, which lets me do some lo-res graphic tests.

[toc] | [next] | [standalone]


#2607

FromMichael Pohoreski <michael.pohoreski@gmail.com>
Date2016-03-29 15:14 -0700
Message-ID<a6f6be3a-07bb-4fc8-bcdd-08235f90ae31@googlegroups.com>
In reply to#2605
On Tuesday, March 29, 2016 at 9:00:35 AM UTC-7, alx...@aol.com wrote:
> Does anyone have a list of the subroutines used to activate the soft-switches for all the text and graphics modes? So far I only know of one: $FB04, which lets me do some lo-res graphic tests.

You _could_ dig through AppleSoft and the F800 ROM but why bother?

1. Just access them directly, they are only 3 bytes/switch (from assembly). 

i.e. To set: "HGR, Mixed"

From the command line:

  CALL-151
  c050 c053 c054 c057

From Applesoft

   G=49232:POKE G,0:POKE G+3,0:POKE G+4,0:POKE G+7,0

See the "Beagle Bros Peeks and Pokes Chart"
* http://www.lazilong.com/apple_ii/bbros/chart.jpg

From Assembly:

 BIT $C050
 BIT $C053
 BIT $C054
 BIT $C057

or by their symbolic names:

  CLRTEXT =  $C050 ;display graphics 
  SETTEXT =  $C051 ;display text

  CLRMIXED = $C052 ;clear mixed mode- enable full graphics 
  SETMIXED = $C053 ;enable graphics/text mixed mode

  PAGE1 =    $C054 ;select text/graphics page1 
  PAGE2 =    $C055 ;select text/graphics page2 

  CLRHIRES = $C056 ;select Lo-res 
  SETHIRES = $C057 ;select Hi-res

Ergo,

  BIT CLRTEXT
  BIT SETMIXED 
  BIT PAGE1 
  BIT SETHIRES 

2. "There are 4 Lights!", er you'll need 4 switches. :-)

   TEXT or Graphics
   Low-Res or Hi-Res
   Page 1 or 2
   Mixed or Full

Hope this helps!

[toc] | [prev] | [next] | [standalone]


#2608

FromMichael Pohoreski <michael.pohoreski@gmail.com>
Date2016-03-29 15:28 -0700
Message-ID<284e6811-1bfd-4303-b3f9-c89c52933055@googlegroups.com>
In reply to#2605
On Tuesday, March 29, 2016 at 9:00:35 AM UTC-7, alx...@aol.com wrote:
> Does anyone have a list of the subroutines used to activate the soft-switches for all the text and graphics modes? So far I only know of one: $FB04, which lets me do some lo-res graphic tests.

To track down Applesoft's usage I highly recommend:
http://jamtronix.com/files/applesoft.html

These are the symbolic names used, # of usages, and cross-reference:

SW.TXTCLR  .EQ $C050 ; 1 usage  @ $F3EF (common code HGR2 HGR)
SW.MIXCLR  .EQ $C052 ; 1 usages @ $F3DB (HGR2)
SW.MIXSET  .EQ $C053 ; 2 usages @ $F3E7 (HGR), $F393 (GR)
SW.LOWSCR  .EQ $C054 ; 2 usages @ $F399 (TEXT), $F3E4 (HGR)
SW.HISCR   .EQ $C055 ; 1 usage  @ $F3D8 (HGR2)
SW.LORES   .EQ $C056 ; 1 usage  @ $F390 (GR)
SW.HIRES   .EQ $C057 ; 1 usage  @ $F3EC (common code HGR2 HGR)

With 4 binary switches there are 2^4 = 16 permutations -- Applesoft & the F8 ROM only use a subset of them.

What's the context of the problem you're trying to solve?

[toc] | [prev] | [next] | [standalone]


#2609

FromMichael Pohoreski <michael.pohoreski@gmail.com>
Date2016-03-29 15:32 -0700
Message-ID<e1fce135-e8f5-436b-aa51-fda3dc551837@googlegroups.com>
In reply to#2608
On Tuesday, March 29, 2016 at 3:28:13 PM UTC-7, Michael Pohoreski wrote:
> 
> With 4 binary switches there are 2^4 = 16 permutations -- Applesoft & the F8 ROM only use a subset of them.

Addendum: Well, technically, there would be 16, but in practice, SETMIXED doesn't do anything in text mode. :-)

The actual # of video modes is left as an exercise for the reader. :-)

OK, that's enough 'spam' :-)

[toc] | [prev] | [next] | [standalone]


#2610

Fromalxmist@aol.com
Date2016-03-30 09:31 -0700
Message-ID<8e90c94f-23e6-4286-b218-5d20603f58c3@googlegroups.com>
In reply to#2609
I don't understand. In "Apple II Graphics and Arcade Game Design" the author uses JSR $FB04 to activate the lo-res graphics. Are $C050-$C057 interchangeable?

[toc] | [prev] | [next] | [standalone]


#2611

FromAntoine Vignau <antoine.vignau@laposte.net>
Date2016-03-30 10:58 -0700
Message-ID<ffcf62f4-f6d0-4ef8-bf23-ff166b0c7b6f@googlegroups.com>
In reply to#2610
The ROM code in the $F800..$FFFF area uses the softswitches and are here to ease your life.

You can use the softswitches directly.

[toc] | [prev] | [next] | [standalone]


#2612

Fromalxmist@aol.com
Date2016-03-30 11:23 -0700
Message-ID<f001e439-1c94-42cb-9404-121c572f9756@googlegroups.com>
In reply to#2611
On Wednesday, March 30, 2016 at 1:58:43 PM UTC-4, Antoine Vignau wrote:
> The ROM code in the $F800..$FFFF area uses the softswitches and are here to ease your life.
> 
> You can use the softswitches directly.

Okay. What are their addresses, and how do I activate them either way? Do the $C050's require a JSR?

[toc] | [prev] | [next] | [standalone]


#2613

FromD Finnigan <dog_cow@macgui.com>
Date2016-03-30 18:28 +0000
Message-ID<dog_cow-1459362685@macgui.com>
In reply to#2612
alxmist wrote:
>
> and how do I activate them either way? Do
> the $C050's require a JSR?
>

No, you just reference the location with a load instruction. Use whichever
(A,X, or Y) is convenient in your code.

Don't try to JMP or JSR to the soft switch location, because there's no
valid instructions there for the 6502 to execute.

-- 
]DF$
The Marina IP stack for Apple II--
http://marina.a2hq.com/

[toc] | [prev] | [next] | [standalone]


#2624

FromMichael J. Mahon <mjmahon@aol.com>
Date2016-03-30 23:46 -0500
Message-ID<Ku6dnV3M7K0MNmHLnZ2dnUU7-QPNnZ2d@giganews.com>
In reply to#2613
D Finnigan <dog_cow@macgui.com> wrote:
> alxmist wrote:
>> 
>> and how do I activate them either way? Do
>> the $C050's require a JSR?
>> 
> 
> No, you just reference the location with a load instruction. Use whichever
> (A,X, or Y) is convenient in your code.
> 
> Don't try to JMP or JSR to the soft switch location, because there's no
> valid instructions there for the 6502 to execute.
> 

An Apple II "softswitch" is actually neither data nor code. It is
memory-mapped I/O. 

A softswitch is "flipped" by simply referencing it with any memory
reference instruction. Since some instructions reference their effective
addresses more than once, simple LOADs, STOREs, and BITs are most commonly
used to flip softswitches. Also, some softswitches do different things
depending on whether they are read or written (LOADs and BITs or STOREs,
respectively). 

Many softswitches have an "on" address and an "off" address. 

A good starting point is the I/O address (softswitch) chart in the Apple II
Reference Manual describing the functions of addresses in the C000 to C07F
range. It shows what references to these addresses do, which is what you're
looking for. 

There are more complete lists describing softswitches introduced in later
models of the Apple II, but the graphics/text modes are well-described in
the original reference manual. 
-- 
-michael - NadaNet 3.1 and AppleCrate II:  http://michaeljmahon.com

[toc] | [prev] | [next] | [standalone]


#2629

Frommmphosis <mmphosis@macgui.com>
Date2016-03-31 16:07 +0000
Message-ID<mmphosis-1459440621@macgui.com>
In reply to#2613
D Finnigan wrote:
> Don't try to JMP or JSR to the soft switch location, because there's no
> valid instructions there for the 6502 to execute.

HGR2:HPLOT0,0:POKE28,96:CALL62454:CALL49233

[toc] | [prev] | [next] | [standalone]


#2619

FromMichael Pohoreski <michael.pohoreski@gmail.com>
Date2016-03-30 14:10 -0700
Message-ID<0f5df021-5367-4e35-8f42-d44f82b0ebdb@googlegroups.com>
In reply to#2612
On Wednesday, March 30, 2016 at 11:23:11 AM UTC-7, alx...@aol.com wrote:
> On Wednesday, March 30, 2016 at 1:58:43 PM UTC-4, Antoine Vignau wrote:
> > The ROM code in the $F800..$FFFF area uses the softswitches and are here to ease your life.
> > 
> > You can use the softswitches directly.
> 
> Okay. What are their addresses, and how do I activate them either way? Do the $C050's require a JSR?

Replace the phrase "soft switch" with the phase: "1 byte flag"

You can't execute flags, as there is NO CODE there, they are just DATA.

You can:

1. READ a flag, via one of available 6502 instructions:
    LDA $C050, or 
    BIT $C050
    LDA $C050,X
    LDA $C050,Y

2. STORE a value* to the flag, via one of the available 6502 instructions:
  STA $C050
  STX $C050
  STY $C050
  STA $C050,X
  STA $C050,Y
  etc.
 
(*) NOTE: Technically this value is *ignored*.  As long as this memory location is accessed, it will trigger the effect.

I would *highly recommend* you play around with setting the flags from the monitor (aka CALL-151 from Applesoft). Type in each line and wait to see what each flag does.

C051
C050

C053
C052

C055
C054

[toc] | [prev] | [next] | [standalone]


#2618

Fromgids.rs@sasktel.net
Date2016-03-30 13:06 -0700
Message-ID<09f2840f-3988-4542-89a5-e6e069ff193d@googlegroups.com>
In reply to#2610
On Wednesday, March 30, 2016 at 10:31:45 AM UTC-6, alx...@aol.com wrote:
> I don't understand. In "Apple II Graphics and Arcade Game Design" the author uses JSR $FB04 to activate the lo-res graphics. Are $C050-$C057 interchangeable?


Here is a ROM call chart with a list of ROM calls that should help you.

http://mirrors.apple2.org.za/ftp.apple.asimov.net/documentation/magazines/misc/theappleorchard_v1n1_applesoftinternalentrypoints_ocr.pdf

[toc] | [prev] | [next] | [standalone]


#2620

FromMichael Pohoreski <michael.pohoreski@gmail.com>
Date2016-03-30 14:13 -0700
Message-ID<f136d523-679d-48f9-88e1-fbd48e6dde2d@googlegroups.com>
In reply to#2618
On Wednesday, March 30, 2016 at 1:06:49 PM UTC-7, gid...@sasktel.net wrote:
> Here is a ROM call chart with a list of ROM calls that should help you.
> http://mirrors.apple2.org.za/ftp.apple.asimov.net/documentation/magazines/misc/theappleorchard_v1n1_applesoftinternalentrypoints_ocr.pdf

Oooh, I hadn't seen that chart before. Thanks for posting that!

Man, I wish I had that 20 years ago that would of have saved hours of reverse engineering!  Of course, the side effect, would have taken out some of the joy of self-discovery too. :-)

[toc] | [prev] | [next] | [standalone]


#2625

Fromgids.rs@sasktel.net
Date2016-03-31 08:25 -0700
Message-ID<385ac7a8-423a-4757-aa31-b8fa1a463a2c@googlegroups.com>
In reply to#2620
> Oooh, I hadn't seen that chart before. Thanks for posting that!
> 
> Man, I wish I had that 20 years ago that would of have saved hours of reverse engineering!  Of course, the side effect, would have taken out some of the joy of self-discovery too. :-)



It was just uploaded in 2011, so that's the earliest you could have got it.

Before then, everything was still a big secret.  And secrets were expensive.

I always figured the less self-discovery I have to do, the farther ahead I would have been.

Which means, someone else is doing all the work for me and not getting paid 
for it.

And with all the knowledge I have now, just means I owe so many people, so much money, in so little time.

:>)

[toc] | [prev] | [next] | [standalone]


#2627

Fromalxmist@aol.com
Date2016-03-31 08:52 -0700
Message-ID<7a3f3f10-d83a-4e1f-89c1-cb728a6f9ff6@googlegroups.com>
In reply to#2625
I tried running the following program:

HOME EQU $FC58
START JSR HOME
 LDA $C050 DISPLAY GRAPHICS
 LDA $C053 ENABLE GRAPHICS/MIXED
 LDA $C054 SELECT PAGE 1
 LDA $C056 SELECT LO-RES
 LDA $22
 STA $700
END RTS

But all I got was alternating lines of grey. :(

[toc] | [prev] | [next] | [standalone]


#2630

FromMichael J. Mahon <mjmahon@aol.com>
Date2016-03-31 11:30 -0500
Message-ID<zuadnTBlad8qzWDLnZ2dnUU7-RHNnZ2d@giganews.com>
In reply to#2627
<alxmist@aol.com> wrote:
> I tried running the following program:
> 
> HOME EQU $FC58
> START JSR HOME
>  LDA $C050 DISPLAY GRAPHICS
>  LDA $C053 ENABLE GRAPHICS/MIXED
>  LDA $C054 SELECT PAGE 1
>  LDA $C056 SELECT LO-RES
>  LDA $22
>  STA $700
> END RTS
> 
> But all I got was alternating lines of grey. :(
> 

Most of the display only reflects the previous contents of the text page.
Your code only changes one pair of pixels at $700. 

To see more, change more pixels in the text buffer, from $400..$7FF. 
-- 
-michael - NadaNet 3.1 and AppleCrate II:  http://michaeljmahon.com

[toc] | [prev] | [next] | [standalone]


#2635

FromMichael Pohoreski <michael.pohoreski@gmail.com>
Date2016-03-31 12:33 -0700
Message-ID<33edbbfa-420d-4d9a-b8ad-521cc8225ef6@googlegroups.com>
In reply to#2627
On Thursday, March 31, 2016 at 8:52:28 AM UTC-7, alx...@aol.com wrote:
> I tried running the following program:
> 
> HOME EQU $FC58
> START JSR HOME
>  LDA $C050 DISPLAY GRAPHICS
>  LDA $C053 ENABLE GRAPHICS/MIXED
>  LDA $C054 SELECT PAGE 1
>  LDA $C056 SELECT LO-RES
>  LDA $22
>  STA $700
> END RTS
> 
> But all I got was alternating lines of grey. :(

That's because you need to ZERO the (video) RAM.

HOME fill in the text page with $A0, you need $00 for black.
Each nibble is the TOP and BOTTOM color.

CAll-151
C050 C053 C054 C056
400:A0
400:00 
!
300: JSR $31A
 LDA $C050
 LDA $C053
 LDA $C054
 LDA $C056
 LDA $22
 STA $700
 LDA $C000
 BPL $314
 RTS
 LDA #0
 LDX #0
 STA $400,X
 STA $500,X
 STA $600,X
 STA $700,X
 INX
 BNE $31E
 RTS

300G

[toc] | [prev] | [next] | [standalone]


#2636

FromMichael Pohoreski <michael.pohoreski@gmail.com>
Date2016-03-31 12:59 -0700
Message-ID<99bfda5c-4aff-4396-a52e-6475253ba794@googlegroups.com>
In reply to#2635
Here is a description of how GR bytes are memory mapped:

400: pixel at column 0, rows 0 and 1
480: pixel at column 0, rows 2 and 3
7D0: pixel at column 0, rows rows 46 and 47
7F3: pixel at column 39, rows 46 and 47

If the byte is 'BT' then that corresponds to:

Row 0: pixel color=T
Row 1: pixel color=B

Since each nibble is 4-bits, that means each GR pixel can be one of the 16 colors: 0 .. F

i.e.

CALL-151
C050 C052 C054 C056
25:0
7D0:FF
7F7:FF

The reason you get alternating grey lines because HOME fills in the TEXT page with $A0.

400:A0

 --> Row 0: Color: 0 = black
 --> Row 1: Color: A = grey

I'd *highly* recommend reviewing:

Section: Copy text screen to HGR
Of my HGR Font Tutorial for the TEXT screen addresses.
https://github.com/Michaelangel007/apple2_hgr_font_tutorial#copy-text-screen-to-hgr

in addition to:

Clearing The Apple II Low-Resolution Graphics Screen
http://www.atarimagazines.com/compute/issue10/032_1_THE_APPLE_GAZETTE.php

[toc] | [prev] | [next] | [standalone]


#2640

FromMark Calderbank <noname@test.com>
Date2016-04-01 15:54 +0100
Message-ID<4me2tc-gmb.ln1@zoot.loggytronic.net>
In reply to#2635
Michael Pohoreski <michael.pohoreski@gmail.com> wrote:
> 
> That's because you need to ZERO the (video) RAM.
> 
> HOME fill in the text page with $A0, you need $00 for black.
> Each nibble is the TOP and BOTTOM color.
> 
> <snip>

> LDA #0
> LDX #0
> STA $400,X
> STA $500,X
> STA $600,X
> STA $700,X
> INX
> BNE $31E

I would recommend against overwriting the screen holes in text page 1,
which are reserved for use by expansion cards. For example:

    LDA #0
L:  LDX #$77
    STA $400,X
    STA $480,X
    STA $500,X
    STA $580,X
    STA $600,X
    STA $680,X
    STA $700,X
    STA $780,X
    DEX
    BPL L

[toc] | [prev] | [next] | [standalone]


#2642

FromMark Calderbank <mark@zoot.loggytronic.net>
Date2016-04-01 16:36 +0100
Message-ID<14h2tc-gmb.ln1@zoot.loggytronic.net>
In reply to#2640
Mark Calderbank <noname@test.com> wrote:
> Michael Pohoreski <michael.pohoreski@gmail.com> wrote:
>> 
>> That's because you need to ZERO the (video) RAM.
>> 
>> HOME fill in the text page with $A0, you need $00 for black.
>> Each nibble is the TOP and BOTTOM color.
>> 
>> <snip>
> 
>> LDA #0
>> LDX #0
>> STA $400,X
>> STA $500,X
>> STA $600,X
>> STA $700,X
>> INX
>> BNE $31E
> 
> I would recommend against overwriting the screen holes in text page 1,
> which are reserved for use by expansion cards. For example:
> 
>    LDA #0
> L:  LDX #$77
>    STA $400,X
>    STA $480,X
>    STA $500,X
>    STA $580,X
>    STA $600,X
>    STA $680,X
>    STA $700,X
>    STA $780,X
>    DEX
>    BPL L

[toc] | [prev] | [next] | [standalone]


Page 1 of 2  [1] 2  Next page →

Back to top | Article view | comp.sys.apple2.programmer


csiph-web