mirror of
https://github.com/digarok/flapple.git
synced 2024-05-28 10:41:27 +00:00
VBL working on IIc
This commit is contained in:
parent
0c8a9a81bb
commit
4c7cc709cd
|
@ -14,7 +14,7 @@
|
|||
* Change this flag to build either color/mono version
|
||||
* 0 = color mode, 1 = mono mode
|
||||
* The main difference is that it uses a black background so playfield is more visible on B/W screens
|
||||
MONO equ 0
|
||||
MONO equ 0
|
||||
|
||||
DO MONO
|
||||
* MONO VERSION BUILD
|
||||
|
@ -74,9 +74,9 @@ AttractLoop
|
|||
jsr DL_WipeIn
|
||||
jsr DrawFlogo
|
||||
lda SongSkipCounter
|
||||
and #%00000011 ; every 4 times?
|
||||
and #%00000011 ; throttle to play song every 4 times?
|
||||
bne :noSongForYou
|
||||
jsr PlayFlappySong ;@todo throttle
|
||||
jsr SND_PlayFlappySong
|
||||
:noSongForYou
|
||||
inc SongSkipCounter
|
||||
ldx #60
|
||||
|
@ -147,7 +147,7 @@ AttractText db 0
|
|||
|
||||
* MAIN GAME LOOP
|
||||
GameLoop
|
||||
jsr WaitVBL ; wait until we are in vertical blanking period
|
||||
jsr WaitVBL ; wait until we are in vertical blanking period
|
||||
jsr UndrawBird ; overwrite sprite area with background color
|
||||
jsr DrawPipes ; draw pipes in new position (this wipes with bgcolor as it draws)
|
||||
jsr DrawScore ; draw the score indicator at the top (overlapping any pipes)
|
||||
|
@ -170,7 +170,7 @@ GAME_OVER
|
|||
jsr DrawPipes
|
||||
jsr DrawScore
|
||||
jsr DrawSplosion
|
||||
jsr SND_Static
|
||||
jsr SND_Crash
|
||||
jsr UpdateHiScore
|
||||
lda #3
|
||||
sta SPR_Y
|
||||
|
@ -230,51 +230,6 @@ HiScreen
|
|||
|
||||
SongSkipCounter db 0 ; used to throttle how often song is played
|
||||
|
||||
SND_Flap ldx #$16 ;LENGTH OF NOISE BURST
|
||||
:spkLoop sta SPEAKER ;TOGGLE SPEAKER
|
||||
txa
|
||||
clc
|
||||
adc #$30
|
||||
tay
|
||||
:waitLoop dey ;DELAY LOOP FOR PULSE WIDTH
|
||||
bne :waitLoop
|
||||
dex ;GET NEXT PULSE OF THIS NOISE BURST
|
||||
bne :spkLoop
|
||||
rts
|
||||
|
||||
|
||||
SND_Static
|
||||
ldx #$80 ;LENGTH OF NOISE BURST
|
||||
:spkLoop lda SPEAKER ;TOGGLE SPEAKER
|
||||
jsr GetRand
|
||||
tay
|
||||
:waitLoop dey ;DELAY LOOP FOR PULSE WIDTH
|
||||
bne :waitLoop
|
||||
dex ;GET NEXT PULSE OF THIS NOISE BURST
|
||||
bne :spkLoop
|
||||
|
||||
ldx #$60 ;LENGTH OF NOISE BURST
|
||||
:spkLoop2 lda SPEAKER ;TOGGLE SPEAKER
|
||||
jsr GetRand
|
||||
and #%1000000
|
||||
tay
|
||||
|
||||
:waitLoop2 dey ;DELAY LOOP FOR PULSE WIDTH
|
||||
bne :waitLoop2
|
||||
dex ;GET NEXT PULSE OF THIS NOISE BURST
|
||||
bne :spkLoop2
|
||||
|
||||
ldx #$80 ;LENGTH OF NOISE BURST
|
||||
:spkLoop3 lda SPEAKER ;TOGGLE SPEAKER
|
||||
jsr GetRand
|
||||
lsr
|
||||
tay
|
||||
:waitLoop3 dey ;DELAY LOOP FOR PULSE WIDTH
|
||||
bne :waitLoop3
|
||||
dex ;GET NEXT PULSE OF THIS NOISE BURST
|
||||
bne :spkLoop3
|
||||
|
||||
rts
|
||||
|
||||
HandleInput
|
||||
lda BIRD_Y
|
||||
|
@ -506,8 +461,8 @@ WriteRefNum db 0 ; set by open subroutine above
|
|||
WriteResult dw 0 ; result count (amount transferred)
|
||||
|
||||
|
||||
Quit jsr ShutDownVBL ; disable IIc VBL polling if needed
|
||||
jsr QRPause
|
||||
Quit jsr QRPause
|
||||
jsr ShutDownVBL ; disable IIc VBL polling if needed
|
||||
sta TXTPAGE1 ; Don't forget to give them back the right page!
|
||||
jsr MLI ; first actual command, call ProDOS vector
|
||||
dfb $65 ; QUIT P8 request ($65)
|
||||
|
|
|
@ -1,162 +1,149 @@
|
|||
* Flappy's Flapping Chirp Sound
|
||||
SND_Flap ldx #$16 ;LENGTH OF NOISE BURST
|
||||
:spkLoop sta SPEAKER ;TOGGLE SPEAKER
|
||||
txa
|
||||
clc
|
||||
adc #$30
|
||||
tay
|
||||
:waitLoop dey ;DELAY LOOP FOR PULSE WIDTH
|
||||
bne :waitLoop
|
||||
dex ;GET NEXT PULSE OF THIS NOISE BURST
|
||||
bne :spkLoop
|
||||
rts
|
||||
|
||||
PlayFlappySong
|
||||
ldy #0
|
||||
:loop lda FlappySong,y
|
||||
cmp #NoteEnd
|
||||
beq :done
|
||||
cmp #NoteRest
|
||||
bne :notRest
|
||||
ldx FlappySong+1,y
|
||||
jsr VBlankX
|
||||
clc
|
||||
bcc :nextNote
|
||||
:notRest ldx FlappySong+1,y
|
||||
jsr SENoteAX
|
||||
ldx #2
|
||||
jsr VBlankX
|
||||
:nextNote iny
|
||||
iny
|
||||
lda KEY ; allow user to skip my totally awesome song
|
||||
bpl :noKey
|
||||
sta STROBE
|
||||
rts
|
||||
:noKey clc
|
||||
bcc :loop
|
||||
:done rts
|
||||
* Flappy's Devastating Crash Sound
|
||||
SND_Crash
|
||||
ldx #$80 ;LENGTH OF NOISE BURST
|
||||
jsr SEStaticBurst
|
||||
|
||||
|
||||
FlappySong hex 72,22,72,22,56,22,01,0E
|
||||
hex 72,22,72,22,56,22,01,0E
|
||||
hex 72,22,72,22,56,22,01,0E
|
||||
hex 72,22,72,22,80,22,01,0E
|
||||
hex 72,22,72,22,56,22,01,0E
|
||||
hex 72,22,72,22,56,22,01,0E
|
||||
hex 72,22,72,22,4C,22,56,22
|
||||
hex 5B,22,72,22,5B,22,56,40
|
||||
hex 02 ; end byte
|
||||
ldx #$60 ;LENGTH OF NOISE BURST
|
||||
:spkLoop2 lda SPEAKER ;TOGGLE SPEAKER
|
||||
jsr GetRand
|
||||
and #%1000000
|
||||
tay
|
||||
:waitLoop2 dey ;DELAY LOOP FOR PULSE WIDTH
|
||||
bne :waitLoop2
|
||||
dex ;GET NEXT PULSE OF THIS NOISE BURST
|
||||
bne :spkLoop2
|
||||
|
||||
ldx #$80 ;LENGTH OF NOISE BURST
|
||||
jsr SEStaticBurst
|
||||
rts
|
||||
|
||||
SEStaticBurst
|
||||
:spkLoop lda SPEAKER ;TOGGLE SPEAKER
|
||||
jsr GetRand
|
||||
tay
|
||||
:waitLoop dey ;DELAY LOOP FOR PULSE WIDTH
|
||||
bne :waitLoop
|
||||
dex ;GET NEXT PULSE OF THIS NOISE BURST
|
||||
bne :spkLoop
|
||||
rts
|
||||
|
||||
|
||||
* BELOW HERE IS THE "MUSIC ENGINE"
|
||||
SND_PlayFlappySong
|
||||
ldy #0
|
||||
:loop lda FlappySong,y
|
||||
cmp #NoteEnd
|
||||
beq :done
|
||||
cmp #NoteRest
|
||||
bne :notRest
|
||||
ldx FlappySong+1,y
|
||||
jsr VBlankX
|
||||
clc
|
||||
bcc :nextNote
|
||||
:notRest ldx FlappySong+1,y
|
||||
jsr SENoteAX
|
||||
ldx #2
|
||||
jsr VBlankX
|
||||
:nextNote iny
|
||||
iny
|
||||
lda KEY ; allow user to skip my totally awesome song
|
||||
bpl :noKey
|
||||
sta STROBE
|
||||
rts
|
||||
:noKey clc
|
||||
bcc :loop
|
||||
:done rts
|
||||
|
||||
|
||||
FlappySong hex 72,22,72,22,56,22,01,0E
|
||||
hex 72,22,72,22,56,22,01,0E
|
||||
hex 72,22,72,22,56,22,01,0E
|
||||
hex 72,22,72,22,80,22,01,0E
|
||||
hex 72,22,72,22,56,22,01,0E
|
||||
hex 72,22,72,22,56,22,01,0E
|
||||
hex 72,22,72,22,4C,22,56,22
|
||||
hex 5B,22,72,22,5B,22,56,40
|
||||
hex 02 ; end byte
|
||||
|
||||
|
||||
|
||||
**************************************************
|
||||
* wrapper for SEplayNote
|
||||
* wrapper for SEplayNote
|
||||
* a = freq ... x = dur
|
||||
**************************************************
|
||||
SENoteAX jsr _storeReg
|
||||
sta _SECURRNOTE
|
||||
stx _SECURRNOTE+1
|
||||
jsr SEplayNote
|
||||
jsr _loadReg
|
||||
rts
|
||||
|
||||
SENoteAX jsr _storeReg
|
||||
sta _SECURRNOTE
|
||||
stx _SECURRNOTE+1
|
||||
jsr SEplayNote
|
||||
jsr _loadReg
|
||||
rts
|
||||
|
||||
**************************************************
|
||||
*
|
||||
**************************************************
|
||||
ds \
|
||||
_SECURRNOTE db 0,0 ; current note being played (frequency/duration)
|
||||
|
||||
ds \ ; align
|
||||
SEplayNote
|
||||
ldy _SECURRNOTE+1
|
||||
:loop lda SPEAKER
|
||||
:whyWut dey
|
||||
bne :thar
|
||||
dec _SECURRNOTE+1
|
||||
beq :doneThat
|
||||
:thar dex
|
||||
bne :whyWut
|
||||
ldx _SECURRNOTE
|
||||
jmp :loop
|
||||
:doneThat rts
|
||||
ldy _SECURRNOTE+1
|
||||
:loop lda SPEAKER
|
||||
:whyWut dey
|
||||
bne :thar
|
||||
dec _SECURRNOTE+1
|
||||
beq :doneThat
|
||||
:thar dex
|
||||
bne :whyWut
|
||||
ldx _SECURRNOTE
|
||||
jmp :loop
|
||||
:doneThat rts
|
||||
|
||||
SEplayNote_OLD
|
||||
:loop lda SPEAKER
|
||||
:whyWut dey
|
||||
bne :thar
|
||||
dec _SECURRNOTE+1
|
||||
beq :doneThat
|
||||
:thar dex
|
||||
bne :whyWut
|
||||
ldx _SECURRNOTE
|
||||
jmp :loop
|
||||
:doneThat rts
|
||||
|
||||
|
||||
_SECURRNOTE db 0,0 ; current note being played (frequency/duration)
|
||||
|
||||
|
||||
|
||||
**************************************************
|
||||
* This is essentially the scale
|
||||
**************************************************
|
||||
_SE_tones db NoteG0,NoteGsharp0,NoteA0,NoteBflat0,NoteB0
|
||||
db NoteC1,NoteCsharp1,NoteD1,NoteDsharp1,NoteE1
|
||||
db NoteF1,NoteFsharp1,NoteG1,NoteGsharp1,NoteA1
|
||||
db NoteBflat1,NoteB1,NoteC2,NoteCsharp2,NoteD2
|
||||
db NoteDsharp2,NoteE2,NoteF2
|
||||
|
||||
NoteRest equ $01 ;\_ these are inaudible anyway
|
||||
NoteEnd equ $02 ;/
|
||||
NoteG0 equ $00 ; because it loops (underflow)
|
||||
NoteGsharp0 equ $f0
|
||||
NoteA0 equ $e6
|
||||
NoteBflat0 equ $d5
|
||||
NoteB0 equ $cb ; speculating here on up
|
||||
NoteC1 equ $c0
|
||||
NoteCsharp1 equ $b5
|
||||
NoteD1 equ $ac
|
||||
NoteDsharp1 equ $a3
|
||||
NoteE1 equ $99
|
||||
NoteF1 equ $90
|
||||
NoteFsharp1 equ $89
|
||||
NoteG1 equ $80
|
||||
NoteGsharp1 equ $79
|
||||
NoteA1 equ $72
|
||||
NoteBflat1 equ $6c
|
||||
NoteB1 equ $66
|
||||
NoteC2 equ $60
|
||||
NoteCsharp2 equ $5b
|
||||
NoteD2 equ $56
|
||||
NoteDsharp2 equ $51
|
||||
NoteE2 equ $4c
|
||||
NoteF2 equ $48
|
||||
; starts to suck here anyway
|
||||
|
||||
|
||||
SErandStatic
|
||||
ldy #$ff
|
||||
:loop lda SPEAKER
|
||||
jsr GetRand
|
||||
tax
|
||||
beq :next
|
||||
:wait dex
|
||||
bne :wait
|
||||
:next dey
|
||||
bne :loop
|
||||
rts
|
||||
|
||||
* y = length
|
||||
SErandStaticBit
|
||||
:loop lda SPEAKER
|
||||
jsr GetRand
|
||||
lsr
|
||||
tax
|
||||
beq :next
|
||||
:wait dex
|
||||
bne :wait
|
||||
:next dey
|
||||
bne :loop
|
||||
rts
|
||||
|
||||
* y = length - no shift so wider range
|
||||
SErandStaticBit2
|
||||
:loop lda SPEAKER
|
||||
jsr GetRand
|
||||
tax
|
||||
beq :next
|
||||
:wait dex
|
||||
bne :wait
|
||||
:next dey
|
||||
bne :loop
|
||||
rts
|
||||
|
||||
_SE_tones db NoteG0,NoteGsharp0,NoteA0,NoteBflat0,NoteB0
|
||||
db NoteC1,NoteCsharp1,NoteD1,NoteDsharp1,NoteE1
|
||||
db NoteF1,NoteFsharp1,NoteG1,NoteGsharp1,NoteA1
|
||||
db NoteBflat1,NoteB1,NoteC2,NoteCsharp2,NoteD2
|
||||
db NoteDsharp2,NoteE2,NoteF2
|
||||
|
||||
NoteRest equ $01 ;\_ these are inaudible anyway
|
||||
NoteEnd equ $02 ;/
|
||||
NoteG0 equ $00 ; because it loops (underflow)
|
||||
NoteGsharp0 equ $f0
|
||||
NoteA0 equ $e6
|
||||
NoteBflat0 equ $d5
|
||||
NoteB0 equ $cb ; speculating here on up
|
||||
NoteC1 equ $c0
|
||||
NoteCsharp1 equ $b5
|
||||
NoteD1 equ $ac
|
||||
NoteDsharp1 equ $a3
|
||||
NoteE1 equ $99
|
||||
NoteF1 equ $90
|
||||
NoteFsharp1 equ $89
|
||||
NoteG1 equ $80
|
||||
NoteGsharp1 equ $79
|
||||
NoteA1 equ $72
|
||||
NoteBflat1 equ $6c
|
||||
NoteB1 equ $66
|
||||
NoteC2 equ $60
|
||||
NoteCsharp2 equ $5b
|
||||
NoteD2 equ $56
|
||||
NoteDsharp2 equ $51
|
||||
NoteE2 equ $4c
|
||||
NoteF2 equ $48
|
||||
; starts to suck here anyway
|
||||
|
|
30
src/vbl.s
30
src/vbl.s
|
@ -1,4 +1,7 @@
|
|||
|
||||
OP_BPL = #$10
|
||||
OP_BMI = #$30
|
||||
|
||||
SetupVBL
|
||||
lda $FBB3 ; machine id byte (A2Misc TN #7)
|
||||
cmp #$06 ; IIe, IIc, IIgs
|
||||
|
@ -11,41 +14,50 @@ SetupVBL
|
|||
jsr $FE1F ; Check for IIgs compatibility routine
|
||||
bcs :foundIIe
|
||||
bcc :foundIIgs
|
||||
|
||||
:foundII lda #$60 ; RTS opcode
|
||||
sta WaitVBL
|
||||
rts
|
||||
|
||||
:foundIIc lda #$EA ; NOP opcode
|
||||
sta ShutDownVBL
|
||||
lda #OP_BPL ; BPL opcode
|
||||
sta __waitRasterOp
|
||||
lda #$70
|
||||
sta __patchVBLIIc+1
|
||||
lda #$60
|
||||
sta __patchVBLIIc+3
|
||||
|
||||
sei
|
||||
sta $C07F ; enable access to VBL register
|
||||
sta $C05B ; enable VBL polling
|
||||
sta $C07E ; disable access to VBL register
|
||||
lda #$EA ; NOP opcode
|
||||
sta __waitVBLIIcPassthru
|
||||
:foundIIe lda #$10 ; BPL opcode
|
||||
rts
|
||||
|
||||
:foundIIe lda #OP_BPL ; BPL opcode
|
||||
sta __waitRasterOp
|
||||
lda #$30 ; BMI opcode
|
||||
lda #OP_BMI ; BMI opcode
|
||||
sta __waitVBLOp
|
||||
:foundIIgs rts
|
||||
|
||||
ShutDownVBL rts ; SMC
|
||||
:lastVBL bit $C019
|
||||
bpl :lastVBL
|
||||
lda $C070 ; $c019 bit 7 is sticky, reset it
|
||||
sta $C07F ; enable access to VBL register
|
||||
sta $C05A ; disable VBL polling
|
||||
sta $C07E ; disable access to VBL register
|
||||
lda $C070 ; $c019 bit 7 is sticky, reset it
|
||||
cli
|
||||
rts
|
||||
|
||||
* This function gets modified based on System: II(+), IIe, IIc, IIgs
|
||||
WaitVBL
|
||||
:waitRaster bit $c019
|
||||
:waitRaster lda $c019
|
||||
bmi :waitRaster ; make sure we are screen area first, (VBL=0) on IIgs, !SMC IIe/c
|
||||
__waitRasterOp = *-2
|
||||
:waitVBL bit $c019
|
||||
__patchVBLIIc = *
|
||||
:waitVBL lda $c019
|
||||
bpl :waitVBL ; as soon as blanking starts return, (VBL=1) on IIgs, !SMC IIe/c
|
||||
__waitVBLOp = *-2
|
||||
__waitVBLIIcPassthru rts
|
||||
lda $C070 ; $c019 bit 7 is sticky on IIc, reset it
|
||||
rts
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user