mirror of
https://github.com/digarok/flapple.git
synced 2026-04-20 06:16:29 +00:00
some pipe spawning, grass scrolling routines
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
**************************************************
|
||||
* Apple Standard Memory Locations
|
||||
**************************************************
|
||||
CLRLORES equ $F832
|
||||
LORES equ $C050
|
||||
TXTSET equ $C051
|
||||
MIXCLR equ $C052
|
||||
MIXSET equ $C053
|
||||
TXTPAGE1 equ $C054
|
||||
TXTPAGE2 equ $C055
|
||||
KEY equ $C000
|
||||
C80STOREOFF equ $C000
|
||||
C80STOREON equ $C001
|
||||
STROBE equ $C010
|
||||
SPEAKER equ $C030
|
||||
VBL equ $C02E
|
||||
RDVBLBAR equ $C019 ;not VBL (VBL signal low
|
||||
|
||||
SETAN3 equ $C05E ;Set annunciator-3 output to 0
|
||||
SET80VID equ $C00D ;enable 80-column display mode (WR-only)
|
||||
+118
@@ -0,0 +1,118 @@
|
||||
DL_SetDLRMode lda LORES ;set lores
|
||||
lda SETAN3 ;enables DLR
|
||||
sta SET80VID
|
||||
|
||||
sta C80STOREON ; enable aux/page1,2 mapping
|
||||
rts
|
||||
|
||||
|
||||
DL_Clear sta TXTPAGE1
|
||||
ldx #40
|
||||
:loop dex
|
||||
sta Lo01,x
|
||||
sta Lo02,x
|
||||
sta Lo03,x
|
||||
sta Lo04,x
|
||||
sta Lo05,x
|
||||
sta Lo06,x
|
||||
sta Lo07,x
|
||||
sta Lo08,x
|
||||
sta Lo09,x
|
||||
sta Lo10,x
|
||||
sta Lo11,x
|
||||
sta Lo12,x
|
||||
sta Lo13,x
|
||||
sta Lo14,x
|
||||
sta Lo15,x
|
||||
sta Lo16,x
|
||||
sta Lo17,x
|
||||
sta Lo18,x
|
||||
sta Lo19,x
|
||||
sta Lo20,x
|
||||
sta Lo21,x
|
||||
sta Lo22,x
|
||||
sta Lo23,x
|
||||
sta Lo24,x
|
||||
bne :loop
|
||||
tax ; get aux color value
|
||||
lda MainAuxMap,x
|
||||
sta TXTPAGE2 ; turn on p2
|
||||
ldx #40
|
||||
:loop2 dex
|
||||
sta Lo01,x
|
||||
sta Lo02,x
|
||||
sta Lo03,x
|
||||
sta Lo04,x
|
||||
sta Lo05,x
|
||||
sta Lo06,x
|
||||
sta Lo07,x
|
||||
sta Lo08,x
|
||||
sta Lo09,x
|
||||
sta Lo10,x
|
||||
sta Lo11,x
|
||||
sta Lo12,x
|
||||
sta Lo13,x
|
||||
sta Lo14,x
|
||||
sta Lo15,x
|
||||
sta Lo16,x
|
||||
sta Lo17,x
|
||||
sta Lo18,x
|
||||
sta Lo19,x
|
||||
sta Lo20,x
|
||||
sta Lo21,x
|
||||
sta Lo22,x
|
||||
sta Lo23,x
|
||||
sta Lo24,x
|
||||
bne :loop2
|
||||
rts
|
||||
|
||||
**************************************************
|
||||
* Lores/Text lines
|
||||
**************************************************
|
||||
Lo01 equ $400
|
||||
Lo02 equ $480
|
||||
Lo03 equ $500
|
||||
Lo04 equ $580
|
||||
Lo05 equ $600
|
||||
Lo06 equ $680
|
||||
Lo07 equ $700
|
||||
Lo08 equ $780
|
||||
Lo09 equ $428
|
||||
Lo10 equ $4a8
|
||||
Lo11 equ $528
|
||||
Lo12 equ $5a8
|
||||
Lo13 equ $628
|
||||
Lo14 equ $6a8
|
||||
Lo15 equ $728
|
||||
Lo16 equ $7a8
|
||||
Lo17 equ $450
|
||||
Lo18 equ $4d0
|
||||
Lo19 equ $550
|
||||
Lo20 equ $5d0
|
||||
* the "plus four" lines
|
||||
Lo21 equ $650
|
||||
Lo22 equ $6d0
|
||||
Lo23 equ $750
|
||||
Lo24 equ $7d0
|
||||
|
||||
LoLineTable da Lo01,Lo02,Lo03,Lo04,Lo05,Lo06
|
||||
da Lo07,Lo08,Lo09,Lo10,Lo11,Lo12
|
||||
da Lo13,Lo14,Lo15,Lo16,Lo17,Lo18
|
||||
da Lo19,Lo20,Lo21,Lo22,Lo23,Lo24
|
||||
MainAuxMap
|
||||
hex 00,08,01,09,02,0A,03,0B,04,0C,05,0D,06,0E,07,0F
|
||||
hex 80,88,81,89,82,8A,83,8B,84,8C,85,8D,86,8E,87,8F
|
||||
hex 10,18,11,19,12,1A,13,1B,14,1C,15,1D,16,1E,17,1F
|
||||
hex 90,98,91,99,92,9A,93,9B,94,9C,95,9D,96,9E,97,9F
|
||||
hex 20,28,21,29,22,2A,23,2B,24,2C,25,2D,26,2E,27,2F
|
||||
hex A0,A8,A1,A9,A2,AA,A3,AB,A4,AC,A5,AD,A6,AE,A7,AF
|
||||
hex 30,38,31,39,32,3A,33,3B,34,3C,35,3D,36,3E,37,3F
|
||||
hex B0,B8,B1,B9,B2,BA,B3,BB,B4,BC,B5,BD,B6,BE,B7,BF
|
||||
hex 40,48,41,49,42,4A,43,4B,44,4C,45,4D,46,4E,47,4F
|
||||
hex C0,C8,C1,C9,C2,CA,C3,CB,C4,CC,C5,CD,C6,CE,C7,CF
|
||||
hex 50,58,51,59,52,5A,53,5B,54,5C,55,5D,56,5E,57,5F
|
||||
hex D0,D8,D1,D9,D2,DA,D3,DB,D4,DC,D5,DD,D6,DE,D7,DF
|
||||
hex 60,68,61,69,62,6A,63,6B,64,6C,65,6D,66,6E,67,6F
|
||||
hex E0,E8,E1,E9,E2,EA,E3,EB,E4,EC,E5,ED,E6,EE,E7,EF
|
||||
hex 70,78,71,79,72,7A,73,7B,74,7C,75,7D,76,7E,77,7F
|
||||
hex F0,F8,F1,F9,F2,FA,F3,FB,F4,FC,F5,FD,F6,FE,F7,FF
|
||||
+441
@@ -0,0 +1,441 @@
|
||||
****************************************
|
||||
* Flapple Bird *
|
||||
* *
|
||||
* Dagen Brock <dagenbrock@gmail.com> *
|
||||
* 2014-04-17 *
|
||||
****************************************
|
||||
lst off
|
||||
org $2000 ; start at $2000 (all ProDOS8 system files)
|
||||
dsk f ; tell compiler what name for output file ("f", temporarily)
|
||||
typ $ff ; set P8 type ($ff = "SYS") for output file
|
||||
xc off ; @todo force 6502?
|
||||
xc off
|
||||
MLI equ $bf00
|
||||
|
||||
|
||||
|
||||
|
||||
Main
|
||||
jsr DetectIIgs
|
||||
jsr InitState ;@todo: IIc vblank code
|
||||
|
||||
|
||||
jsr VBlank
|
||||
|
||||
jsr DL_SetDLRMode
|
||||
|
||||
lda #$77
|
||||
jsr DL_Clear
|
||||
|
||||
GameLoop
|
||||
; handle input
|
||||
; draw grass
|
||||
; wait vblank
|
||||
; undraw player
|
||||
; update pipes / draw
|
||||
; update player / draw (w/collision)
|
||||
; update score
|
||||
jsr UpdatePipes
|
||||
jsr UpdateGrass
|
||||
jsr VBlank
|
||||
*jsr WaitKey
|
||||
|
||||
|
||||
|
||||
:kloop lda KEY
|
||||
bpl :noKey
|
||||
:key sta STROBE
|
||||
bmi Quit
|
||||
:noKey bpl GameLoop
|
||||
|
||||
|
||||
|
||||
|
||||
Quit jsr MLI ; first actual command, call ProDOS vector
|
||||
dfb $65 ; with "quit" request ($65)
|
||||
da QuitParm
|
||||
bcs Error
|
||||
brk $00 ; shouldn't ever here!
|
||||
|
||||
QuitParm dfb 4 ; number of parameters
|
||||
dfb 0 ; standard quit type
|
||||
da $0000 ; not needed when using standard quit
|
||||
dfb 0 ; not used
|
||||
da $0000 ; not used
|
||||
|
||||
|
||||
Error brk $00 ; shouldn't be here either
|
||||
|
||||
|
||||
**************************************************
|
||||
* Pipes
|
||||
*
|
||||
**************************************************
|
||||
PipeInterval equ #60 ; game ticks to spawn new pipe
|
||||
PipeSpawn db 0 ; our counter
|
||||
PipeSpawnSema db 0 ; points to next spot (even if currently unavailable)
|
||||
MaxPipes equ 2
|
||||
TopPipes hex 00,00,00,00
|
||||
lst on
|
||||
BotPipes hex 00,00,00,00
|
||||
lst off
|
||||
BotPipeMin equ 3
|
||||
BotPipeMax equ 8
|
||||
|
||||
PipeSpr_Main
|
||||
hex 55,e5,e5,c5,e5,c5,c5,c5,c5,45,c5,45,45,55,77
|
||||
hex 55,5e,5e,5c,5e,5c,5c,5c,5c,54,5c,54,54,55,77
|
||||
hex 77,55,ee,ee,cc,ee,cc,cc,44,cc,44,44,55,77,77
|
||||
|
||||
|
||||
PipeSpr_Aux
|
||||
hex aa,7a,7a,6a,7a,6a,6a,6a,6a,2a,6a,2a,2a,aa,bb
|
||||
hex aa,a7,a7,a6,a7,a6,a6,a6,a6,a2,a6,a2,a2,aa,bb
|
||||
hex bb,aa,77,77,66,77,66,66,22,66,22,22,aa,bb,bb
|
||||
|
||||
* pipe min = 15x6 pixels = 15x3 bytes
|
||||
* playfield = 80x48 pixels = 80x24 bytes
|
||||
* - grass = 80x44 pixels = 80x22 bytes
|
||||
* we'll make the pipes sit on a 95x22 space
|
||||
* we don't care about screen pixel X/Y though we could translate
|
||||
* the drawing routine will handle it, and we will do collision
|
||||
* in the bird drawing routine
|
||||
UpdatePipes inc PipeSpawn
|
||||
lda PipeSpawn
|
||||
cmp #PipeInterval
|
||||
bne :noSpawn
|
||||
jsr SpawnPipe
|
||||
lda #0
|
||||
sta PipeSpawn
|
||||
:noSpawn jsr MoveDrawPipes
|
||||
|
||||
|
||||
rts
|
||||
|
||||
MoveDrawPipes lda BotPipes
|
||||
beq :noP1
|
||||
dec BotPipes
|
||||
ldy BotPipes+1
|
||||
jsr DrawPipe
|
||||
:noP1
|
||||
lda BotPipes+2
|
||||
beq :noP2
|
||||
dec BotPipes+2
|
||||
ldy BotPipes+3
|
||||
jsr DrawPipe
|
||||
|
||||
:noP2 rts
|
||||
|
||||
SRCPTR equz $00
|
||||
DSTPTR equz $02
|
||||
|
||||
* A=x Y=(byte)y
|
||||
DrawPipeSimple
|
||||
tax
|
||||
cpx #95-15
|
||||
bcc :notOver
|
||||
rts
|
||||
:notOver cpx #16
|
||||
bcs :notUnder
|
||||
rts
|
||||
:notUnder
|
||||
|
||||
lsr
|
||||
bcc :even
|
||||
:odd txa
|
||||
jsr DrawPipeOddR
|
||||
rts
|
||||
:even txa
|
||||
jsr DrawPipeEvenR
|
||||
rts
|
||||
|
||||
* A=x x=x Y=(byte)y
|
||||
DrawPipeOddR
|
||||
sta TXTPAGE1
|
||||
tya
|
||||
asl ; *2
|
||||
tay
|
||||
lda LoLineTable,y
|
||||
sta DSTPTR
|
||||
lda LoLineTable+1,y
|
||||
sta DSTPTR+1 ; pointer to line on screen
|
||||
txa
|
||||
clc
|
||||
sbc #15
|
||||
lsr
|
||||
pha
|
||||
tay ; y= the x offset... yay dp indexing on 6502
|
||||
ldx #0
|
||||
:l1_loop lda PipeSpr_Main,x
|
||||
sta (DSTPTR),y
|
||||
iny ; can check this for clipping?
|
||||
inx
|
||||
inx ;\_ skip a col
|
||||
cpx #15
|
||||
bcc :l1_loop
|
||||
|
||||
sta TXTPAGE2
|
||||
pla ;\
|
||||
tay ; >- restore
|
||||
iny ;-- pixel after - fun mapping
|
||||
ldx #1
|
||||
:l1a_loop lda PipeSpr_Aux,x
|
||||
sta (DSTPTR),y
|
||||
iny ; can check this for clipping?
|
||||
inx
|
||||
inx ;\_ skip a col
|
||||
cpx #15
|
||||
bcc :l1a_loop
|
||||
rts
|
||||
|
||||
DrawPipeEvenR
|
||||
sta TXTPAGE2
|
||||
tya
|
||||
asl ; *2
|
||||
tay
|
||||
lda LoLineTable,y
|
||||
sta DSTPTR
|
||||
lda LoLineTable+1,y
|
||||
sta DSTPTR+1 ; pointer to line on screen
|
||||
txa
|
||||
clc
|
||||
sbc #15
|
||||
lsr
|
||||
pha
|
||||
tay ; y= the x offset... yay dp indexing on 6502
|
||||
ldx #0
|
||||
:l1_loop lda PipeSpr_Aux,x
|
||||
sta (DSTPTR),y
|
||||
iny ; can check this for clipping?
|
||||
inx
|
||||
inx ;\_ skip a col
|
||||
cpx #15
|
||||
bcc :l1_loop
|
||||
|
||||
sta TXTPAGE1
|
||||
pla ;\
|
||||
tay ; >- restore
|
||||
* iny ;-- pixel after - fun mapping
|
||||
ldx #1
|
||||
:l1a_loop lda PipeSpr_Main,x
|
||||
sta (DSTPTR),y
|
||||
iny ; can check this for clipping?
|
||||
inx
|
||||
inx ;\_ skip a col
|
||||
cpx #15
|
||||
bcc :l1a_loop
|
||||
rts
|
||||
|
||||
|
||||
|
||||
* A=x Y=(byte)y
|
||||
DrawPipe jsr _storeReg
|
||||
jsr DrawPipeSimple
|
||||
jsr _loadReg
|
||||
tay ;store?
|
||||
lsr
|
||||
bcc DrawBlipEven
|
||||
DrawBlipOdd sta TXTPAGE1
|
||||
sec
|
||||
sbc #$08
|
||||
tax
|
||||
lda #$11
|
||||
sta Lo15,x
|
||||
cpx #40 ;test---
|
||||
bcs :noUndraw
|
||||
sta TXTPAGE2
|
||||
lda #$BB
|
||||
sta Lo15+1,x
|
||||
:noUndraw rts
|
||||
DrawBlipEven sta TXTPAGE2
|
||||
sec
|
||||
sbc #$08
|
||||
tax
|
||||
lda #$88
|
||||
sta Lo15,x
|
||||
cpx #40 ;test---
|
||||
bcs :noUndraw
|
||||
sta TXTPAGE1
|
||||
lda #$77
|
||||
sta Lo15,x
|
||||
:noUndraw rts
|
||||
|
||||
SpawnPipe lda PipeSpawnSema
|
||||
asl ; convert to word index
|
||||
tax
|
||||
jsr GetRand ; Build Y Value
|
||||
and #$0F ; @todo - this doesn't check bounds.. just for testing
|
||||
lsr ; even smaller
|
||||
sta TopPipes+1,x
|
||||
lda #22
|
||||
clc
|
||||
sbc TopPipes+1,x
|
||||
sta BotPipes+1,x
|
||||
lda #95 ; Build X Value ;)
|
||||
sta TopPipes,x
|
||||
sta BotPipes,x
|
||||
inc PipeSpawnSema
|
||||
lda PipeSpawnSema
|
||||
cmp #MaxPipes
|
||||
bne :done
|
||||
lda #0 ; flip our semaphore/counter to 0
|
||||
sta PipeSpawnSema
|
||||
:done rts
|
||||
|
||||
**************************************************
|
||||
* Grass
|
||||
**************************************************
|
||||
UpdateGrass inc GrassState
|
||||
lda GrassState
|
||||
cmp #4
|
||||
bne :noReset
|
||||
lda #0
|
||||
sta GrassState
|
||||
:noReset sta TXTPAGE2
|
||||
ldx GrassState
|
||||
lda GrassTop,x
|
||||
tax
|
||||
lda MainAuxMap,x
|
||||
ldx #0
|
||||
:lp1 sta Lo23,x
|
||||
inx
|
||||
inx
|
||||
cpx #40
|
||||
bcc :lp1
|
||||
ldx GrassState
|
||||
lda GrassTop+2,x
|
||||
tax
|
||||
lda MainAuxMap,x
|
||||
ldx #0
|
||||
:lp2 sta Lo23+1,x
|
||||
inx
|
||||
inx
|
||||
cpx #40
|
||||
bcc :lp2
|
||||
|
||||
sta TXTPAGE1
|
||||
ldx GrassState
|
||||
lda GrassTop+1,x
|
||||
ldx #0
|
||||
:lp3 sta Lo23,x
|
||||
inx
|
||||
inx
|
||||
cpx #40
|
||||
bcc :lp3
|
||||
ldx GrassState
|
||||
lda GrassTop+3,x
|
||||
ldx #0
|
||||
:lp4 sta Lo23+1,x
|
||||
inx
|
||||
inx
|
||||
cpx #40
|
||||
bcc :lp4
|
||||
:bottom sta TXTPAGE2
|
||||
ldx GrassState
|
||||
lda GrassBot,x
|
||||
tax
|
||||
lda MainAuxMap,x
|
||||
ldx #0
|
||||
:lp5 sta Lo24,x
|
||||
inx
|
||||
inx
|
||||
cpx #40
|
||||
bcc :lp5
|
||||
ldx GrassState
|
||||
lda GrassBot+2,x
|
||||
tax
|
||||
lda MainAuxMap,x
|
||||
ldx #0
|
||||
:lp6 sta Lo24+1,x
|
||||
inx
|
||||
inx
|
||||
cpx #40
|
||||
bcc :lp6
|
||||
|
||||
sta TXTPAGE1
|
||||
ldx GrassState
|
||||
lda GrassBot+1,x
|
||||
ldx #0
|
||||
:lp7 sta Lo24,x
|
||||
inx
|
||||
inx
|
||||
cpx #40
|
||||
bcc :lp7
|
||||
ldx GrassState
|
||||
lda GrassBot+3,x
|
||||
ldx #0
|
||||
:lp8 sta Lo24+1,x
|
||||
inx
|
||||
inx
|
||||
cpx #40
|
||||
bcc :lp8
|
||||
rts
|
||||
|
||||
GrassState db 00
|
||||
GrassTop hex CE,CE,4E,4E,CE,CE,4E,4E
|
||||
GrassBot hex 4C,44,44,4C,4C,44,44,4C
|
||||
|
||||
WaitKey
|
||||
:kloop lda KEY
|
||||
bpl :kloop
|
||||
sta STROBE
|
||||
rts
|
||||
|
||||
**************************************************
|
||||
* See if we're running on a IIgs
|
||||
* From Apple II Technote:
|
||||
* Miscellaneous #7
|
||||
* Apple II Family Identification
|
||||
**************************************************
|
||||
DetectIIgs
|
||||
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 lda #1
|
||||
sta GMachineIIgs
|
||||
rts
|
||||
:oldmachine lda #0
|
||||
sta GMachineIIgs
|
||||
rts
|
||||
|
||||
InitState
|
||||
lda GMachineIIgs
|
||||
beq :IIe
|
||||
rts
|
||||
:IIe rts
|
||||
|
||||
GMachineIIgs dw 0
|
||||
|
||||
VBlankSafe
|
||||
* pha
|
||||
* phx
|
||||
* phy
|
||||
jsr VBlank
|
||||
* ply
|
||||
* plx
|
||||
* pla
|
||||
rts
|
||||
|
||||
VBlank lda _vblType
|
||||
bne :IIc
|
||||
jsr VBlankNormal
|
||||
rts
|
||||
:IIc rts
|
||||
|
||||
_vblType db 0 ; 0 - normal, 1 - IIc
|
||||
|
||||
**************************************************
|
||||
* Wait for vertical blanking interval - IIe/IIgs
|
||||
**************************************************
|
||||
VBlankNormal
|
||||
:loop1 lda RDVBLBAR
|
||||
bpl :loop1 ; not VBL
|
||||
:loop lda $c019
|
||||
bmi :loop ;wait for beginning of VBL interval
|
||||
rts
|
||||
|
||||
|
||||
use applerom
|
||||
use dlrlib
|
||||
use util
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
** Register preservation
|
||||
_sX dw 0
|
||||
_sY dw 0
|
||||
_sA dw 0
|
||||
_storeReg sta _sA
|
||||
stx _sX
|
||||
sty _sY
|
||||
rts
|
||||
_loadReg lda _sA
|
||||
ldx _sX
|
||||
ldy _sY
|
||||
rts
|
||||
|
||||
**************************************************
|
||||
* Awesome PRNG thx to White Flame (aka David Holz)
|
||||
**************************************************
|
||||
GetRand
|
||||
lda _randomByte
|
||||
beq :doEor
|
||||
asl
|
||||
bcc :noEor
|
||||
:doEor eor #$1d
|
||||
:noEor sta _randomByte
|
||||
rts
|
||||
_randomByte db 0
|
||||
|
||||
GetRandLow
|
||||
lda _randomByte2
|
||||
beq :doEor
|
||||
asl
|
||||
bcc :noEor
|
||||
:doEor eor #$1d
|
||||
:noEor sta _randomByte2
|
||||
cmp #$80
|
||||
bcs :hot
|
||||
lda #$0
|
||||
rts
|
||||
:hot lda #$04
|
||||
rts
|
||||
|
||||
_randomByte2 db 0
|
||||
|
||||
|
||||
Reference in New Issue
Block a user