- replaces Apple IIc, IIc+ VBL ProDOS interrupt handler with direct $C019 polling
- removes a few pieces of unused code
- added comments and changed formatting (sorry) for consistency
This commit is contained in:
Dagen Brock 2020-03-19 04:34:14 -05:00 committed by Dagen Brock
commit 2a002b1c07
13 changed files with 3059 additions and 3228 deletions

1
.gitignore vendored
View File

@ -8,4 +8,3 @@ src/*_Output.txt
src/*.system
flapple800.po
flapple140.po

View File

@ -14,6 +14,8 @@ fi
#revert file to original state (MONO=0)
sed -i.bak "s/^MONO\(.*\)equ.*/MONO\1equ 0/g" src/flapple.s
rm src/flapple.s.bak
./make_po.sh
gsplus

View File

@ -21,3 +21,4 @@ RAMWRTMAIN equ $C004
SETAN3 equ $C05E ;Set annunciator-3 output to 0
SET80VID equ $C00D ;enable 80-column display mode (WR-only)

View File

@ -25,6 +25,10 @@ SPRITE_IMASK_P equ $FC
SPRITE_SCREEN_IDX db #$0
BIRD_VELOCITY db 0 ; in two's compliment {-3,3}
BIRD_VELOCITY_MAX equ #20
BIRD_VELOCITY_MIN equ #%111111111 ; -1
BIRD_WIDTH equ #5
BIRD_X equ #17
BIRD_Y_INIT equ #17
BIRD_Y db #BIRD_Y_INIT ; (0-47)
@ -112,7 +116,6 @@ BIRD_WUP_O_PIXEL
hex AB,AE,EE,FF,FF,55,5D,AA,00,77
hex 5A,DE,4E,8C,8C,5D,D5,18,19,79
hex BB,BA,BA,BB,BB,77,75,75,77,77
FIN
BIRD_WUP_O_MASK
@ -233,7 +236,6 @@ UndrawBird lda BIRD_Y_OLD
:undraw4 lda LoLineTableL,y
sta SPRITE_SCREEN_P
lda LoLineTableH,y
@ -348,24 +350,6 @@ DrawBird
jsr DrawSpriteBetter
rts
*** MAKE IT WORK
BirdTest
lda BIRD_X ;#30 (0-79)
sta SPRITE_X
lda BIRD_Y ;#10 (0-23)
sta SPRITE_Y
lda #5 ;/2 value (we do two passes of 1/2... Aux/Main)
sta SPRITE_W
lda #3 ;/2 value (must be byte aligned vertically
sta SPRITE_H
; CopyPtr BIRD_WDN_MAIN;SPRITE_MAIN_P
; CopyPtr BIRD_WDN_AUX;SPRITE_AUX_P
; CopyPtr BIRD_WDN_MASK;SPRITE_MASK_P
; CopyPtr BIRD_WDN_IMASK;SPRITE_IMASK_P
jsr DrawSpriteBetter
rts
* still does collision
DrawSpriteBetter
lda #0
@ -442,10 +426,7 @@ DD_ODD
sta SPRITE_SCREEN_IDX
sta TXTPAGE1
:lineLoop ;ldy SPRITE_X_IDX ;
;lda (SPRITE_IMASK_P),y
;beq :noPixel
:lineLoop
:collisionCheckDrawer
ldy SPRITE_SCREEN_IDX ; GET SCREEN PIXELS
lda (SPRITE_SCREEN_P),y
@ -482,7 +463,4 @@ DD_ODD
cpy SPRITE_W
bcc :lineLoop
jmp ]DSLCD_done

View File

@ -937,32 +937,18 @@ QRCodeMaskColor equ #$88
QRCodeHeight equ #$0e
QRCodeWidth equ #$0e
QRCodeData
hex FF,0F,0F,0F,FF,FF,FF,0F,FF,FF,0F,0F,0F,FF,0F,0F,0F,0F,FF,FF,0F,FF,FF,0F
hex 0F,0F,0F,FF
hex FF,FF,0F,FF,FF,FF,FF,F0,F0,FF,FF,0F,FF,FF,00,0F,0F,00,F0,F0,FF,F0,F0,00
hex 0F,0F,00,FF
hex FF,FF,00,FF,FF,00,0F,F0,FF,FF,FF,00,FF,FF,00,00,00,00,F0,F0,F0,F0,0F,00
hex 00,00,00,FF
hex FF,0F,0F,0F,FF,F0,FF,F0,F0,FF,0F,0F,0F,FF,00,0F,0F,00,00,0F,00,0F,00,00
hex 0F,0F,00,FF
hex FF,0F,0F,FF,0F,00,0F,0F,0F,0F,0F,0F,0F,FF,0F,0F,0F,0F,0F,F0,0F,00,FF,FF
hex FF,FF,FF,FF
hex FF,00,0F,FF,00,FF,F0,00,0F,0F,00,0F,00,FF,F0,F0,FF,0F,F0,00,0F,0F,00,0F
hex FF,FF,0F,FF
hex FF,00,F0,00,0F,0F,FF,0F,FF,00,FF,FF,0F,FF,F0,0F,FF,0F,00,0F,F0,00,F0,0F
hex 0F,0F,00,FF
hex FF,F0,00,F0,00,FF,F0,F0,0F,0F,F0,00,00,FF,00,0F,0F,0F,FF,0F,0F,0F,F0,0F
hex FF,FF,0F,FF
hex FF,FF,00,0F,F0,00,FF,0F,0F,00,00,F0,FF,FF,00,00,00,0F,FF,00,F0,F0,0F,00
hex 0F,0F,F0,FF
hex FF,0F,0F,0F,FF,FF,F0,00,FF,FF,FF,00,0F,FF,0F,0F,0F,0F,00,FF,FF,0F,00,0F
hex 00,00,0F,FF
hex FF,FF,0F,FF,FF,00,FF,0F,0F,0F,0F,00,00,FF,00,0F,0F,00,0F,FF,00,00,00,0F
hex 00,0F,F0,FF
hex FF,FF,00,FF,FF,FF,F0,0F,00,F0,0F,FF,F0,FF,00,00,00,00,00,FF,0F,0F,F0,F0
hex F0,00,00,FF
hex FF,0F,0F,0F,FF,00,0F,0F,F0,F0,00,00,0F,FF,00,0F,0F,00,00,F0,0F,0F,F0,FF
hex 00,0F,00,FF
hex FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF
hex FF,FF,FF,FF
hex FF,0F,0F,0F,FF,FF,FF,0F,FF,FF,0F,0F,0F,FF,0F,0F,0F,0F,FF,FF,0F,FF,FF,0F,0F,0F,0F,FF
hex FF,FF,0F,FF,FF,FF,FF,F0,F0,FF,FF,0F,FF,FF,00,0F,0F,00,F0,F0,FF,F0,F0,00,0F,0F,00,FF
hex FF,FF,00,FF,FF,00,0F,F0,FF,FF,FF,00,FF,FF,00,00,00,00,F0,F0,F0,F0,0F,00,00,00,00,FF
hex FF,0F,0F,0F,FF,F0,FF,F0,F0,FF,0F,0F,0F,FF,00,0F,0F,00,00,0F,00,0F,00,00,0F,0F,00,FF
hex FF,0F,0F,FF,0F,00,0F,0F,0F,0F,0F,0F,0F,FF,0F,0F,0F,0F,0F,F0,0F,00,FF,FF,FF,FF,FF,FF
hex FF,00,0F,FF,00,FF,F0,00,0F,0F,00,0F,00,FF,F0,F0,FF,0F,F0,00,0F,0F,00,0F,FF,FF,0F,FF
hex FF,00,F0,00,0F,0F,FF,0F,FF,00,FF,FF,0F,FF,F0,0F,FF,0F,00,0F,F0,00,F0,0F,0F,0F,00,FF
hex FF,F0,00,F0,00,FF,F0,F0,0F,0F,F0,00,00,FF,00,0F,0F,0F,FF,0F,0F,0F,F0,0F,FF,FF,0F,FF
hex FF,FF,00,0F,F0,00,FF,0F,0F,00,00,F0,FF,FF,00,00,00,0F,FF,00,F0,F0,0F,00,0F,0F,F0,FF
hex FF,0F,0F,0F,FF,FF,F0,00,FF,FF,FF,00,0F,FF,0F,0F,0F,0F,00,FF,FF,0F,00,0F,00,00,0F,FF
hex FF,FF,0F,FF,FF,00,FF,0F,0F,0F,0F,00,00,FF,00,0F,0F,00,0F,FF,00,00,00,0F,00,0F,F0,FF
hex FF,FF,00,FF,FF,FF,F0,0F,00,F0,0F,FF,F0,FF,00,00,00,00,00,FF,0F,0F,F0,F0,F0,00,00,FF
hex FF,0F,0F,0F,FF,00,0F,0F,F0,F0,00,00,0F,FF,00,0F,0F,00,00,F0,0F,0F,F0,FF,00,0F,00,FF
hex FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF

View File

@ -9,21 +9,15 @@
typ $ff ; set P8 type ($ff = "SYS") for output file
xc off ; @todo force 6502?
xc off
MLI equ $bf00
; Sorry, I gotta have some macros.. this is merlin format after all
; You might as well take advantage of your tools :P
CopyPtr MAC
lda #<]1 ; load low byte
sta ]2 ; store low byte
lda #>]1 ; load high byte
sta ]2+1 ; store high byte
<<<
; HANDLE GREENSCREEN DOODS... MONO flag set 0 = color mode, 1 = mono mode
* 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
DO MONO
* MONO VERSION BUILD
dsk fmono.system ; tell compiler output filename
BGCOLOR equ #$00
BGCOLORAUX equ #$00
@ -32,8 +26,8 @@ BGCOLOR_0HI equ #$00
BGCOLORAUX_0LO equ #$00
BGCOLORAUX_0HI equ #$00
; HANDLE COLOR DOODS
ELSE
* COLOR VERSION BUILD
dsk flap.system ; tell compiler output filename
BGCOLOR equ #$77
BGCOLORAUX equ #$BB
@ -41,20 +35,31 @@ BGCOLOR_0LO equ #$70
BGCOLOR_0HI equ #$07
BGCOLORAUX_0LO equ #$B0
BGCOLORAUX_0HI equ #$0B
FIN
* Usage: CopyPtr sourceAddress;destinationZPPtrLoc
* macro used to set up ZeroPage pointers
* Example setting up sprite data pointer to the location of a bird sprite
* CopyPtr BIRD_WUP_E_PIXEL;SPRITE_DATA_P
CopyPtr MAC
lda #<]1 ; load low byte
sta ]2 ; store low byte
lda #>]1 ; load high byte
sta ]2+1 ; store high byte
<<<
Main
jsr DetectMachine ; also inits vbl
jsr SetupVBL
jsr LoadHiScore
jsr IntroWipe
jsr DL_SetDLRMode
Title
jsr VBlank
AttractLoop
jsr WaitVBL
DO MONO
lda #$FF
ELSE
@ -68,97 +73,87 @@ Title
ldy #BGCOLOR
jsr DL_WipeIn
jsr DrawFlogo
lda FlogoCount
and #%00000011 ; every 4 times?
lda SongSkipCounter
and #%00000011 ; throttle to play song every 4 times?
bne :noSongForYou
jsr PlayFlappySong ;@todo throttle
jsr SND_PlayFlappySong
:noSongForYou
inc FlogoCount
inc SongSkipCounter
ldx #60
ldy #2
jsr WaitKeyXY
PreGameLoop
** INIT ALL GAME STATE ITEMS
PlayfieldAttract
* INITIALIZE ALL GAME STATE VALUES
lda #BIRD_X
sta SPRITE_X
lda #BIRD_Y_INIT
sta BIRD_Y
sta BIRD_Y_OLD
lda #BIRD_WIDTH
sta SPRITE_W
lda #0
sta SPRITE_COLLISION
sta PreGameTick
sta PreGameTick+1
sta PreGameText
sta AttractTick
sta AttractTick+1
sta AttractText
sta ScoreLo
sta ScoreHi
lda #0
ldx #3
:clearPipes sta TopPipes,x
sta BotPipes
:zeroPipes sta TopPipes,x
sta BotPipes,x
dex
bpl :clearPipes
bpl :zeroPipes
** CLEAR SCREEN - SETUP BIRD
jsr VBlank
* CLEAR SCREEN TO PLAYFIELD COLOR
jsr WaitVBL
lda #BGCOLOR
jsr DL_Clear
lda #BIRD_X
sta SPRITE_X
lda #5
sta SPRITE_W ; all birds are same width
** WAIT FOR PLAYER TO HIT SOMETHING
:noKey jsr VBlank
* ANIMATE PLAYFIELD/BIRD WHILE WAITING FOR A KEYPRESS
:attractAnimLoop jsr WaitVBL
jsr UndrawBird
jsr DrawBird
jsr UpdateGrass
jsr FlapBird
inc PreGameTick
inc AttractTick
bne :noOverflow
inc PreGameTick+1
:noOverflow lda PreGameTick
cmp #60
bcc :skipText
lda PreGameText
inc AttractTick+1
:noOverflow lda AttractTick
cmp #60 ; on the 60th tick (aka after 1 second)
bne :skipText
inc PreGameText
jsr DrawTap
jsr DrawTap ; draw the "tap to flap" message
:skipText
lda PreGameTick+1
cmp #2
lda AttractTick+1
cmp #2 ; on the 0x200 aka 512th tick, switch to hiscore screen
bne :checkKey
jmp HiScreen
:checkKey jsr ButtonsCheck
bcs :key
bcs :keyPressed
lda KEY
bpl :noKey
:key sta STROBE
bpl :attractAnimLoop
:keyPressed sta STROBE
lda #BGCOLOR
jsr DL_Clear
jmp GameLoop
PreGameTick dw 0
PreGameText db 0
GSBORDER da _GSBORDER
_GSBORDER db 0
AttractTick dw 0
AttractText db 0
* MAIN GAME LOOP
GameLoop
jsr VBlank
jsr UndrawBird
jsr DrawPipes
jsr DrawScore
jsr DrawBird
jmp UpdatePipes
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)
jsr DrawBird ; draw the bird
jmp UpdatePipes ; update the
UpdatePipesDone
DONTUPDATEPIPES
jsr FlapBird
jsr UpdateGrass
@ -175,7 +170,7 @@ GAME_OVER
jsr DrawPipes
jsr DrawScore
jsr DrawSplosion
jsr SND_Static
jsr SND_Crash
jsr UpdateHiScore
lda #3
sta SPR_Y
@ -205,13 +200,13 @@ GAME_OVER
lda QuitFlag
beq :noQuit
jmp Quit
:noQuit jmp PreGameLoop
:noQuit jmp PlayfieldAttract
:noKey
lda #$FA
ldx #$50
ldy #$00
jsr DL_WipeIn
jmp Title
jmp AttractLoop
HiScreen
jsr GetRand
jsr DL_Clear
@ -230,74 +225,11 @@ HiScreen
lda QuitFlag
beq :noQuit
jmp Quit
:noQuit jmp PreGameLoop
:noKey jmp Title
:noQuit jmp PlayfieldAttract
:noKey jmp AttractLoop
FlogoCount db 0 ; used to throttle how often song is played
SongSkipCounter db 0 ; used to throttle how often song is played
SND_Flap jmp SND_Flap2
SND_Flap1
ldx #$1c ;LENGTH OF NOISE BURST
:spkLoop lda SPEAKER ;TOGGLE SPEAKER
txa
asl
asl
tay
:waitLoop dey ;DELAY LOOP FOR PULSE WIDTH
bne :waitLoop
dex ;GET NEXT PULSE OF THIS NOISE BURST
bne :spkLoop
rts
SND_Flap2
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
* ldy $BA00,X ;GET PULSE WIDTH PSEUDO-RANDOMLY
: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
* ldy $BA00,X ;GET PULSE WIDTH PSEUDO-RANDOMLY
: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
@ -400,9 +332,6 @@ PauseKeyCheck cmp #"p"
lda #0
rts
BIRD_VELOCITY db 0 ; in two's compliment {-3,3}
BIRD_VELOCITY_MAX equ #20
BIRD_VELOCITY_MIN equ #%111111111 ; -1
LoadHiScore jsr CreateHiScoreFile
bcs :error
jsr OpenHiScoreFile
@ -445,7 +374,7 @@ OpenHiScoreFile
ReadHiScoreFile
lda #0
sta IOBuffer
sta IOBuffer+1 ;zero load area, just in case
sta IOBuffer+1 ; zero load area, just in case
lda OpenRefNum
sta ReadRefNum
jsr MLI
@ -533,6 +462,7 @@ WriteResult dw 0 ; result count (amount transferred)
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)
@ -584,15 +514,16 @@ QRPause jsr DL_SetDLRMixMode
ldy #60
jsr WaitKeyXY
rts
QuitStr str "http://dagenbrock.com/flappy"
QuitStr str "https://github.com/digarok/flapple"
******************************
**************************************************
* Score Routines
*********************
**************************************************
ScoreLo db 0 ; 0-99
ScoreHi db 0 ; hundreds, not shown on screen
ScoreHi db 0 ; hundreds, not shown during gameplay but in highscore it is shown
HiScoreLo db 0
HiScoreHi db 0
** Draw the Score - @todo - handle > 99
DrawScore lda ScoreLo
and #$0F
@ -623,7 +554,6 @@ UpdateHiScore
bcc :newHighScore
bcs :noHighScore
:newHighScore lda ScoreHi
sta HiScoreHi
lda ScoreLo
@ -842,7 +772,7 @@ WaitKey
WaitKeyXY
stx _waitX
:kloop jsr VBlank
:kloop jsr WaitVBL
lda KEY
bmi :kpress
dex
@ -859,27 +789,8 @@ WaitKeyXY
rts
_waitX db 0
**************************************************
* See if we're running on a IIgs
* From Apple II Technote:
* Miscellaneous #7
* Apple II Family Identification
**************************************************
DetectMachine
sec ;Set carry bit (flag)
jsr $FE1F ;Call to the monitor
bcs :oldmachine ;If carry is still set, then old machine
* bcc :newmachine ;If carry is clear, then new machine
:newmachine asl _compType ;multiply vblank detection val $7E * 2
lda #1
bne :setmachine
:oldmachine lda #0
:setmachine sta GMachineIIgs
jsr InitVBlank
rts
GMachineIIgs db 0
IntroWipe
sta C80STOREON
@ -905,12 +816,12 @@ IntroText str "Dagen Brock presents..."
**************************************************
* Wait for vertical blanking interval - IIe/IIgs
* Wait for multiple VBLs
**************************************************
VBlankX
:xloop txa
pha
jsr VBlank
jsr WaitVBL
pla
tax
dex
@ -918,94 +829,14 @@ VBlankX
rts
InitVBlank
lda $FBC0 ; check for IIc
bne :rts ; not a IIc--use VBlankIIeIIgs
jsr MLI ; instantiate our interrupt
dfb $40
da VBLIntParm
lda #%00001000 ; enable vblint only
ldx #SETMOUSE
jsr mouse
lda #VBlankIIc ; override vblank
sta VBlankRoutine
lda #>VBlankIIc
sta VBlankRoutine+1
cli
:rts rts
VBLIntParm dfb 2
brk ;?
da VBLIntHandler
VBLIntHandler cld ; Expected by ProDOS
ldx #SERVEMOUSE
jsr mouse
bcs :notOurs ; pass if not
sec
ror _vblflag ;set hibit
clc
:notOurs rts
mouse ldy $C400,x
sty :jump+1
ldx #$C4
ldy #$40
sei
:jump jmp $C400
MOUSE = $c400 ; mouse = slot 4
*SETMOUSE = $c412 ; Apple IIc Ref p.168
*SERVEMOUSE = $c413 ; Apple IIc Ref p.168
SETMOUSE = $12
SERVEMOUSE = $13
READMOUSE = $14
INITMOUSE = $19
VBlank jmp VBlankIIeIIgs
VBlankRoutine equ *-2
VBlankIIc
cli ;enable interrupts
:loop1 bit _vblflag
bpl :loop1 ;wait for vblflag = 1
lsr _vblflag ;...& set vblflag = 0
*:loop2 bit _vblflag
* bpl :loop2
* lsr _vblflag
sei
rts
_vblflag db 0
VBlankIIeIIgs
lda _compType
:vblActive cmp RDVBLBAR ; make sure we wait for the current one to stop
bpl :vblActive ; in case it got launched in rapid succession
:screenActive cmp RDVBLBAR
bmi :screenActive
rts
_compType db #$7e ; $7e - IIe ; $FE - IIgs
MLI equ $bf00 ; ProDOS entry point
put vbl
put util
put applerom
put dlrlib

View File

@ -152,7 +152,7 @@ DrawPipes
jsr DrawPipe
:noPipes1
rts
*jmp DrawPipesDone ;Back to main
* Used by all of the routines that draw the pipe caps

View File

@ -3,25 +3,27 @@
*
* Flapple Bird - A de-make of Flappy Bird for the Apple II computer
*
* More information about this project is available at
* http://dagenbrock.com/flappy
* # Download releases here:
* https://github.com/digarok/flapple/releases
*
* How to run
* ==========
* You can download either disk image and run it with an emulator
* or transfer it to the respective media and run it on a real
* machine (recommended).
* The 3.5" ProDOS disk version is "flapple800.po", and the
* 5.25" ProDOS disk version is "flapple140.po".
* # How to run
* You can download either disk image and run it with an emulator like GSplus
* or transfer to the respective media and run on a real machine (recommended).
* - `flapple800.po` is the 3.5" ProDOS disk version (800KB)
* - `flapple140.po` is the 5.25" ProDOS disk version (140KB)
*
* How to build
* ============
* This is written to compile on Merlin 8/16, but I believe should
* work with all later Merlin variants. Load Merlin, then 'L'oad
* the file "flapple.s", finally hit OpenApple-A to assemble and
* it should build the "flap.system" file.
* It should automatically boot ProDOS and load the color version of the game.
* There is a Monochrome version of the game included on the disk.
* To run it, quit game with the `q` key, and from the ProDOS selector menu
* run `fmono.system`.
*
* # How to build
* This was originally written to compile on Merlin 8/16, but it's now
* maintained using Merlin32 (https://github.com/digarok/merlin32/).
*
*
* Again, more information about this project is available at
* http://dagenbrock.com/flappy
* - Classic Merlin16+ on an Apple IIgs
* - Load Merlin, then `L`oad the file "flapple.s", finally hit OpenApple-A to assemble and it should build the "flap.system" file.
* - Modern PC builds:
* - Assemble with `merlin32 src/flapple.s`
* - Make disks with `./make_po.sh`
* * Requires having `merlin32` and `cadius` commands available on your system.

View File

@ -1,5 +1,49 @@
* 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
* Flappy's Devastating Crash Sound
SND_Crash
ldx #$80 ;LENGTH OF NOISE BURST
jsr SEStaticBurst
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
@ -37,7 +81,6 @@ FlappySong hex 72,22,72,22,56,22,01,0E
**************************************************
* wrapper for SEplayNote
* a = freq ... x = dur
@ -49,12 +92,10 @@ SENoteAX jsr _storeReg
jsr _loadReg
rts
**************************************************
*
**************************************************
ds \
_SECURRNOTE db 0,0 ; current note being played (frequency/duration)
ds \ ; align
SEplayNote
ldy _SECURRNOTE+1
:loop lda SPEAKER
@ -68,20 +109,6 @@ SEplayNote
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)
@ -120,43 +147,3 @@ 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

View File

@ -25,24 +25,6 @@ SPRITE_SCREEN_IDX db #$0
AUX_BG_COLOR db #$BB
MAIN_BG_COLOR db #$77
*** MAKE IT WORK
BirdTest
lda BIRD_X ;#30 (0-79)
sta SPRITE_X
lda BIRD_Y ;#10 (0-23)
sta SPRITE_Y
lda #5 ;/2 value (we do two passes of 1/2... Aux/Main)
sta SPRITE_W
lda #3 ;/2 value (must be byte aligned vertically
sta SPRITE_H
CopyPtr BIRD_WDN_MAIN;SPRITE_MAIN_P
CopyPtr BIRD_WDN_AUX;SPRITE_AUX_P
CopyPtr BIRD_WDN_MASK;SPRITE_MASK_P
CopyPtr BIRD_WDN_IMASK;SPRITE_IMASK_P
jsr DrawSpriteBetter
rts
* still does collision
DrawSpriteBetter
lda #0

63
src/vbl.s Normal file
View File

@ -0,0 +1,63 @@
OP_BPL = #$10
OP_BMI = #$30
SetupVBL
lda $FBB3 ; machine id byte (A2Misc TN #7)
cmp #$06 ; IIe, IIc, IIgs
bne :foundII ; II, II+
lda $FBC0 ; machine id byte (A2Misc TN #7)
beq :foundIIc ; IIc = FBB3:06 FBC0:00
sec
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
rts
:foundIIe lda #OP_BPL ; BPL opcode
sta __waitRasterOp
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
cli
rts
* This function gets modified based on System: II(+), IIe, IIc, IIgs
WaitVBL
:waitRaster lda $c019
bmi :waitRaster ; make sure we are screen area first, (VBL=0) on IIgs, !SMC IIe/c
__waitRasterOp = *-2
__patchVBLIIc = *
:waitVBL lda $c019
bpl :waitVBL ; as soon as blanking starts return, (VBL=1) on IIgs, !SMC IIe/c
__waitVBLOp = *-2
rts