diff --git a/macros/GTE.Macs.s b/macros/GTE.Macs.s index 1e31133..c9a2302 100644 --- a/macros/GTE.Macs.s +++ b/macros/GTE.Macs.s @@ -114,6 +114,9 @@ _GTERefresh MAC _GTERenderDirty MAC UserTool $2700+GTEToolNum <<< +_GTESetBG1Displacement MAC + UserTool $2800+GTEToolNum + <<< ; EngineMode definitions ; Script definition @@ -137,6 +140,8 @@ ENGINE_MODE_BNK0_BUFF equ $0004 ; Render flags RENDER_ALT_BG1 equ $0001 +RENDER_BG1_HORZ_OFFSET equ $0002 +RENDER_BG1_VERT_OFFSET equ $0004 ; Tile constants ; TILE_RESERVED_BIT equ $8000 diff --git a/src/Defs.s b/src/Defs.s index 5f9527d..a09177e 100644 --- a/src/Defs.s +++ b/src/Defs.s @@ -168,6 +168,8 @@ ENGINE_MODE_BNK0_BUFF equ $0004 ; Render flags RENDER_ALT_BG1 equ $0001 +RENDER_BG1_HORZ_OFFSET equ $0002 +RENDER_BG1_VERT_OFFSET equ $0004 ; DirtyBits definitions DIRTY_BIT_BG0_X equ $0001 @@ -260,6 +262,7 @@ _stamp_step EXT VBuffVertTableSelect EXT VBuffHorzTableSelect EXT Overlays EXT +BG1YCache EXT ; Tool error codes NO_TIMERS_AVAILABLE equ 10 diff --git a/src/Timer.s b/src/Timer.s index 61f3332..90727ca 100644 --- a/src/Timer.s +++ b/src/Timer.s @@ -133,8 +133,9 @@ _DoTimers sbc LastTick stx LastTick -; We don't want times to fire excessively. If the timer hasn't been evaluated for over +; We don't want timers to fire excessively. If the timer hasn't been evaluated for over ; one second, then just skip processing and wait for the next call. + cmp #60 bcc :do_timer :exit rts diff --git a/src/Tool.s b/src/Tool.s index ec661b1..ce06286 100644 --- a/src/Tool.s +++ b/src/Tool.s @@ -91,6 +91,7 @@ _CallTable adrl _TSFillTileStore-1 adrl _TSRefresh-1 adrl _TSRenderDirty-1 + adrl _TSSetBG1Displacement-1 _CTEnd _GTEAddSprite MAC UserTool $1000+GTEToolNum @@ -616,11 +617,11 @@ _TSAddTimer lda :callback+2,s tax - lda :callback,s + lda :numTicks,s tay lda :flags,s - lsr ; put low bit into carry - lda :numTicks,s + ror ; put low bit into carry + lda :callback,s jsr _AddTimer sta :output,s ldx #0 @@ -735,6 +736,18 @@ _TSRefresh jsr _Refresh _TSExit #0;#0 + +; SetBG1Displacement(offset) +_TSSetBG1Displacement +:offset equ FirstParam+0 + + _TSEntry + + lda :offset,s + and #$001E + sta BG1OffsetIndex + + _TSExit #0;#2 ; Insert the GTE code put Math.s diff --git a/src/blitter/BG1.s b/src/blitter/BG1.s index 08ab71a..3d3c72b 100644 --- a/src/blitter/BG1.s +++ b/src/blitter/BG1.s @@ -80,7 +80,12 @@ _CopyToBG1 bcc :cloop ldy #164 - lda [:srcptr] ; Duplicate the last byte in the extra space at the end of the line + lda [:srcptr] ; Duplicate the last couple of words in the extra space at the end of the line + sta [:dstptr],y + + ldy #2 + lda [:srcptr],y + ldy #166 sta [:dstptr],y lda :srcptr @@ -237,10 +242,21 @@ _ApplyBG1YPos asl tax + lda RenderFlags + bit #RENDER_BG1_HORZ_OFFSET ; Are we using horizontal displacement? + beq :no_displacement + + lda :ytbl_idx ; Read from this location in the BG1YTable + asl + jsr CopyBG1YTableToBG1Addr2 + bra :next_step + +:no_displacement lda :ytbl_idx ; Read from this location in the BG1YTable asl jsr CopyBG1YTableToBG1Addr ; or CopyBG1YTableToBG1Addr2 +:next_step lda :virt_line ; advance to the virtual line after the segment we just clc ; filled in adc :draw_count @@ -347,8 +363,10 @@ CopyBG1YTableToBG1Addr2 phy ; save the registers phx phb + pha + jsr _SetDataBank ; Set to toolbox data bank - jsr _SetDataBank ; restore access to this bank + pla ldy BG1OffsetIndex ; Get the offset and save the values jsr SaveBG1OffsetValues @@ -485,6 +503,4 @@ ApplyBG1OffsetValues sta BG1_ADDR+$1000,y :do01 ldal BG1YCache+00 sta: BG1_ADDR+$0000,y -:none rts - -BG1YCache ds 32 +:none rts \ No newline at end of file diff --git a/src/static/TileStore.s b/src/static/TileStore.s index 06c218c..2b1eee3 100644 --- a/src/static/TileStore.s +++ b/src/static/TileStore.s @@ -375,10 +375,14 @@ BG1YTable ENT ]step = ]step+256 --^ +BG1YCache ENT + ds 32 + ; Repeat BG1YOffsetTable ENT - lup 26 + lup 2 dw 1,1,1,2,2,2,2,2,1,1,1,0,0,0,0,0 +; dw 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 --^ ; Other Toolset variables