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


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

Emulator Detection

Started by"Frank M." <frank_o_rama@hotmail.com>
First post2018-03-06 14:46 -0800
Last post2018-03-14 21:23 -0700
Articles 16 on this page of 56 — 14 participants

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


Contents

  Emulator Detection "Frank M." <frank_o_rama@hotmail.com> - 2018-03-06 14:46 -0800
    Re: Emulator Detection "Frank M." <frank_o_rama@hotmail.com> - 2018-03-06 19:03 -0800
      Re: Emulator Detection gids.rs@sasktel.net - 2018-03-07 01:07 -0800
        Re: Emulator Detection "Frank M." <frank_o_rama@hotmail.com> - 2018-03-07 07:18 -0800
          Re: Emulator Detection TomCh <tomcharlesworth26@gmail.com> - 2018-03-07 12:53 -0800
            Re: Emulator Detection "Frank M." <frank_o_rama@hotmail.com> - 2018-03-07 13:24 -0800
              Re: Emulator Detection Antoine Vignau <antoine.vignau@laposte.net> - 2018-03-08 04:42 -0800
                Re: Emulator Detection Tom Porter <laseractiveguy@gmail.com> - 2018-03-08 07:41 -0800
                  Re: Emulator Detection Tom Porter <laseractiveguy@gmail.com> - 2018-03-08 07:46 -0800
                    Re: Emulator Detection Tom Porter <laseractiveguy@gmail.com> - 2018-03-08 08:55 -0800
    Re: Emulator Detection Steve Nickolas <usotsuki@buric.co> - 2018-03-07 05:49 -0500
    Re: Emulator Detection Mark Pilgrim <markpilgrimfastmail@gmail.com> - 2018-03-08 10:21 -0800
      Re: Emulator Detection "Frank M." <frank_o_rama@hotmail.com> - 2018-03-08 22:41 -0800
        Re: Emulator Detection MG <michael@apps.guidero.us> - 2018-03-10 13:24 -0800
          Re: Emulator Detection Zellyn <zellyn@gmail.com> - 2018-03-11 14:21 -0700
      Re: Emulator Detection qkumba <peter.ferrie@gmail.com> - 2018-03-11 14:50 -0700
        Re: Emulator Detection "Frank M." <frank_o_rama@hotmail.com> - 2018-03-11 22:02 -0700
        Re: Emulator Detection TomCh <tomcharlesworth26@gmail.com> - 2018-03-12 13:25 -0700
    Re: Emulator Detection "Frank M." <frank_o_rama@hotmail.com> - 2018-03-11 22:19 -0700
      Re: Emulator Detection gids.rs@sasktel.net - 2018-03-12 10:17 -0700
        Re: Emulator Detection "Frank M." <frank_o_rama@hotmail.com> - 2018-03-12 11:11 -0700
          Re: Emulator Detection mmphosis <mmphosis@macgui.com> - 2018-03-12 22:37 +0000
          Re: Emulator Detection gids.rs@sasktel.net - 2018-03-12 17:03 -0700
            Re: Emulator Detection "Frank M." <frank_o_rama@hotmail.com> - 2018-03-12 17:27 -0700
              Re: Emulator Detection gids.rs@sasktel.net - 2018-03-12 17:39 -0700
                Re: Emulator Detection "Frank M." <frank_o_rama@hotmail.com> - 2018-03-12 20:02 -0700
                  Re: Emulator Detection gids.rs@sasktel.net - 2018-03-12 20:39 -0700
                    Re: Emulator Detection gids.rs@sasktel.net - 2018-03-12 20:40 -0700
                    Re: Emulator Detection "Frank M." <frank_o_rama@hotmail.com> - 2018-03-12 20:58 -0700
                      Re: Emulator Detection qkumba <peter.ferrie@gmail.com> - 2018-03-12 21:51 -0700
                        Re: Emulator Detection "Frank M." <frank_o_rama@hotmail.com> - 2018-03-13 18:45 -0700
                          Re: Emulator Detection gids.rs@sasktel.net - 2018-03-13 22:22 -0700
                            Re: Emulator Detection Antoine Vignau <antoine.vignau@laposte.net> - 2018-03-13 22:43 -0700
                              Re: Emulator Detection "Frank M." <frank_o_rama@hotmail.com> - 2018-03-14 00:08 -0700
                                Re: Emulator Detection Antoine Vignau <antoine.vignau@laposte.net> - 2018-03-14 00:30 -0700
                                  Re: Emulator Detection "Frank M." <frank_o_rama@hotmail.com> - 2018-03-14 08:38 -0700
                          Re: Emulator Detection Zellyn <zellyn@gmail.com> - 2018-03-14 09:03 -0700
                            Re: Emulator Detection Antoine Vignau <antoine.vignau@laposte.net> - 2018-03-14 13:58 -0700
                              Re: Emulator Detection Zellyn <zellyn@gmail.com> - 2018-03-15 06:11 -0700
          Re: Emulator Detection Michael Pohoreski <michael.pohoreski@gmail.com> - 2018-03-12 21:55 -0700
            Re: Emulator Detection Antoine Vignau <antoine.vignau@laposte.net> - 2018-03-12 22:50 -0700
        Re: Emulator Detection Zellyn <zellyn@gmail.com> - 2018-03-12 13:40 -0700
    Re: Emulator Detection "Frank M." <frank_o_rama@hotmail.com> - 2018-03-14 08:42 -0700
      Re: Emulator Detection Antoine Vignau <antoine.vignau@laposte.net> - 2018-03-14 13:57 -0700
        Re: Emulator Detection "Frank M." <frank_o_rama@hotmail.com> - 2018-03-14 21:07 -0700
          Re: Emulator Detection Antoine Vignau <antoine.vignau@laposte.net> - 2018-03-15 14:56 -0700
            Re: Emulator Detection "Frank M." <frank_o_rama@hotmail.com> - 2018-03-16 20:49 -0700
              Re: Emulator Detection Antoine Vignau <antoine.vignau@laposte.net> - 2018-03-16 22:20 -0700
                Re: Emulator Detection "Frank M." <frank_o_rama@hotmail.com> - 2018-03-16 22:24 -0700
                  Re: Emulator Detection Antoine Vignau <antoine.vignau@laposte.net> - 2018-03-17 02:32 -0700
                    Re: Emulator Detection "Frank M." <frank_o_rama@hotmail.com> - 2018-03-17 08:09 -0700
                      Re: Emulator Detection Michael J. Mahon <mjmahon@aol.com> - 2018-03-17 17:01 -0500
                        Re: Emulator Detection Antoine Vignau <antoine.vignau@laposte.net> - 2018-04-28 02:44 -0700
                          Re: Emulator Detection John Brooks <jbrooks@blueshiftinc.com> - 2018-04-28 22:01 -0700
                            Re: Emulator Detection Antoine Vignau <antoine.vignau@laposte.net> - 2018-04-29 08:16 -0700
    Re: Emulator Detection "Frank M." <frank_o_rama@hotmail.com> - 2018-03-14 21:23 -0700

Page 3 of 3 — ← Prev page 1 2 [3]


#4334

FromAntoine Vignau <antoine.vignau@laposte.net>
Date2018-03-12 22:50 -0700
Message-ID<b7556a93-5349-4932-8403-c957119ef4e0@googlegroups.com>
In reply to#4333
Zellyn: thank you. Your message is 100% true and that is what I have in mind.

av

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


#4323

FromZellyn <zellyn@gmail.com>
Date2018-03-12 13:40 -0700
Message-ID<f7b4e075-8c15-4ab5-b14c-d7a4fa19f0b2@googlegroups.com>
In reply to#4320
On Monday, March 12, 2018 at 1:17:46 PM UTC-4, gid...@sasktel.net wrote:
> Detecting emulators would be kind of redundant unless every little idiosyncracy
> is logged for every problem that happens within each emulator.
> 
> Is there a plan to use this code for work-arounds in certain emulators?

I like following emulator detection discussions, because each place you can detect an emulator shows an infidelity in the emulator.

Zellyn

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


#4345

From"Frank M." <frank_o_rama@hotmail.com>
Date2018-03-14 08:42 -0700
Message-ID<86dc1e76-62ae-4670-ab37-1780cb8ad74e@googlegroups.com>
In reply to#4287
Found it. $FE1F returns the ROM version in register X.
f

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


#4350

FromAntoine Vignau <antoine.vignau@laposte.net>
Date2018-03-14 13:57 -0700
Message-ID<9cef29c2-3d56-4864-be7c-161a83f83090@googlegroups.com>
In reply to#4345
On Wednesday, March 14, 2018 at 4:42:46 PM UTC+1, Frank M. wrote:
> Found it. $FE1F returns the ROM version in register X.
> f

It is in Y ;-)
If ROM 1 in Y, JSR $F962 and you'll be done...

---

*
* This routine installs a heartbeat task
* that copies text page 2 to bank E0 for
* the Mega // to display on every VBL.
*
* This is a toggle (enable/disable) routine.
* If auto text copy is on, on entry, it is disabled on exit.
* If auto text copy is off, on entry, it is enabled on exit.
*
* For Gyro, no heart beat task is required.
* Toggle hardware bit5 of shadow register, $c035 
* is equivalent to software copying.
*
* This routine can be invoked from Classic Desk Accessory
* or mainside entry point $f962. In the case of CDA, an      
* interrupt occurred and the enviroments are stored and restored
* during in and out of the CDA, this includes store and restore of
* SHADOW reg, therefore it is necessay to update IRQ_SHADOW to   
* reflect the most current states of shadowing.  When exits, then
* restoring of SHADOW reg from IRQ_SHADOW would show the users'
* preference states.

TEXT2COPYFF	EQU	*	;Entry from $f962 also !!!   
		IF IS512 <> 0 THEN
		ELSE
		PHB		;Save data bank
		JSR	DBTOE1	;Change to $e1
		LDA	|TP2MODE	;Toggle the flag
		EOR	#$FF	;
		STA	|TP2MODE	;Save back, 0/1 = off/on
		JSR	SETTEXT2REG	;
		BCC	@1	;BRA for //gs
		PLB		;Restore data bank
		RTS		;


@1		EQU	*	;//gs uses software copy !!!
		PLB		;Restore its data bank
		SEP	#$40	;Set 'v' to indicate enabling routine
		CLC		;Make call in full native mode
		XCE		;
		PHP		;Preserve entry status
		REP	#$30	;16 bit land required
		OPCODE	BVC	;Do a trick to save a byte
@2		EQU	*
		CLV		;Skipped first time through this code
		PEA	TP2THDR>>16	;High word of routine address
		PEA	|TP2THDR	;Low word of routine address
		LONGI	ON
		LDX	#SETHEART	;Set up heartbeat task
		BVS	@14	;'v'=1 then put in heartbeat queue
		LDX	#DELHEART	;Remove from heartbeat task
		LONGI	OFF
@14		EQU	*	;'v'=0=disable 'v'=1=enable routine
		JSL	>DISPATCH1	;Off to tool locator
		BCS	@2	;Already on then disable txt pg 2 copier
		PLP		;Recall entry status (8 bit mode)  
		LDA	#$08	;Enable VBL's to start up copier
		TSB	INTEN	;
		XCE		;Switch back to entry state now
		ENDIF
		RTS		;Back to caller

---

* Identification bytes for CORTLAND
*
* REGIDz's are return'ed when the user JSR's to $FE1F.
*
* REGIDA = Bit 15 = reserved
*          Bit 14 = reserved
*          Bit 13 = reserved
*          Bit 12 = reserved
*          Bit 11 = reserved
*          Bit 10 = reserved
*          Bit 09 = reserved
*          Bit 08 = reserved
*          Bit 07 = reserved
*          Bit 06 = 1 if system has a memory expansion slot
*          Bit 05 = 1 if system has an IWM port
*          Bit 04 = 1 if system has a built in clock
*          Bit 03 = 1 if system has front desk bus
*          Bit 02 = 1 if system has SCC built in
*          Bit 01 = 1 if system has external slots
*          Bit 00 = 1 if system has internal slots
*
* REGIDX = Bit 15 = reserved
*          Bit 14 = reserved
*          Bit 13 = reserved
*          Bit 12 = reserved
*          Bit 11 = reserved
*          Bit 10 = reserved
*          Bit 09 = reserved
*          Bit 08 = reserved
*          Bit 07 = reserved
*          Bit 06 = reserved
*          Bit 05 = reserved
*          Bit 04 = reserved
*          Bit 03 = reserved
*          Bit 02 = reserved
*          Bit 01 = reserved
*          Bit 00 = reserved
*
* REGIDY = Bit 15-8 = machine id byte
*                  0 = Cortland
*                  01-FF = future systems
*          Bit 07 = 0
*          Bit 06 = 0
*          Bit 05 = 0
*          Bit 04 = 0         Bits 00-07 = ROM version number
*          Bit 03 = 0
*          Bit 02 = 0
*          Bit 01 = 0
*          Bit 00 = 1   

REGIDA		DC.W	$007F	;Register identification byte
REGIDX		DC.W	$0000	;Register identification byte
REGIDY		DC.W	$0003	;Register identification byte 

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


#4352

From"Frank M." <frank_o_rama@hotmail.com>
Date2018-03-14 21:07 -0700
Message-ID<72ac75fb-5bbd-4936-bfde-b3c767896fea@googlegroups.com>
In reply to#4350
I did some further testing, and it looks like the page flipping problem under //gs is with Sweet16 and not actual hardware. Also, Sweet16 on my mac is running with a ROM 03 setup so I don't think it's the ROM 01 issue (I also set the CDA to "Alternate"--didn't work). I'm still seeing problems with page 2 display (alternating bands of black and white on the AUX memory sections). It plays double-lores page 1 fine, but requires starting playback on page 1 which causes problems with control-reset handling, and playback on actual hardware. The first frame then shows "combing" because page 1 is active as it's being loaded to page 1. Otherwise I have to code in a workaround just for Sweet16.

Antoine, it looks like this $F962 routine only switches settings back and forth. Is there any way to test which mode is currently active?

Starting to see how cross-][-line compatibility (and making sure it all works on every single emulator) can be a headache.

F

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


#4356

FromAntoine Vignau <antoine.vignau@laposte.net>
Date2018-03-15 14:56 -0700
Message-ID<88ac3f5f-a278-4366-a469-f956cb337897@googlegroups.com>
In reply to#4352
Test on real hardware ;-)

On Thursday, March 15, 2018 at 5:07:46 AM UTC+1, Frank M. wrote:
>... 
> Antoine, it looks like this $F962 routine only switches settings back and forth. Is there any way to test which mode is currently active?
> 
> Starting to see how cross-][-line compatibility (and making sure it all works on every single emulator) can be a headache.
> 
> F

I don't think so, I've followed the source code from the CDA to the heartbeat handler and I saw no flag to know which mode is active (there may be ways but the code would be long...)

		TITLE	'Some Stuff Called/Used by Desk Acc'

* TP2TASK is called by the heartbeat task scheduler
* to move text page 2 from bank 00 to bank E1.

	; SEG $FF
TP2TASK		EQU	*	;Task to copy text page 2 to bank E0
	; SEG $00
		LDA	#$01	;Reset task counter
		STA	>TP2TCNT	;Low byte is sufficient
		LONGA	ON
		LONGI	ON
		REP	#$30	;16 bit land required for routine
		LDX	#$0800	;Starting address of move in source bank
		TXY		;Starting addr of move in destination bank
		LDA	#$0400-1	;Number of bytes to move-1
		MVN	$000000,$E00000	;Source,destination banks
		LONGI	OFF
		LONGA	OFF
		RTL		;Back to heartbeat handler with task done

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


#4361

From"Frank M." <frank_o_rama@hotmail.com>
Date2018-03-16 20:49 -0700
Message-ID<24c9db9c-4ea5-49dc-881f-70a83b6050f1@googlegroups.com>
In reply to#4356
Would calling this routine after every frame load to page 2 on a ROM 01 //gs solve the page 2 playback issue there? What's the address TP2TASK is located and can it be called directly to do one bank swap?

F

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


#4363

FromAntoine Vignau <antoine.vignau@laposte.net>
Date2018-03-16 22:20 -0700
Message-ID<b98bf4ad-1ccd-4f31-88d7-8b10e4dea7fa@googlegroups.com>
In reply to#4361
not needed, the //gs puts a background task and does the refresh for you

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


#4364

From"Frank M." <frank_o_rama@hotmail.com>
Date2018-03-16 22:24 -0700
Message-ID<d0065e32-27be-49aa-af52-c871b83957f5@googlegroups.com>
In reply to#4363
I'd rather do the refresh myself, since I can't know if it's actually turned on or not.
f

On Friday, March 16, 2018 at 10:20:36 PM UTC-7, Antoine Vignau wrote:
> not needed, the //gs puts a background task and does the refresh for you

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


#4365

FromAntoine Vignau <antoine.vignau@laposte.net>
Date2018-03-17 02:32 -0700
Message-ID<d1dea22e-d14b-40bc-aba6-32ef184ecb18@googlegroups.com>
In reply to#4364
On Saturday, March 17, 2018 at 6:24:40 AM UTC+1, Frank M. wrote:
> I'd rather do the refresh myself, since I can't know if it's actually turned on or not.
> f
> 
> On Friday, March 16, 2018 at 10:20:36 PM UTC-7, Antoine Vignau wrote:
> > not needed, the //gs puts a background task and does the refresh for you

By default, it is turned off.
The source code shows the usage of a flag but it is not in the ROM code, so you'll either have:
- to handle the flag yourself,
- browse through the list of installed handlers and compare pointers.

If you had a ROM 3, where the hardware bug was removed, you could use the $C035 softswitch to know the status.

Antoine

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


#4370

From"Frank M." <frank_o_rama@hotmail.com>
Date2018-03-17 08:09 -0700
Message-ID<b6a39e3f-e6a6-4782-8603-f3d60b9ef017@googlegroups.com>
In reply to#4365
If I had a ROM 3 I wouldn't need to know the status.  :p

Maybe I'll just print a message to turn it on using the CDA if I detect a ROM 1, since I can't know if it's on or off.

f


On Saturday, March 17, 2018 at 2:32:32 AM UTC-7, Antoine Vignau wrote:
> On Saturday, March 17, 2018 at 6:24:40 AM UTC+1, Frank M. wrote:
> > I'd rather do the refresh myself, since I can't know if it's actually turned on or not.
> > f
> > 
> > On Friday, March 16, 2018 at 10:20:36 PM UTC-7, Antoine Vignau wrote:
> > > not needed, the //gs puts a background task and does the refresh for you
> 
> By default, it is turned off.
> The source code shows the usage of a flag but it is not in the ROM code, so you'll either have:
> - to handle the flag yourself,
> - browse through the list of installed handlers and compare pointers.
> 
> If you had a ROM 3, where the hardware bug was removed, you could use the $C035 softswitch to know the status.
> 
> Antoine

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


#4371

FromMichael J. Mahon <mjmahon@aol.com>
Date2018-03-17 17:01 -0500
Message-ID<uvCdnTsMlbivDTDHnZ2dnUU7-IXNnZ2d@giganews.com>
In reply to#4370
Frank M. <frank_o_rama@hotmail.com> wrote:
> 
> If I had a ROM 3 I wouldn't need to know the status.  :p
> 
> Maybe I'll just print a message to turn it on using the CDA if I detect a
> ROM 1, since I can't know if it's on or off.

Or you could just unconditionally turn it on!

-michael


> f
> 
> 
> On Saturday, March 17, 2018 at 2:32:32 AM UTC-7, Antoine Vignau wrote:
>> On Saturday, March 17, 2018 at 6:24:40 AM UTC+1, Frank M. wrote:
>>> I'd rather do the refresh myself, since I can't know if it's actually turned on or not.
>>> f
>>> 
>>> On Friday, March 16, 2018 at 10:20:36 PM UTC-7, Antoine Vignau wrote:
>>>> not needed, the //gs puts a background task and does the refresh for you
>> 
>> By default, it is turned off.
>> The source code shows the usage of a flag but it is not in the ROM code,
>> so you'll either have:
>> - to handle the flag yourself,
>> - browse through the list of installed handlers and compare pointers.
>> 
>> If you had a ROM 3, where the hardware bug was removed, you could use
>> the $C035 softswitch to know the status.
>> 
>> Antoine
> 
> 



-- 
-michael - NadaNet 3.1 and AppleCrate II:  http://michaeljmahon.com

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


#4536

FromAntoine Vignau <antoine.vignau@laposte.net>
Date2018-04-28 02:44 -0700
Message-ID<54bff5da-3330-41bb-a0b3-fc27265e61b8@googlegroups.com>
In reply to#4371
Re-activating the beast.

Date: May 15, 1986
Author: Fern Bachman
Subject: Cortland Monitor ERS
Document Version Number: 00:70

Page #40
12. Text Page 2 Shadowing

Cortland has hardware shadowing for all video screens except page 2. [..]
$F962 is a toggle routine. Call it from BASIC or machine language. Each time is called it changes it's (sic) current state. [..]

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


#4537

FromJohn Brooks <jbrooks@blueshiftinc.com>
Date2018-04-28 22:01 -0700
Message-ID<c43a5895-631f-45c8-96dc-84ef4cc1f4c0@googlegroups.com>
In reply to#4536
On Saturday, April 28, 2018 at 2:44:08 AM UTC-7, Antoine Vignau wrote:
> Re-activating the beast.
> 
> Date: May 15, 1986
> Author: Fern Bachman
> Subject: Cortland Monitor ERS
> Document Version Number: 00:70
> 
> Page #40
> 12. Text Page 2 Shadowing
> 
> Cortland has hardware shadowing for all video screens except page 2. [..]
> $F962 is a toggle routine. Call it from BASIC or machine language. Each time is called it changes it's (sic) current state. [..]

All GS motherboards have global hardware shadowing for all video frame buffers which is much better/faster than the slow IRQ-based CDA (Alternate Display Mode) IMO.

ROM 3 does have an extra shadow enable/disable hardware mode specifically for text page 2. This is nice, but since it's not available on ROM 0/1, I prefer to use $C036 bit 4 which works on all motherboards, and generally requires enabling & disabling around the print/draw code to avoid shadow-stomping system-use parts of bank $E0/$E1.

-JB
@JBrooksBSI

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


#4538

FromAntoine Vignau <antoine.vignau@laposte.net>
Date2018-04-29 08:16 -0700
Message-ID<15ebaaf7-7fc3-442d-810f-f7092eaade10@googlegroups.com>
In reply to#4537
> All GS motherboards have global hardware shadowing for all video frame buffers which is much better/faster than the slow IRQ-based CDA (Alternate Display Mode) IMO.
> 
> ROM 3 does have an extra shadow enable/disable hardware mode specifically for text page 2. This is nice, but since it's not available on ROM 0/1, I prefer to use $C036 bit 4 which works on all motherboards, and generally requires enabling & disabling around the print/draw code to avoid shadow-stomping system-use parts of bank $E0/$E1.
> 
> -JB
> @JBrooksBSI

Please share code! Using bit 4 of CYAREG is "dangerous" as it enables shadowing from all RAM banks to $E0/$E1.

av

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


#4353

From"Frank M." <frank_o_rama@hotmail.com>
Date2018-03-14 21:23 -0700
Message-ID<254e98d1-4102-4491-8dfc-a5b08c55cc49@googlegroups.com>
In reply to#4287
Anyway, here's the latest source showing the emulator testing and //gs-sensing routines. This version flips pages 1 and 2, but I have another which just shows page 1 and waits for VBL on "bad emulators" like Sweet16. Unfortunately, that version has a couple issues on "good emulators" and actual hardware since it starts showing page 1 while it's being loaded (required on Sweet16 since page 2 is off-limits).
f



 ;
 ; PLAY.DGR.S
 ; Play Double-lores (DGR) Video File
 ; hacked together by Frank Milliron
 ; March 14, 2018
 ; (Code can be pasted into Merlin Pro 2.33)
 ;
 ORG $C00 ; CALL 3072
****************************************************************
*                    Initialize Everything                     *
****************************************************************
SETUP JSR EMUTEST ; Run emulator test for Virtual ][ / Sweet16
 JSR TESTGS ; If we're on a GS, fix a couple things
 JSR $1100 ; Initialize ProRWTS2 (relocates itself to $1000)
 STA $C005 ; Enable write to AUX
COPYPRO LDA $1000,Y ; Y is set by init
 STA $1000,Y ; Copy ProRWTS2 to AUX
 INY
 BNE COPYPRO
 STA $C004 ; Restore write to MAIN
 LDA #$00
 STA $57 ; $0300 namlo - name of file to access
 STA $52 ; $0400 sizelo - size of the data to load (always $00)
 STA $55 ; $0400/0800 ldrlo - address to load the data (always $00)
 STA $51 ; auxreq - set load to MAIN
 LDA #$03
 STA $58 ; $0300 namhi - name of file to access
 LDA #$08
 STA $56 ; $0400/0800 ldrhi - address to load the data (start $800)
 LSR ; same as LDA #$04
 STA $53 ; $0400 sizehi - size of the initial data to load
 LDA #$01
 STA $54 ; Set reqcmd to #cmdread (1)
 JSR GRFX ; Setup graphics/memory modes
SETRESET LDA #<DORESET ; Change reset vector to DORESET
 STA $03F2 ; low byte
 LDA #>DORESET-1
 STA $03F3 ; high byte
 JSR $FB6F ; Set valid power-up byte based on reset vector
 JSR $1003 ; hddopendir (also sets up cache structures)
 STA $C005 ; Enable write to AUX
COPYTREE LDA $1300,X ; X is set by hddopendir
 STA $1300,X
 LDA $1400,X
 STA $1400,X ; Copy ProRWTS2 tree buffer to AUX
 INX
 BNE COPYTREE
ADJUST STA $C005 ; Enable write to AUX, ProRWTS2 will restore it
COPYBLK LDA $1100,X
 STA $1100,X
 LDA $1200,X
 STA $1200,X ; Copy ProRWTS2 block buffer to AUX
 INX
 BNE COPYBLK
 BEQ RESUME
****************************************************************
*                    Main Playback Routine                     *
****************************************************************
PLAY LDA #$00 ; set load to MAIN
 STA $51 ; auxreq
 LDA #$04
 STA $53 ; $0400 sizehi - size of the data to load
 JSR $1000 ; hddrdwrpart - initial load to $400 main then $400 aux
 BCS EXIT1 ; Quit at end of file
 LDA $F8 ; Check block index
 CMP #2 ; Watch for 64kb wrap-around
 BEQ ADJUST
RESUME LDA #$01 ; set load to AUX
 STA $51 ; auxreq
 LDA #$04
 STA $53 ; $0400 sizehi - size of the data to load
 JSR $1000 ; hddrdwrpart - initial load to $400 main then $400 aux
SOFTSW EQU *+1 ; This instruction patched if we find an emulator
 BIT $C055 ; Start showing Page 1 (self-modifying!)
 LDA SOFTSW
 EOR #1 ; Alternate displaying $400/$800
 STA SOFTSW
 LDA $56 ; ldrhi - address to load the data
 EOR #$0C ; Alternate loading to $400/$800
 STA $56 ; ldrhi
CHKKEY LDA $C000 ; Check for keypress
 BPL PLAY ; none!
 JMP KEY ; handle keypresses
EXIT1 JMP EXIT ; BCS can only jump +127 or -128 bytes
****************************************************************
*                       Keypress Handler                       *
****************************************************************
KEY BIT $C010 ; Clear keyboard strobe
*
REW CMP #$88 ; Left arrow key pressed? ($08+80)
 BNE FASTF ; No, check next key
REW1 LDX $F6 ; treeidx
 BEQ PLAY ; if treeidx is already 0 don't rewind
 DEX
 BEQ REW2 ; if it's 1, decrement 1
 DEX ; Otherwise decrement 2
REW2 STX $F6
 JMP DORESET1 ; Restart playback using reset routine
*
FASTF CMP #$95 ; Right arrow key pressed? ($15+80)
 BNE PAUSE ; No, check next key
FASTF1 INC $F6 ; Increment treeidx
 JMP DORESET1 ; Restart playback using reset routine
*
PAUSE CMP #$A0 ; Space Bar pressed? ($20+80)
 BNE LORES ; No, check next key
* Pause screen display setup here?
* Second pause screen keypress handler here?
PAUSELP LDA $C000 ; Check for keypress
 BPL PAUSELP ;nothing yet
 CMP #$A0 ; Space Bar pressed again? ($20+80)?
 BNE PAUSELP ; if not, keep waiting
PAUSELP1 BIT $C010 ; Clear keyboard strobe
 JMP PLAY
*
LORES CMP #$B1 ; "1" key pressed? ($31+80)
 BNE DLORES ; No, check next key
LORES1 BIT $C05F ; Turn off Double-Lores Mode
 JMP PLAY ; Load next frame
*
DLORES CMP #$B2 ; "2" key pressed? ($32+80)
 BNE ESC ; No, check next key
DLORES1 BIT $C05E ; Turn on Double-Lores Mode
 JMP PLAY ; Load next frame
*
ESC CMP #$9B ; Escape key pressed? ($1B+80)
 BEQ EXIT2
 JMP PLAY ; No, do next frame
EXIT2 JMP EXIT ; BCS can only jump +127 or -128 bytes
****************************************************************
*                      Set Graphics Modes                      *
****************************************************************
 ; Assume we are starting with page 1 active (restart/reset)
GRFX STA $C000 ; Let $C054/C055 change page 1/2
 STA $C010 ; Clear keyboard strobe
 STA $C00D ; Set 80-col softswitch
 STA $C050 ; Turn on Graphics Mode
 STA $C052 ; Turn on Full Screen Mode
 STA $C056 ; Turn on Lores Graphics Mode
 STA $C05E ; Turn on Double-Lores Mode
 RTS
****************************************************************
*                    Control-Reset Handler                     *
****************************************************************
 ; Also used to restart playback on REW/FF
DORESET JSR TESTGS ; Re-test for //gs border color and speed
 JSR GRFX ; On reset, re-setup graphics modes
 LDA $F6 ; treeidx
 BEQ DORESET1 ; Already at the beginning, don't adjust
 DEC $F6 ; treeidx - play last section again
DORESET1 LDA #$00 ; set load to MAIN
 STA $51 ; auxreq
 STA $F8 ; Clear entries
 LDA #$04
 STA $53 ; $0400 sizehi - size of the data to load
 JSR $1000 ; hddrdwrpart (to main)
 BCS EXIT3 ; Quit at end of file
 JMP ADJUST ; To sync the aux side and resume playing
EXIT3 JMP EXIT ; BCS can only jump +127 or -128 bytes
****************************************************************
*                  Emulator-specific Routines                  *
****************************************************************
 ; Fixes for Virtual ][ and Sweet16 playback problems
EMUTEST LDX #$FF ; Test floating bus 255 times
 LDA #$00
 STA $FF ; Zero out test variable at zero-page $FF
EMU1 STA $C04F ; Tickle Sweet 16
 LDA $C04F ; Load value from bus
 CMP #$00 ; Likely it's Virtual ][? (always returns zero)
 BEQ EMU3
 CMP #$16 ; Likely it's Sweet16? (returns $16 when tickled)
 BEQ EMU3
EMU2 DEX ; Decrement test count
 CPX #$00
 BEQ EMU4 ; Done with 255 tests yet?
 JMP EMU1 ; If not, keep going
EMU3 INC $FF ; Found potential emulator, increment found count
 JMP EMU2
EMU4 LDA $FF ; Load found counts
 CMP #$FF ; 255 tests of 255 runs positive for emulation?
 BEQ EMUFIX ; If yes, patch the code
 RTS ; Otherwise, just exit. We're on "normal" "hardware".
EMUFIX LDA #$4C
 STA SOFTSW-1 ; 4C = JMP instruction
 LDA #<EMUWAIT ; set branch from normal playback routine
 STA SOFTSW ; during page flipping operations
 LDA #>EMUWAIT-1 ; (which emulators can't display properly)
 STA SOFTSW+1 ; to slightly revised EMUWAIT routine.
 LDA #$02 ; number of times to wait
 STA $FF ; playback speed variable
 RTS
EMUWAIT LDX $FF ; Wait for 3 vertical blank periods (22.5fps)
]LRP BIT $C019 ; Wait for next VBLANK period (every 1/60th sec)
 BPL ]LRP
]LP BIT $C019 ; VBLANK happening?
 BMI ]LP
 DEX
 BPL ]LRP ; Do it twice without page flipping
SOFTSW1 EQU *+1 ; Flip page 1 and 2
 BIT $C055 ; Start showing Page 2 (self-modifying!)
 LDA SOFTSW1
 EOR #1 ; Alternate displaying $400/$800
 STA SOFTSW1
 LDA $56 ; ldrhi - address to load the data
 EOR #$0C ; Alternate loading to $400/$800
 STA $56 ; ldrhi
 JMP CHKKEY ; Resume playback using PLAY after keypress check
****************************************************************
*                    //gs-specific routines                    *
****************************************************************
TESTGS SEC
 JSR $FE1F ; Does RTS on //e, clears carry on //gs (ROM ver in Y)
 BCC GSROM1 ; If we have a //gs, test for ROM1
 CLC
 RTS ; Not a //gs, just exit
GSROM1 CPY #$01 ; Are we on a ROM 01 //gs?
 BEQ ALTDISP ; If so, turn on Alternate Display Mode
 JMP SETGS
ALTDISP JMP $F962 ; Turn on Alternate Display Mode
SETGS LDA #$00
 STA $C034 ; If we're on a //gs, turn border color black
 LDA $C036 ; Read Speed register (bit 7 is speed control)
 ORA #%10000000 ; Force bit 7 on (fast speed)
 EOR #%10000000 ; now turn it off (normal speed)
 STA $C036 ; Set processor speed to normal
 RTS
****************************************************************
*                           Goodbye!                           *
****************************************************************
EXIT STA $C004 ; Restore write to MAIN
 STA $C010 ; Clear keyboard strobe
 STA $C00C ; Clear 80-col softswitch
 STA $C000 ; Turn off AUX memory mode
 STA $C05F ; Turn off Double-Lores Mode
 JSR $FB2F ; Set TEXT mode
 JSR $FC58 ; Clear screen (HOME)
 INC $03F4 ; Invalidate reset vector
 JSR $BF00 ; Exit using ProDOS QUIT
 DFB $65 ;CALL TYPE = QUIT
 DW PARMTABLE ;Pointer to parameter table
PARMTABLE DFB 4 ;Number of parameters is 4
 ; None of the parameters are actually used

[toc] | [prev] | [standalone]


Page 3 of 3 — ← Prev page 1 2 [3]

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


csiph-web