mirror of
https://github.com/lscharen/iigs-game-engine.git
synced 2025-01-13 19:29:52 +00:00
Add VSYNC toggle
This commit is contained in:
parent
45ad44f1a6
commit
bab57f6e43
@ -94,6 +94,22 @@ EvtLoop
|
||||
lda #$FFF8
|
||||
sta PlayerYVel
|
||||
:no_jump
|
||||
|
||||
|
||||
; Enable/disable v-sync
|
||||
lda 1,s
|
||||
bit #$0400
|
||||
beq :no_key_down
|
||||
and #$007F
|
||||
cmp #'v'
|
||||
bne :not_v
|
||||
lda #$0001
|
||||
eor vsync
|
||||
sta vsync
|
||||
:not_v
|
||||
:no_key_down
|
||||
|
||||
|
||||
pla
|
||||
and #$007F ; Ignore the buttons for now
|
||||
|
||||
@ -165,6 +181,7 @@ EvtLoop
|
||||
bra :do_render
|
||||
:not_l
|
||||
|
||||
|
||||
; Update the camera position
|
||||
|
||||
:do_render
|
||||
@ -178,8 +195,25 @@ EvtLoop
|
||||
jsl UpdateSprite ; Move the sprite to this local position
|
||||
|
||||
; Let's see what it looks like!
|
||||
|
||||
lda vsync
|
||||
beq :no_vsync
|
||||
:vsyncloop jsl GetVerticalCounter ; 8-bit value
|
||||
cmp ScreenY0
|
||||
bcc :vsyncloop
|
||||
sec
|
||||
sbc ScreenY0
|
||||
cmp #8
|
||||
bcs :vsyncloop
|
||||
lda #1
|
||||
jsl SetBorderColor
|
||||
:no_vsync
|
||||
jsl Render
|
||||
|
||||
lda vsync
|
||||
beq :no_vsync2
|
||||
lda #0
|
||||
jsl SetBorderColor
|
||||
:no_vsync2
|
||||
|
||||
; Update the performance counters
|
||||
|
||||
@ -435,6 +469,8 @@ MovePlayerToOrigin
|
||||
qtRec adrl $0000
|
||||
da $00
|
||||
|
||||
vsync dw $0000
|
||||
|
||||
PUT ../shell/Overlay.s
|
||||
PUT gen/App.TileMapBG0.s
|
||||
PUT gen/App.TileSetAnim.s
|
||||
|
17
src/Core.s
17
src/Core.s
@ -343,6 +343,7 @@ ClearKbdStrobe sep #$20
|
||||
rts
|
||||
|
||||
; Read the keyboard and paddle controls and return in a game-controller-like format
|
||||
LastKey db 0
|
||||
ReadControl ENT
|
||||
pea $0000 ; low byte = key code, high byte = %------AB
|
||||
|
||||
@ -351,7 +352,7 @@ ReadControl ENT
|
||||
and #$80
|
||||
beq :BNotDown
|
||||
|
||||
lda #1
|
||||
lda #PAD_BUTTON_B
|
||||
ora 2,s
|
||||
sta 2,s
|
||||
|
||||
@ -360,7 +361,7 @@ ReadControl ENT
|
||||
and #$80
|
||||
beq :ANotDown
|
||||
|
||||
lda #2
|
||||
lda #PAD_BUTTON_A
|
||||
ora 2,s
|
||||
sta 2,s
|
||||
|
||||
@ -372,7 +373,19 @@ ReadControl ENT
|
||||
ora 1,s
|
||||
sta 1,s
|
||||
|
||||
cmpl LastKey
|
||||
beq :KbdDown
|
||||
stal LastKey
|
||||
|
||||
lda #PAD_KEY_DOWN ; set the keydown flag
|
||||
ora 2,s
|
||||
sta 2,s
|
||||
bra :KbdDown
|
||||
|
||||
:KbdNotDwn
|
||||
lda #0
|
||||
stal LastKey
|
||||
:KbdDown
|
||||
rep #$20
|
||||
pla
|
||||
rtl
|
||||
|
@ -119,6 +119,11 @@ SWAP_PALETTE_ENTRY equ $0004
|
||||
SET_DYN_TILE equ $0006
|
||||
CALLBACK equ $0010
|
||||
|
||||
; ReadControl return value bits
|
||||
PAD_BUTTON_B equ $01
|
||||
PAD_BUTTON_A equ $02
|
||||
PAD_KEY_DOWN equ $04
|
||||
|
||||
; Tile constants
|
||||
TILE_ID_MASK equ $01FF
|
||||
TILE_SPRITE_BIT equ $8000 ; Set if this tile intersects an active sprite
|
||||
|
@ -10,6 +10,8 @@ ReadControl EXT
|
||||
; Low-Level Functions
|
||||
SetPalette EXT
|
||||
GetVBLTicks EXT
|
||||
GetVerticalCounter EXT
|
||||
SetBorderColor EXT
|
||||
|
||||
; Tilemap functions
|
||||
SetBG0XPos EXT
|
||||
|
@ -126,6 +126,9 @@ _ShadowOff
|
||||
rep #$20
|
||||
rts
|
||||
|
||||
GetVerticalCounter ENT
|
||||
jsr _GetVBL
|
||||
rtl
|
||||
_GetVBL
|
||||
sep #$20
|
||||
ldal VBL_HORZ_REG
|
||||
|
Loading…
x
Reference in New Issue
Block a user