Added waitvsync() for the Enhanced Apple //e.
The implementation is a bit tricky as it requires to take different code paths for the //e, the //c and the IIgs. Additionally the //c only provides a VBL IRQ flag supposed to be used by an IRQ handler to determine what triggered the IRQ. However, masking IRQs on the CPU, activating the VBL IRQ, clearing any pending VBL IRQs and then polling for the IRQ flag does the trick.
This commit is contained in:
parent
baa5d051e4
commit
37107174c6
5 changed files with 88 additions and 20 deletions
|
@ -1,6 +1,6 @@
|
|||
|
||||
;-----------------------------------------------------------------------------
|
||||
; Zero page stuff
|
||||
; Zero page
|
||||
|
||||
WNDLFT := $20 ; Text window left
|
||||
WNDWDTH := $21 ; Text window width
|
||||
|
@ -31,35 +31,41 @@ PWREDUP := $03F4 ; This must be = EOR #$A5 of SOFTEV+1
|
|||
KBD := $C000 ; Read keyboard
|
||||
KBDSTRB := $C010 ; Clear keyboard strobe
|
||||
|
||||
; 80 column video switches
|
||||
; 80 column video
|
||||
CLR80COL:= $C000 ; Disable 80 column store
|
||||
SET80COL:= $C001 ; Enable 80 column store
|
||||
RD80COL := $C018 ; >127 if 80 column store enabled
|
||||
RD80VID := $C01F ; >127 if 80 column video enabled
|
||||
|
||||
; Character set switches
|
||||
; Character set
|
||||
CLRALTCHAR := $C00E ; Normal Apple II char set
|
||||
SETALTCHAR := $C00F ; Norm/inv LC, no flash
|
||||
ALTCHARSET := $C01E ; >127 if alt charset switched in
|
||||
|
||||
; Language card switches
|
||||
; Language card
|
||||
RDLCBNK2:= $C011 ; >127 if LC bank 2 in use
|
||||
RDLCRAM := $C012 ; >127 if LC is read enabled
|
||||
ROMIN := $C081 ; Swap in D000-FFFF ROM
|
||||
LCBANK2 := $C083 ; Swap in LC bank 2
|
||||
LCBANK1 := $C08B ; Swap in LC bank 1
|
||||
|
||||
; Video mode switches
|
||||
TXTCLR := $C050 ; Display graphics
|
||||
TXTSET := $C051 ; Display text
|
||||
MIXCLR := $C052 ; Disable 4 lines of text
|
||||
MIXSET := $C053 ; Enable 4 lines of text
|
||||
LOWSCR := $C054 ; Page 1
|
||||
HISCR := $C055 ; Page 2
|
||||
LORES := $C056 ; Lores graphics
|
||||
HIRES := $C057 ; Hires graphics
|
||||
DHIRESON := $C05E ; Enable double-width graphics
|
||||
DHIRESOFF := $C05F ; Disable double-width graphics
|
||||
; Vertical blanking
|
||||
RDVBLBAR := $C019 ; >127 if not vertical blanking
|
||||
RDVBLMSK := $C041 ; >127 if VBL interrupts enabled
|
||||
DISVBL := $C05A ; Disable VBL interrupts
|
||||
ENVBL := $C05B ; Enable VBL interrupts
|
||||
|
||||
; Video mode
|
||||
TXTCLR := $C050 ; Display graphics
|
||||
TXTSET := $C051 ; Display text
|
||||
MIXCLR := $C052 ; Disable 4 lines of text
|
||||
MIXSET := $C053 ; Enable 4 lines of text
|
||||
LOWSCR := $C054 ; Page 1
|
||||
HISCR := $C055 ; Page 2
|
||||
LORES := $C056 ; Lores graphics
|
||||
HIRES := $C057 ; Hires graphics
|
||||
DHIRESON := $C05E ; Enable double-width graphics
|
||||
DHIRESOFF := $C05F ; Disable double-width graphics
|
||||
|
||||
; Game controller
|
||||
TAPEIN := $C060 ; Read casette input / Switch input 3
|
||||
|
@ -73,8 +79,8 @@ PADDL3 := $C067 ; Analog input 3
|
|||
PTRIG := $C070 ; Analog input reset
|
||||
|
||||
; Input/Output Unit
|
||||
IOUDISON := $C07E ; Disable IOU
|
||||
IOUDISOFF := $C07F ; Enable IOU
|
||||
IOUDISON := $C07E ; Disable IOU
|
||||
IOUDISOFF := $C07F ; Enable IOU
|
||||
|
||||
; Control Your Apple
|
||||
CYAREG := $C036 ; Bits 0-3=disk detect 4=shadow all banks 7=fast
|
||||
|
|
|
@ -332,10 +332,9 @@ usage.
|
|||
<item>get_ostype
|
||||
<item>rebootafterexit
|
||||
<item>ser_apple2_slot
|
||||
<item>textframe
|
||||
<item>textframexy
|
||||
<item>tgi_apple2_mix
|
||||
<item>videomode
|
||||
<item>waitvsync
|
||||
</itemize>
|
||||
|
||||
|
||||
|
|
|
@ -116,6 +116,9 @@ unsigned __fastcall__ videomode (unsigned mode);
|
|||
** constants.
|
||||
*/
|
||||
|
||||
void waitvsync (void);
|
||||
/* Wait for start of next frame */
|
||||
|
||||
|
||||
|
||||
/* End of apple2enh.h */
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
; unsigned char get_ostype (void)
|
||||
;
|
||||
|
||||
.constructor initostype
|
||||
.constructor initostype, 9
|
||||
.export _get_ostype
|
||||
|
||||
; Identify machine according to:
|
||||
|
|
60
libsrc/apple2/waitvsync.s
Normal file
60
libsrc/apple2/waitvsync.s
Normal file
|
@ -0,0 +1,60 @@
|
|||
;
|
||||
; Oliver Schmidt, 2020-06-14
|
||||
;
|
||||
; void waitvsync (void);
|
||||
;
|
||||
.ifdef __APPLE2ENH__
|
||||
|
||||
.constructor initvsync
|
||||
.export _waitvsync
|
||||
.import _get_ostype
|
||||
|
||||
.include "apple2.inc"
|
||||
|
||||
.segment "ONCE"
|
||||
|
||||
initvsync:
|
||||
jsr _get_ostype
|
||||
sta ostype
|
||||
rts
|
||||
|
||||
.code
|
||||
|
||||
_waitvsync:
|
||||
bit ostype
|
||||
bmi iigs ; $8x
|
||||
bvs iic ; $4x
|
||||
|
||||
: bit RDVBLBAR
|
||||
bpl :- ; Blanking
|
||||
: bit RDVBLBAR
|
||||
bmi :- ; Drawing
|
||||
rts
|
||||
|
||||
; Apple IIgs TechNote #40, VBL Signal
|
||||
iigs: bit RDVBLBAR
|
||||
bmi iigs ; Blanking
|
||||
: bit RDVBLBAR
|
||||
bpl :- ; Drawing
|
||||
rts
|
||||
|
||||
; Apple IIc TechNote #9, Detecting VBL
|
||||
iic: sei
|
||||
sta IOUDISOFF
|
||||
lda RDVBLMSK
|
||||
bit ENVBL
|
||||
bit PTRIG ; Reset VBL interrupt flag
|
||||
: bit RDVBLBAR
|
||||
bpl :-
|
||||
asl
|
||||
bcs :+ ; VBL interrupts were already enabled
|
||||
bit DISVBL
|
||||
: sta IOUDISON ; IIc Tech Ref Man: The firmware normally leaves IOUDIS on.
|
||||
cli
|
||||
rts
|
||||
|
||||
.segment "INIT"
|
||||
|
||||
ostype: .res 1
|
||||
|
||||
.endif ; __APPLE2ENH__
|
Loading…
Add table
Reference in a new issue