Apple2: Dynamic IIe check on a2_lo_tgi

This commit is contained in:
Colin Leroy-Mira
2025-05-28 08:40:51 +02:00
committed by Oliver Schmidt
parent a9ab23ad51
commit 0122307399
5 changed files with 36 additions and 32 deletions

View File

@@ -8526,11 +8526,10 @@ if the mode is not supported due to lack of hardware.
<ref id="pce.h" name="pce.h">/
<tag/Declaration/
<tt>void waitvsync (void);</tt><newline>
<tt>signed char waitvsync (void); /* For Apple II */</tt><newline>
<tag/Description/Wait for vertical sync, to reduce flickering.
<tag/Notes/<itemize>
<item>The function will return -1 when the feature is not supported,
like on the Apple&nbsp;&rsqb;&lsqb;+.
<item>The function will silently fail when the feature is not
supported, like on the Apple&nbsp;&rsqb;&lsqb;+.
</itemize>
<tag/Availability/Platforms served by the headers above
(Atmos requires the VSync hack)

View File

@@ -343,6 +343,9 @@ signed char __fastcall__ videomode (unsigned mode);
** installed. Call with one of the VIDEOMODE_xx constants.
*/
void waitvsync (void);
/* Wait for start of next frame */
/* End of apple2.h */

View File

@@ -63,16 +63,5 @@ extern void a2e_lo_tgi[];
/*****************************************************************************/
/* Code */
/*****************************************************************************/
void waitvsync (void);
/* Wait for start of next frame */
/* End of apple2enh.h */
#endif

View File

@@ -53,7 +53,7 @@ Y2 := ptr4
.byte $74, $67, $69 ; "tgi"
.byte TGI_API_VERSION ; TGI API version number
.addr $0000 ; Library reference
libref: .addr $0000 ; Library reference
.word 40 ; X resolution
.word 48 ; Y resolution
.byte 16 ; Number of drawing colors
@@ -93,6 +93,10 @@ Y2 := ptr4
ERROR: .res 1 ; Error code
MIX: .res 1 ; 4 lines of text
.ifndef __APPLE2ENH__
machinetype: .res 1
.endif
; ------------------------------------------------------------------------
.rodata
@@ -126,11 +130,15 @@ INIT:
bit $C082 ; Switch in ROM
jsr SETGR
bit MIXCLR
.ifdef __APPLE2ENH__
.ifndef __APPLE2ENH__
bit machinetype
bpl lc_in
.endif
sta IOUDISON
bit DHIRESOFF
.endif
bit $C080 ; Switch in LC bank 2 for R/O
lc_in: bit $C080 ; Switch in LC bank 2 for R/O
; Done, reset the error code
lda #TGI_ERR_OK
@@ -144,6 +152,16 @@ INIT:
; most of the time.
; Must set an error code: NO
INSTALL:
.ifndef __APPLE2ENH__
lda libref
ldx libref+1
sta ptr1
stx ptr1+1
ldy #$0
lda (ptr1),y
sta machinetype
bpl :+
.endif
; Fall through
; UNINSTALL routine. Is called before the driver is removed from memory. May

View File

@@ -13,31 +13,28 @@
.include "apple2.inc"
_waitvsync:
.ifndef __APPLE2ENH__
bit machinetype ; IIe/enh?
bpl out ; No, silently fail
.endif
bit ostype
bmi iigs ; $8x
bvs iic ; $4x
.ifndef __APPLE2ENH__
bit machinetype ; IIe/enh?
bmi :+
lda #$FF ; ][+ Unsupported
tax
rts
.endif
; Apple IIe
: bit RDVBLBAR
bpl :- ; Blanking
: bit RDVBLBAR
bmi :- ; Drawing
bpl out
rts
; Apple IIgs TechNote #40, VBL Signal
iigs: bit RDVBLBAR
bmi iigs ; Blanking
: bit RDVBLBAR
bpl :- ; Drawing
bmi out
rts
; Apple IIc TechNote #9, Detecting VBL
iic: php
@@ -53,6 +50,4 @@ iic: php
bit DISVBL
: sta IOUDISON ; IIc Tech Ref Man: The firmware normally leaves IOUDIS on.
plp
out: lda #$00
tax
rts
out: rts